Module org.elasticsearch.server
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,VersionedNamedWriteable,Writeable,QueryBuilder,Rewriteable<QueryBuilder>,ToXContent,ToXContentObject
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.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default value for ignore_unmapped.static final 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.xcontent.ToXContent
EMPTY, 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(XContentBuilder builder, ToXContent.Params params) Returns the name of the field to base the bounding box computation on.static GeoBoundingBoxQueryBuilderfromXContent(XContentParser parser) The minimal version of the recipient this object can be sent to.Returns the name of the writeable objectignoreUnmapped(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.Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, boostAndQueryNameToXContent, checkNegativeBoost, declareStandardFields, doCoordinatorRewrite, doIndexMetadataRewrite, doInnerHitsRewrite, doRewrite, doSearchRewrite, equals, extractInnerHitBuilders, getMaxNestedDepth, getName, hashCode, parseInnerQueryBuilder, parseTopLevelQuery, parseTopLevelQuery, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, setMaxNestedDepth, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeQueries, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragmentMethods inherited from interface org.elasticsearch.common.io.stream.VersionedNamedWriteable
supportsVersion
-
Field Details
-
NAME
- See Also:
-
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPEDThe default value for ignore_unmapped.- See Also:
-
-
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. -
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. -
doToQuery
- Specified by:
doToQueryin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>
-
doXContent
- Specified by:
doXContentin classAbstractQueryBuilder<GeoBoundingBoxQueryBuilder>- Throws:
IOException
-
fromXContent
- 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:VersionedNamedWriteableReturns the name of the writeable object -
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to. SeeVersionedNamedWriteable.supportsVersion(TransportVersion)for the default serialization check.
-