Class LatLonPointPrototypeQueries
- java.lang.Object
-
- org.apache.lucene.sandbox.search.LatLonPointPrototypeQueries
-
public class LatLonPointPrototypeQueries extends Object
Holder class for prototype sandboxed queriesWhen the query graduates from sandbox, these static calls should be placed in
LatLonPoint- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TopFieldDocsnearest(IndexSearcher searcher, String field, double latitude, double longitude, int n)Finds thennearest indexed points to the provided point, according to Haversine distance.
-
-
-
Method Detail
-
nearest
public static TopFieldDocs nearest(IndexSearcher searcher, String field, double latitude, double longitude, int n) throws IOException
Finds thennearest indexed points to the provided point, according to Haversine distance.This is functionally equivalent to running
MatchAllDocsQuerywith aLatLonDocValuesField.newDistanceSort(java.lang.String, double, double), but is far more efficient since it takes advantage of properties the indexed BKD tree. Currently this only works withLucene90PointsFormat(used by the default codec). Multi-valued fields are currently not de-duplicated, so if a document had multiple instances of the specified field that make it into the top n, that document will appear more than once.Documents are ordered by ascending distance from the location. The value returned in
FieldDocfor the hits contains a Double instance with the distance in meters.- Parameters:
searcher- IndexSearcher to find nearest points from.field- field name. must not be null.latitude- latitude at the center: must be within standard +/-90 coordinate bounds.longitude- longitude at the center: must be within standard +/-180 coordinate bounds.n- the number of nearest neighbors to retrieve.- Returns:
- TopFieldDocs containing documents ordered by distance, where the field value for each
FieldDocis the distance in meters - Throws:
IllegalArgumentException- if the underlying PointValues is not aLucene60PointsReader(this is a current limitation), or iffieldorsearcheris null, or iflatitude,longitudeornare out-of-boundsIOException- if an IOException occurs while finding the points.
-
-