public final class GeoPointField extends Field
Field that indexes latitude
longitude
decimal-degree values
for efficient encoding, sorting, and querying. This Geo capability is intended
to provide a basic and efficient out of the box field type for indexing and
querying 2 dimensional points in WGS-84 decimal degrees. An example usage is as follows:
document.add(new GeoPointField(name, -96.33, 32.66, Field.Store.NO));
To perform simple geospatial queries against a GeoPointField
,
see GeoPointInBBoxQuery
, GeoPointInPolygonQuery
,
or GeoPointDistanceQuery
NOTE: This indexes only high precision encoded terms which may result in visiting a high number
of terms for large queries. See LUCENE-6481 for a future improvement.
Modifier and Type | Class and Description |
---|---|
static class |
GeoPointField.TermEncoding
Expert: Optional flag to select term encoding for GeoPointField types
|
Field.Store
Modifier and Type | Field and Description |
---|---|
static short |
BITS
number of bits used for quantizing latitude and longitude values
|
static FieldType |
NUMERIC_TYPE_NOT_STORED
Deprecated.
Type for a GeoPointField that is not stored:
normalization factors, frequencies, and positions are omitted.
|
static FieldType |
NUMERIC_TYPE_STORED
Deprecated.
Type for a stored GeoPointField:
normalization factors, frequencies, and positions are omitted.
|
static int |
PRECISION_STEP
encoding step value for GeoPoint prefix terms
|
static FieldType |
PREFIX_TYPE_NOT_STORED
Type for a GeoPointField that is not stored:
normalization factors, frequencies, and positions are omitted.
|
static FieldType |
PREFIX_TYPE_STORED
Type for a stored GeoPointField:
normalization factors, frequencies, and positions are omitted.
|
boost, fieldsData, name, tokenStream, type
Constructor and Description |
---|
GeoPointField(String name,
double latitude,
double longitude,
Field.Store stored)
Creates a stored or un-stored GeoPointField
|
GeoPointField(String name,
double latitude,
double longitude,
FieldType type)
Expert: allows you to customize the
FieldType . |
GeoPointField(String name,
double latitude,
double longitude,
GeoPointField.TermEncoding termEncoding,
Field.Store stored)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static double |
decodeLatitude(long hash)
decode latitude value from morton encoded geo point
|
static double |
decodeLongitude(long hash)
decode longitude value from morton encoded geo point
|
static long |
encodeLatLon(double lat,
double lon)
31 bit encoding utils *
|
static void |
geoCodedToPrefixCoded(long hash,
int shift,
BytesRefBuilder bytes)
Convert a geocoded morton long into a prefix coded geo term
|
double |
getLat()
access latitude value
|
double |
getLon()
access longitude value
|
static int |
getPrefixCodedShift(BytesRef val)
Get the prefix coded geo term shift value
|
static long |
prefixCodedToGeoCoded(BytesRef val)
Convert a prefix coded geo term back into the geocoded morton long
|
TokenStream |
tokenStream(Analyzer analyzer,
TokenStream reuse) |
String |
toString() |
binaryValue, boost, fieldType, name, numericValue, readerValue, setBoost, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStreamValue
public static final int PRECISION_STEP
public static final short BITS
@Deprecated public static final FieldType NUMERIC_TYPE_NOT_STORED
@Deprecated public static final FieldType NUMERIC_TYPE_STORED
public static final FieldType PREFIX_TYPE_NOT_STORED
public static final FieldType PREFIX_TYPE_STORED
public GeoPointField(String name, double latitude, double longitude, Field.Store stored)
name
- field namelatitude
- latitude double value [-90.0 : 90.0]longitude
- longitude double value [-180.0 : 180.0]stored
- Store.YES if the content should also be storedIllegalArgumentException
- if the field name is null.@Deprecated public GeoPointField(String name, double latitude, double longitude, GeoPointField.TermEncoding termEncoding, Field.Store stored)
GeoPointField.TermEncoding
methodname
- field namelatitude
- latitude double value [-90.0 : 90.0]longitude
- longitude double value [-180.0 : 180.0]termEncoding
- encoding type to use (GeoPointField.TermEncoding.NUMERIC
Terms, or GeoPointField.TermEncoding.PREFIX
only Terms)stored
- Store.YES if the content should also be storedIllegalArgumentException
- if the field name is null.public GeoPointField(String name, double latitude, double longitude, FieldType type)
FieldType
.name
- field namelatitude
- latitude double value [-90.0 : 90.0]longitude
- longitude double value [-180.0 : 180.0]type
- customized field type: must have FieldType.numericType()
of FieldType.LegacyNumericType.LONG
.IllegalArgumentException
- if the field name or type is null, or
if the field type does not have a LONG numericType()public TokenStream tokenStream(Analyzer analyzer, TokenStream reuse)
tokenStream
in interface IndexableField
tokenStream
in class Field
public double getLat()
public double getLon()
public static long encodeLatLon(double lat, double lon)
public static final double decodeLongitude(long hash)
public static final double decodeLatitude(long hash)
public static void geoCodedToPrefixCoded(long hash, int shift, BytesRefBuilder bytes)
public static long prefixCodedToGeoCoded(BytesRef val)
public static int getPrefixCodedShift(BytesRef val)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.