Fast range faceting using segment trees and the Java ASM library by Mike McCandless.
From the post:
In Lucene’s facet module we recently added support for dynamic range faceting, to show how many hits match each of a dynamic set of ranges. For example, the Updated drill-down in the Lucene/Solr issue search application uses range facets. Another example is distance facets (< 1 km, < 2 km, etc.), where the distance is dynamically computed based on the user's current location. Price faceting might also use range facets, if the ranges cannot be established during indexing.
To implement range faceting, for each hit, we first calculate the value (the distance, the age, the price) to be aggregated, and then lookup which ranges match that value and increment its counts. Today we use a simple linear search through all ranges, which has O(N) cost, where N is the number of ranges.
But this is inefficient!
Mike lays out a more efficient approach, that hasn’t been folded into Lucene, yet.
I like the example of distance from a user as an example of distance as a dynamic facet.
Distance issues are common with mobile devices, but most of those are merchants trying to sell you something.
Not a public database use case, but what if you had an alternative map of a metropolitan area? Where the distance issue was to caches, safe houses, contacts, etc.?
You are double thumbing your mobile device just like everyone else but yours is displaying different data.
You could get false information that is auto-corrected by a local app. 😉
You may have heard the old saying:
The old saying goes that God made men, but Sam Colt made them equal.
We may need to add IT to that list.