Class GeoBoundingBoxQueryBuilder

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

public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
Creates a Lucene query that will filter for all documents that lie within the specified bounding box. This query can only operate on fields of type geo_point that have latitude and longitude enabled.
  • Field Details

    • NAME

      public static final  NAME
      See Also:
      Constant Field Values
    • DEFAULT_TYPE

      public static final GeoExecType DEFAULT_TYPE
      Default type for executing this query (memory as of this writing).
    • DEFAULT_IGNORE_UNMAPPED

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

    • GeoBoundingBoxQueryBuilder

      public GeoBoundingBoxQueryBuilder( fieldName)
      Create new bounding box query.
      Parameters:
      fieldName - name of index field containing geo coordinates to operate on.
    • GeoBoundingBoxQueryBuilder

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

    • doWriteTo

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

      public GeoBoundingBoxQueryBuilder setCorners(double top, double left, double bottom, double right)
      Adds top left point.
      Parameters:
      top - The top latitude
      left - The left longitude
      bottom - The bottom latitude
      right - The right longitude
    • setCorners

      public GeoBoundingBoxQueryBuilder setCorners(GeoPoint topLeft, GeoPoint bottomRight)
      Adds points.
      Parameters:
      topLeft - topLeft point to add.
      bottomRight - bottomRight point to add.
    • setCorners

      public  geohash)
      Adds points from a single geohash.
      Parameters:
      geohash - The geohash for computing the bounding box.
    • setCorners

      public  topLeft,  bottomRight)
      Adds points.
      Parameters:
      topLeft - topLeft point to add as geohash.
      bottomRight - bottomRight point to add as geohash.
    • topLeft

      public GeoPoint topLeft()
      Returns the top left corner of the bounding box.
    • bottomRight

      public GeoPoint bottomRight()
      Returns the bottom right corner of the bounding box.
    • setCornersOGC

      public GeoBoundingBoxQueryBuilder setCornersOGC(GeoPoint bottomLeft, GeoPoint topRight)
      Adds corners in OGC standard bbox/ envelop format.
      Parameters:
      bottomLeft - bottom left corner of bounding box.
      topRight - top right corner of bounding box.
    • setCornersOGC

      public  bottomLeft,  topRight)
      Adds corners in OGC standard bbox/ envelop format.
      Parameters:
      bottomLeft - bottom left corner geohash.
      topRight - top right corner geohash.
    • setValidationMethod

      public GeoBoundingBoxQueryBuilder setValidationMethod(GeoValidationMethod method)
      Specify whether or not to ignore validation errors of bounding boxes. Can only be set if coerce set to false, otherwise calling this method has no effect.
    • getValidationMethod

      public GeoValidationMethod getValidationMethod()
      Returns geo coordinate validation method to use.
    • type

      public GeoBoundingBoxQueryBuilder type(GeoExecType type)
      Sets the type of executing of the geo bounding box. Can be either `memory` or `indexed`. Defaults to `memory`.
    • type

      public  type)
      For BWC: Parse type from type name.
    • type

      public GeoExecType type()
      Returns the execution type of the geo bounding box.
    • fieldName

      public  fieldName()
      Returns the name of the field to base the bounding box computation on.
    • ignoreUnmapped

      public GeoBoundingBoxQueryBuilder 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

      public org.apache.lucene.search.Query doToQuery(SearchExecutionContext context)
      Specified by:
      doToQuery in class AbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
    • doXContent

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

      public static GeoBoundingBoxQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws
      Throws:
    • doEquals

      protected boolean doEquals(GeoBoundingBoxQueryBuilder 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<GeoBoundingBoxQueryBuilder>
    • doHashCode

      protected int doHashCode()
      Specified by:
      doHashCode in class AbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
    • getWriteableName

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