Package org.apache.lucene.demo.facet
Class DistanceFacetsExample
- java.lang.Object
-
- org.apache.lucene.demo.facet.DistanceFacetsExample
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DistanceFacetsExample extends Object implements Closeable
Shows simple usage of dynamic range faceting, using the expressions module to calculate distance.
-
-
Field Summary
Fields Modifier and Type Field Description static doubleEARTH_RADIUS_KMMean radius of the Earth in KMstatic doubleORIGIN_LATITUDEThe "home" latitude.static doubleORIGIN_LONGITUDEThe "home" longitude.
-
Constructor Summary
Constructors Constructor Description DistanceFacetsExample()Empty constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()TopDocsdrillDown(DoubleRange range)User drills down on the specified range.static QuerygetBoundingBoxQuery(double originLat, double originLng, double maxDistanceKM)Given a latitude and longitude (in degrees) and the maximum great circle (surface of the earth) distance, returns a simple Filter bounding box to "fast match" candidates.voidindex()Build the example index.static voidmain(String[] args)Runs the search and drill-down examples and prints the results.FacetResultsearch()User runs a query and counts facets.
-
-
-
Field Detail
-
ORIGIN_LATITUDE
public static final double ORIGIN_LATITUDE
The "home" latitude.- See Also:
- Constant Field Values
-
ORIGIN_LONGITUDE
public static final double ORIGIN_LONGITUDE
The "home" longitude.- See Also:
- Constant Field Values
-
EARTH_RADIUS_KM
public static final double EARTH_RADIUS_KM
Mean radius of the Earth in KMNOTE: this is approximate, because the earth is a bit wider at the equator than the poles. See http://en.wikipedia.org/wiki/Earth_radius
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DistanceFacetsExample
public DistanceFacetsExample()
Empty constructor
-
-
Method Detail
-
index
public void index() throws IOException
Build the example index.- Throws:
IOException
-
getBoundingBoxQuery
public static Query getBoundingBoxQuery(double originLat, double originLng, double maxDistanceKM)
Given a latitude and longitude (in degrees) and the maximum great circle (surface of the earth) distance, returns a simple Filter bounding box to "fast match" candidates.
-
search
public FacetResult search() throws IOException
User runs a query and counts facets.- Throws:
IOException
-
drillDown
public TopDocs drillDown(DoubleRange range) throws IOException
User drills down on the specified range.- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-