org.apache.lucene.spatial.geopoint.document

## Class GeoPointField

- java.lang.Object
- - org.apache.lucene.document.Field
  - - org.apache.lucene.spatial.geopoint.document.GeoPointField

- All Implemented Interfaces:
    IndexableField

      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.

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GeoPointField.TermEncoding` Expert: Optional flag to select term encoding for GeoPointField types

    - ### Nested classes/interfaces inherited from class org.apache.lucene.document.Field

      `Field.Index, Field.Store, Field.TermVector`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `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.

    - ### Fields inherited from class org.apache.lucene.document.Field

      `boost, fieldsData, name, tokenStream, type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeoPointField(String name, double lon, double lat, Field.Store stored)` Creates a stored or un-stored GeoPointField
    `GeoPointField(String name, double lon, double lat, FieldType type)` Expert: allows you to customize the `FieldType`.
    `GeoPointField(String name, double lon, double lat, GeoPointField.TermEncoding termEncoding, Field.Store stored)` Deprecated.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getLat()` access latitude value
    `double` | `getLon()` access longitude value
    `TokenStream` | `tokenStream(Analyzer analyzer, TokenStream reuse)`
    `String` | `toString()`

    - ### Methods inherited from class org.apache.lucene.document.Field

      `binaryValue, boost, fieldType, name, numericValue, readerValue, setBoost, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStreamValue, translateFieldType`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### PRECISION_STEP

          public static final int PRECISION_STEP

      encoding step value for GeoPoint prefix terms
      See Also:
        Constant Field Values

    - #### NUMERIC_TYPE_NOT_STORED

          @Deprecated
          public static final FieldType NUMERIC_TYPE_NOT_STORED

      Deprecated. Type for a GeoPointField that is not stored: normalization factors, frequencies, and positions are omitted.

    - #### NUMERIC_TYPE_STORED

          @Deprecated
          public static final FieldType NUMERIC_TYPE_STORED

      Deprecated. Type for a stored GeoPointField: normalization factors, frequencies, and positions are omitted.

    - #### PREFIX_TYPE_NOT_STORED

          public static final FieldType PREFIX_TYPE_NOT_STORED

      Type for a GeoPointField that is not stored: normalization factors, frequencies, and positions are omitted.

    - #### PREFIX_TYPE_STORED

          public static final FieldType PREFIX_TYPE_STORED

      Type for a stored GeoPointField: normalization factors, frequencies, and positions are omitted.

  - ### Constructor Detail

    - #### GeoPointField

          public GeoPointField(String name,
                       double lon,
                       double lat,
                       Field.Store stored)

      Creates a stored or un-stored GeoPointField
      Parameters:
        `name` - field name
        `lon` - longitude double value [-180.0 : 180.0]
        `lat` - latitude double value [-90.0 : 90.0]
        `stored` - Store.YES if the content should also be stored
      Throws:
        `IllegalArgumentException` - if the field name is null.

    - #### GeoPointField

          @Deprecated
          public GeoPointField(String name,
                                  double lon,
                                  double lat,
                                  GeoPointField.TermEncoding termEncoding,
                                  Field.Store stored)

      Deprecated.
      Creates a stored or un-stored GeoPointField using the specified `GeoPointField.TermEncoding` method
      Parameters:
        `name` - field name
        `lon` - longitude double value [-180.0 : 180.0]
        `lat` - latitude double value [-90.0 : 90.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 stored
      Throws:
        `IllegalArgumentException` - if the field name is null.

    - #### GeoPointField

          public GeoPointField(String name,
                       double lon,
                       double lat,
                       FieldType type)

      Expert: allows you to customize the `FieldType`.
      Parameters:
        `name` - field name
        `lon` - longitude double value [-180.0 : 180.0]
        `lat` - latitude double value [-90.0 : 90.0]
        `type` - customized field type: must have `FieldType.numericType()` of `FieldType.NumericType.LONG`.
      Throws:
        `IllegalArgumentException` - if the field name or type is null, or if the field type does not have a LONG numericType()

  - ### Method Detail

    - #### tokenStream

          public TokenStream tokenStream(Analyzer analyzer,
                                TokenStream reuse)

      Specified by:
        `tokenStream` in interface `IndexableField`
      Overrides:
        `tokenStream` in class `Field`

    - #### getLon

          public double getLon()

      access longitude value

    - #### getLat

          public double getLat()

      access latitude value

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Field`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.