Class GeoDistanceQueryBuilder

All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>

public class GeoDistanceQueryBuilder
extends AbstractQueryBuilder<GeoDistanceQueryBuilder>
Filter results of a query to include only those within a specific distance to some geo point.
  • Field Details

    • NAME

      public static final java.lang.String NAME
      See Also:
      Constant Field Values

      public static final DistanceUnit DEFAULT_DISTANCE_UNIT
      Default for distance unit computation.

      public static final GeoDistance DEFAULT_GEO_DISTANCE
      Default for geo distance computation.

      public static final boolean DEFAULT_IGNORE_UNMAPPED
      The default value for ignore_unmapped.
      See Also:
      Constant Field Values
  • Constructor Details

    • GeoDistanceQueryBuilder

      public GeoDistanceQueryBuilder​(java.lang.String fieldName)
      Construct new GeoDistanceQueryBuilder.
      fieldName - name of indexed geo field to operate distance computation on.
    • GeoDistanceQueryBuilder

      public GeoDistanceQueryBuilder​(StreamInput in) throws
      Read from a stream.
  • Method Details

    • doWriteTo

      protected void doWriteTo​(StreamOutput out) throws
      Specified by:
      doWriteTo in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
    • fieldName

      public java.lang.String fieldName()
      Name of the field this query is operating on.
    • point

      public GeoDistanceQueryBuilder point​(GeoPoint point)
      Sets the center point for the query.
      point - the center of the query
    • point

      public GeoDistanceQueryBuilder point​(double lat, double lon)
      Sets the center point of the query.
      lat - latitude of center
      lon - longitude of center
    • point

      public GeoPoint point()
      Returns the center point of the distance query.
    • distance

      public GeoDistanceQueryBuilder distance​(java.lang.String distance)
      Sets the distance from the center using the default distance unit.
    • distance

      public GeoDistanceQueryBuilder distance​(java.lang.String distance, DistanceUnit unit)
      Sets the distance from the center for this query.
    • distance

      public GeoDistanceQueryBuilder distance​(double distance, DistanceUnit unit)
      Sets the distance from the center for this query.
    • distance

      public double distance()
      Returns the distance configured as radius.
    • geohash

      public GeoDistanceQueryBuilder geohash​(java.lang.String geohash)
      Sets the center point for this query.
    • geoDistance

      public GeoDistanceQueryBuilder geoDistance​(GeoDistance geoDistance)
      Which type of geo distance calculation method to use.
    • geoDistance

      public GeoDistance geoDistance()
      Returns geo distance calculation type to use.
    • setValidationMethod

      public void setValidationMethod​(GeoValidationMethod method)
      Set validation method for geo coordinates.
    • getValidationMethod

      public GeoValidationMethod getValidationMethod()
      Returns validation method for geo coordinates.
    • ignoreUnmapped

      public GeoDistanceQueryBuilder ignoreUnmapped​(boolean ignoreUnmapped)
      Sets whether the query builder should ignore unmapped fields (and run a MatchNoDocsQuery in place of this query) or throw an exception if the field is unmapped.
    • ignoreUnmapped

      public boolean ignoreUnmapped()
      Gets whether the query builder will ignore unmapped fields (and run a MatchNoDocsQuery in place of this query) or throw an exception if the field is unmapped.
    • doToQuery

      protected doToQuery​(SearchExecutionContext context) throws
      Specified by:
      doToQuery in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
    • doXContent

      protected void doXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      Specified by:
      doXContent in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
    • fromXContent

      public static GeoDistanceQueryBuilder fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser) throws
    • doHashCode

      protected int doHashCode()
      Specified by:
      doHashCode in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
    • doEquals

      protected boolean doEquals​(GeoDistanceQueryBuilder other)
      Description copied from class: AbstractQueryBuilder
      Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
      Specified by:
      doEquals in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
    • getWriteableName

      public java.lang.String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object