Class GeoDistanceQueryBuilder

org.elasticsearch.index.query.AbstractQueryBuilder<GeoDistanceQueryBuilder>
org.elasticsearch.index.query.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  NAME
      See Also:
      Constant Field Values
    • DEFAULT_DISTANCE_UNIT

      public static final DistanceUnit DEFAULT_DISTANCE_UNIT
      Default for distance unit computation.
    • DEFAULT_GEO_DISTANCE

      public static final GeoDistance DEFAULT_GEO_DISTANCE
      Default for geo distance computation.
    • DEFAULT_IGNORE_UNMAPPED

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

    • GeoDistanceQueryBuilder

      public GeoDistanceQueryBuilder( fieldName)
      Construct new GeoDistanceQueryBuilder.
      Parameters:
      fieldName - name of indexed geo field to operate distance computation on.
    • GeoDistanceQueryBuilder

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

    • doWriteTo

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

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

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

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

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

      public  distance)
      Sets the distance from the center using the default distance unit.
    • distance

      public  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  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 org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws
      Specified by:
      doToQuery in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
      Throws:
    • 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>
      Throws:
    • fromXContent

      public static GeoDistanceQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws
      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  getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object