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>
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
FieldsModifier and TypeFieldDescriptionstatic booleanThe default value for ignore_unmapped.static GeoExecTypeDefault type for executing this query (memory as of this writing).static StringFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryNameFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionGeoBoundingBoxQueryBuilder(String fieldName)Create new bounding box query.Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionReturns the bottom right corner of the bounding box.protected booleanIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intorg.apache.lucene.search.QuerydoToQuery(SearchExecutionContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)Returns the name of the field to base the bounding box computation on.static GeoBoundingBoxQueryBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)Returns geo coordinate validation method to use.Returns the name of the writeable objectbooleanGets whether the query builder will ignore unmapped fields (and run aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped.ignoreUnmapped(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.setCorners(double top, double left, double bottom, double right)Adds top left point.setCorners(String geohash)Adds points from a single geohash.setCorners(String topLeft, String bottomRight)Adds points.setCorners(GeoPoint topLeft, GeoPoint bottomRight)Adds points.setCornersOGC(String bottomLeft, String topRight)Adds corners in OGC standard bbox/ envelop format.setCornersOGC(GeoPoint bottomLeft, GeoPoint topRight)Adds corners in OGC standard bbox/ envelop format.Specify whether or not to ignore validation errors of bounding boxes.topLeft()Returns the top left corner of the bounding box.type()Returns the execution type of the geo bounding box.For BWC: Parse type from type name.type(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, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
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
Create new bounding box query.- Parameters:
fieldName- name of index field containing geo coordinates to operate on.
-
GeoBoundingBoxQueryBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>- Throws:
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
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
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
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 IOException- Specified by:
doXContentin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>- Throws:
IOException
-
fromXContent
public static GeoBoundingBoxQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
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
Description copied from interface:NamedWriteableReturns the name of the writeable object
-