Package org.elasticsearch.index.query
Class GeoShapeQueryBuilder
java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<QB>
org.elasticsearch.index.query.AbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
org.elasticsearch.index.query.GeoShapeQueryBuilder
- All Implemented Interfaces:
NamedWriteable
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,QueryBuilder
,Rewriteable<QueryBuilder>
Derived
AbstractGeometryQueryBuilder
that builds a lat, lon GeoShape Query. It
can be applied to any MappedFieldType
that implements GeoShapeQueryable
.
GeoJson and WKT shape definitions are supported-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.index.query.AbstractGeometryQueryBuilder
AbstractGeometryQueryBuilder.ParsedGeometryQueryParams
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.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
protected static org.elasticsearch.common.xcontent.ParseField
Fields inherited from class org.elasticsearch.index.query.AbstractGeometryQueryBuilder
DEFAULT_IGNORE_UNMAPPED, DEFAULT_SHAPE_FIELD_NAME, DEFAULT_SHAPE_INDEX_NAME, DEFAULT_SHAPE_RELATION, fieldName, IGNORE_UNMAPPED_FIELD, ignoreUnmapped, INDEXED_SHAPE_FIELD, indexedShapeId, indexedShapeIndex, indexedShapePath, indexedShapeRouting, indexedShapeType, relation, RELATION_FIELD, shape, SHAPE_FIELD, SHAPE_ID_FIELD, SHAPE_INDEX_FIELD, SHAPE_PATH_FIELD, SHAPE_ROUTING_FIELD, SHAPE_TYPE_FIELD, supplier
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionGeoShapeQueryBuilder(String fieldName, String indexedShapeId)
Creates a new GeoShapeQueryBuilder whose Query will be against the given field name and will use the Shape found with the given IDGeoShapeQueryBuilder(String fieldName, String indexedShapeId, String indexedShapeType)
Deprecated.GeoShapeQueryBuilder(String fieldName, Supplier<org.elasticsearch.geometry.Geometry> shapeSupplier, String indexedShapeId, String indexedShapeType)
GeoShapeQueryBuilder(String fieldName, ShapeBuilder shape)
Deprecated.useGeoShapeQueryBuilder(String, Geometry)
insteadGeoShapeQueryBuilder(String fieldName, org.elasticsearch.geometry.Geometry shape)
Creates a new GeoShapeQueryBuilder whose Query will be against the given field name using the given Shape -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.Query
buildShapeQuery(SearchExecutionContext context, MappedFieldType fieldType)
builds the appropriate lucene shape queryprotected boolean
doEquals(GeoShapeQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
protected GeoShapeQueryBuilder
doRewrite(QueryRewriteContext queryRewriteContext)
void
doShapeQueryXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
writes the xcontent specific to this shape queryprotected void
doWriteTo(StreamOutput out)
static GeoShapeQueryBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Returns the name of the writeable objectprotected GeoShapeQueryBuilder
newShapeQueryBuilder(String fieldName, Supplier<org.elasticsearch.geometry.Geometry> shapeSupplier, String indexedShapeId, String indexedShapeType)
creates a new ShapeQueryBuilder from the provided field name, supplier, indexed shape id, and indexed shape typeprotected GeoShapeQueryBuilder
newShapeQueryBuilder(String fieldName, org.elasticsearch.geometry.Geometry shape)
creates a new ShapeQueryBuilder from the provided field name and shape builderrelation(ShapeRelation relation)
Sets the relation of query shape and indexed shape.strategy()
strategy(SpatialStrategy strategy)
Defines which spatial strategy will be used for building the geo shape Query.Methods inherited from class org.elasticsearch.index.query.AbstractGeometryQueryBuilder
doEquals, doToQuery, doXContent, fieldName, ignoreUnmapped, ignoreUnmapped, indexedShapeId, indexedShapeIndex, indexedShapeIndex, indexedShapePath, indexedShapePath, indexedShapeRouting, indexedShapeRouting, indexedShapeType, parsedParamsFromXContent, relation, shape, shape
Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
- Constant Field Values
-
STRATEGY_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField STRATEGY_FIELD
-
-
Constructor Details
-
GeoShapeQueryBuilder
Creates a new GeoShapeQueryBuilder whose Query will be against the given field name using the given Shape- Parameters:
fieldName
- Name of the field that will be queriedshape
- Shape used in the Query
-
GeoShapeQueryBuilder
Deprecated.useGeoShapeQueryBuilder(String, Geometry)
insteadCreates a new GeoShapeQueryBuilder whose Query will be against the given field name using the given Shape- Parameters:
fieldName
- Name of the field that will be queriedshape
- Shape used in the Query
-
GeoShapeQueryBuilder
-
GeoShapeQueryBuilder
@Deprecated public GeoShapeQueryBuilder(String fieldName, String indexedShapeId, String indexedShapeType)Deprecated.useGeoShapeQueryBuilder(String, String)
insteadCreates a new GeoShapeQueryBuilder whose Query will be against the given field name and will use the Shape found with the given ID in the given type- Parameters:
fieldName
- Name of the field that will be filteredindexedShapeId
- ID of the indexed Shape that will be used in the QueryindexedShapeType
- Index type of the indexed Shapes
-
GeoShapeQueryBuilder
Creates a new GeoShapeQueryBuilder whose Query will be against the given field name and will use the Shape found with the given ID- Parameters:
fieldName
- Name of the field that will be filteredindexedShapeId
- ID of the indexed Shape that will be used in the Query
-
GeoShapeQueryBuilder
- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Overrides:
doWriteTo
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
- Throws:
IOException
-
getWriteableName
Description copied from interface:NamedWriteable
Returns the name of the writeable object -
relation
Sets the relation of query shape and indexed shape.- Overrides:
relation
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
- Parameters:
relation
- relation of the shapes- Returns:
- this
-
strategy
Defines which spatial strategy will be used for building the geo shape Query. When not set, the strategy that will be used will be the one that is associated with the geo shape field in the mappings.- Parameters:
strategy
- The spatial strategy to use for building the geo shape Query- Returns:
- this
-
strategy
- Returns:
- The spatial strategy to use for building the geo shape Query
-
doShapeQueryXContent
public void doShapeQueryXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOExceptionDescription copied from class:AbstractGeometryQueryBuilder
writes the xcontent specific to this shape query- Specified by:
doShapeQueryXContent
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
- Throws:
IOException
-
newShapeQueryBuilder
protected GeoShapeQueryBuilder newShapeQueryBuilder(String fieldName, org.elasticsearch.geometry.Geometry shape)Description copied from class:AbstractGeometryQueryBuilder
creates a new ShapeQueryBuilder from the provided field name and shape builder- Specified by:
newShapeQueryBuilder
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
-
newShapeQueryBuilder
protected GeoShapeQueryBuilder newShapeQueryBuilder(String fieldName, Supplier<org.elasticsearch.geometry.Geometry> shapeSupplier, String indexedShapeId, String indexedShapeType)Description copied from class:AbstractGeometryQueryBuilder
creates a new ShapeQueryBuilder from the provided field name, supplier, indexed shape id, and indexed shape type- Specified by:
newShapeQueryBuilder
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
-
buildShapeQuery
public org.apache.lucene.search.Query buildShapeQuery(SearchExecutionContext context, MappedFieldType fieldType)Description copied from class:AbstractGeometryQueryBuilder
builds the appropriate lucene shape query- Specified by:
buildShapeQuery
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<GeoShapeQueryBuilder>
-
doHashCode
protected int doHashCode()- Overrides:
doHashCode
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
-
doRewrite
protected GeoShapeQueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException- Overrides:
doRewrite
in classAbstractGeometryQueryBuilder<GeoShapeQueryBuilder>
- Throws:
IOException
-
fromXContent
public static GeoShapeQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
GeoShapeQueryBuilder(String, String)
instead