public class LatLonDocValuesField extends Field
Sorting by distance is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for common operations:
newDistanceSort()
for ordering documents by distance from a specified location.
If you also need query operations, you should add a separate LatLonPoint
instance.
If you also need to store the value, you should add a separate StoredField
instance.
WARNING: Values are indexed with some loss of precision from the
original double
values (4.190951585769653E-8 for the latitude component
and 8.381903171539307E-8 for longitude).
LatLonPoint
Field.Store
Modifier and Type | Field and Description |
---|---|
static FieldType |
TYPE
Type for a LatLonDocValuesField
|
fieldsData, name, tokenStream, type
Constructor and Description |
---|
LatLonDocValuesField(String name,
double latitude,
double longitude)
Creates a new LatLonDocValuesField with the specified latitude and longitude
|
Modifier and Type | Method and Description |
---|---|
static SortField |
newDistanceSort(String field,
double latitude,
double longitude)
Creates a SortField for sorting by distance from a location.
|
static Query |
newSlowBoxQuery(String field,
double minLatitude,
double maxLatitude,
double minLongitude,
double maxLongitude)
Create a query for matching a bounding box using doc values.
|
static Query |
newSlowDistanceQuery(String field,
double latitude,
double longitude,
double radiusMeters)
Create a query for matching points within the specified distance of the supplied location.
|
void |
setLocationValue(double latitude,
double longitude)
Change the values of this field
|
String |
toString() |
binaryValue, fieldType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
public static final FieldType TYPE
Each value stores a 64-bit long where the upper 32 bits are the encoded latitude, and the lower 32 bits are the encoded longitude.
public LatLonDocValuesField(String name, double latitude, double longitude)
name
- field namelatitude
- latitude value: must be within standard +/-90 coordinate bounds.longitude
- longitude value: must be within standard +/-180 coordinate bounds.IllegalArgumentException
- if the field name is null or latitude or longitude are out of boundspublic void setLocationValue(double latitude, double longitude)
latitude
- latitude value: must be within standard +/-90 coordinate bounds.longitude
- longitude value: must be within standard +/-180 coordinate bounds.IllegalArgumentException
- if latitude or longitude are out of boundspublic static SortField newDistanceSort(String field, double latitude, double longitude)
This sort orders documents by ascending distance from the location. The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance to the location is used.
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.IllegalArgumentException
- if field
is null or location has invalid coordinates.public static Query newSlowBoxQuery(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
IndexOrDocValuesQuery
alongside a
LatLonPoint.newBoxQuery(java.lang.String, double, double, double, double)
.public static Query newSlowDistanceQuery(String field, double latitude, double longitude, double radiusMeters)
IndexOrDocValuesQuery
alongside a
LatLonPoint.newDistanceQuery(java.lang.String, double, double, double)
.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.radiusMeters
- maximum distance from the center in meters: must be non-negative and finite.IllegalArgumentException
- if field
is null, location has invalid coordinates, or radius is invalid.Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.