Package org.elasticsearch.index.query
Class GeoBoundingBoxQueryBuilder
java.lang.Object
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_IGNORE_UNMAPPEDThe default value for ignore_unmapped.static GeoExecTypeDEFAULT_TYPEDefault type for executing this query (memory as of this writing).static java.lang.StringNAMEFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName -
Constructor Summary
Constructors Constructor Description GeoBoundingBoxQueryBuilder(java.lang.String fieldName)Create new bounding box query.GeoBoundingBoxQueryBuilder(StreamInput in)Read from a stream. -
Method Summary
Modifier and Type Method Description GeoPointbottomRight()Returns the bottom right corner of the bounding box.protected booleandoEquals(GeoBoundingBoxQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)java.lang.StringfieldName()Returns the name of the field to base the bounding box computation on.static GeoBoundingBoxQueryBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)GeoValidationMethodgetValidationMethod()Returns geo coordinate validation method to use.java.lang.StringgetWriteableName()Returns the name of the writeable objectbooleanignoreUnmapped()Gets whether the query builder will ignore unmapped fields (and run aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped.GeoBoundingBoxQueryBuilderignoreUnmapped(boolean ignoreUnmapped)Sets whether the query builder should ignore unmapped fields (and run aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped.GeoBoundingBoxQueryBuildersetCorners(double top, double left, double bottom, double right)Adds top left point.GeoBoundingBoxQueryBuildersetCorners(java.lang.String geohash)Adds points from a single geohash.GeoBoundingBoxQueryBuildersetCorners(java.lang.String topLeft, java.lang.String bottomRight)Adds points.GeoBoundingBoxQueryBuildersetCorners(GeoPoint topLeft, GeoPoint bottomRight)Adds points.GeoBoundingBoxQueryBuildersetCornersOGC(java.lang.String bottomLeft, java.lang.String topRight)Adds corners in OGC standard bbox/ envelop format.GeoBoundingBoxQueryBuildersetCornersOGC(GeoPoint bottomLeft, GeoPoint topRight)Adds corners in OGC standard bbox/ envelop format.GeoBoundingBoxQueryBuildersetValidationMethod(GeoValidationMethod method)Specify whether or not to ignore validation errors of bounding boxes.GeoPointtopLeft()Returns the top left corner of the bounding box.GeoExecTypetype()Returns the execution type of the geo bounding box.GeoBoundingBoxQueryBuildertype(java.lang.String type)For BWC: Parse type from type name.GeoBoundingBoxQueryBuildertype(GeoExecType type)Sets the type of executing of the geo bounding box.Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
DEFAULT_TYPE
Default type for executing this query (memory as of this writing). -
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPEDThe default value for ignore_unmapped.- See Also:
- Constant Field Values
-
-
Constructor Details
-
GeoBoundingBoxQueryBuilder
public GeoBoundingBoxQueryBuilder(java.lang.String fieldName)Create new bounding box query.- Parameters:
fieldName- name of index field containing geo coordinates to operate on.
-
GeoBoundingBoxQueryBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>- Throws:
java.io.IOException
-
setCorners
Adds top left point.- Parameters:
top- The top latitudeleft- The left longitudebottom- The bottom latituderight- The right longitude
-
setCorners
Adds points.- Parameters:
topLeft- topLeft point to add.bottomRight- bottomRight point to add.
-
setCorners
Adds points from a single geohash.- Parameters:
geohash- The geohash for computing the bounding box.
-
setCorners
public GeoBoundingBoxQueryBuilder setCorners(java.lang.String topLeft, java.lang.String bottomRight)Adds points.- Parameters:
topLeft- topLeft point to add as geohash.bottomRight- bottomRight point to add as geohash.
-
topLeft
Returns the top left corner of the bounding box. -
bottomRight
Returns the bottom right corner of the bounding box. -
setCornersOGC
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 GeoBoundingBoxQueryBuilder setCornersOGC(java.lang.String bottomLeft, java.lang.String topRight)Adds corners in OGC standard bbox/ envelop format.- Parameters:
bottomLeft- bottom left corner geohash.topRight- top right corner geohash.
-
setValidationMethod
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
Returns geo coordinate validation method to use. -
type
Sets the type of executing of the geo bounding box. Can be either `memory` or `indexed`. Defaults to `memory`. -
type
For BWC: Parse type from type name. -
type
Returns the execution type of the geo bounding box. -
fieldName
public java.lang.String fieldName()Returns the name of the field to base the bounding box computation on. -
ignoreUnmapped
Sets whether the query builder should ignore unmapped fields (and run aMatchNoDocsQueryin 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 aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped. -
doToQuery
- Specified by:
doToQueryin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
-
doXContent
protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
doXContentin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static GeoBoundingBoxQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
doEquals
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
-
doHashCode
protected int doHashCode()- Specified by:
doHashCodein classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object
-