Package org.elasticsearch.index.query
Class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
- java.lang.Object
-
- org.elasticsearch.index.query.AbstractQueryBuilder<QB>
-
- org.elasticsearch.index.query.AbstractGeometryQueryBuilder<QB>
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,QueryBuilder,Rewriteable<QueryBuilder>
- Direct Known Subclasses:
GeoShapeQueryBuilder
public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>> extends AbstractQueryBuilder<QB>
BaseQueryBuilderthat builds a Geometry Query
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractGeometryQueryBuilder.ParsedGeometryQueryParamslocal class that encapsulates xcontent parsed shape parameters-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested 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 java.lang.StringDEFAULT_SHAPE_FIELD_NAMEstatic java.lang.StringDEFAULT_SHAPE_INDEX_NAMEstatic ShapeRelationDEFAULT_SHAPE_RELATIONprotected java.lang.StringfieldNameprotected static ParseFieldIGNORE_UNMAPPED_FIELDprotected booleanignoreUnmappedprotected static ParseFieldINDEXED_SHAPE_FIELDprotected java.lang.StringindexedShapeIdprotected java.lang.StringindexedShapeIndexprotected java.lang.StringindexedShapePathprotected java.lang.StringindexedShapeRoutingprotected java.lang.StringindexedShapeTypeprotected ShapeRelationrelationprotected static ParseFieldRELATION_FIELDprotected Geometryshapeprotected static ParseFieldSHAPE_FIELDprotected static ParseFieldSHAPE_ID_FIELDprotected static ParseFieldSHAPE_INDEX_FIELDprotected static ParseFieldSHAPE_PATH_FIELDprotected static ParseFieldSHAPE_ROUTING_FIELDprotected static ParseFieldSHAPE_TYPE_FIELDprotected java.util.function.Supplier<Geometry>supplierprotected java.util.List<java.lang.String>validContentTypesregistry of content types this query can be used with-
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
Constructors Modifier Constructor Description protectedAbstractGeometryQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId)Creates a new ShapeQueryBuilder whose Query will be against the given field name and will use the Shape found with the given IDprotectedAbstractGeometryQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId, java.lang.String indexedShapeType)Deprecated.useAbstractGeometryQueryBuilder(String, String)insteadprotectedAbstractGeometryQueryBuilder(java.lang.String fieldName, java.util.function.Supplier<Geometry> supplier, java.lang.String indexedShapeId, java.lang.String indexedShapeType)protectedAbstractGeometryQueryBuilder(java.lang.String fieldName, ShapeBuilder shape)Deprecated.useAbstractGeometryQueryBuilder(String, Geometry)insteadAbstractGeometryQueryBuilder(java.lang.String fieldName, Geometry shape)Creates a new AbstractGeometryQueryBuilder whose Query will be against the given field name using the given ShapeprotectedAbstractGeometryQueryBuilder(java.lang.String fieldName, Geometry shape, java.lang.String indexedShapeId, java.lang.String indexedShapeType)protectedAbstractGeometryQueryBuilder(StreamInput in)Read from a stream.
-
Method Summary
Modifier and Type Method Description protected abstract org.apache.lucene.search.QuerybuildShapeQuery(QueryShardContext context, MappedFieldType fieldType)builds the appropriate lucene shape queryprotected booleandoEquals(AbstractGeometryQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected abstract voiddoShapeQueryXContent(XContentBuilder builder, ToXContent.Params params)writes the xcontent specific to this shape queryprotected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(XContentBuilder builder, ToXContent.Params params)java.lang.StringfieldName()booleanignoreUnmapped()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.AbstractGeometryQueryBuilder<QB>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.java.lang.StringindexedShapeId()java.lang.StringindexedShapeIndex()QBindexedShapeIndex(java.lang.String indexedShapeIndex)Sets the name of the index where the indexed Shape can be foundjava.lang.StringindexedShapePath()QBindexedShapePath(java.lang.String indexedShapePath)Sets the path of the field in the indexed Shape document that has the Shape itselfjava.lang.StringindexedShapeRouting()QBindexedShapeRouting(java.lang.String indexedShapeRouting)Sets the optional routing to the indexed Shape that will be used in the queryjava.lang.StringindexedShapeType()Deprecated.Types are in the process of being removed.protected booleanisValidContentType(java.lang.String typeName)returns true if the provided field type is valid for this queryprotected abstract AbstractGeometryQueryBuilder<QB>newShapeQueryBuilder(java.lang.String fieldName, java.util.function.Supplier<Geometry> shapeSupplier, java.lang.String indexedShapeId, java.lang.String indexedShapeType)creates a new ShapeQueryBuilder from the provided field name, supplier, indexed shape id, and indexed shape typeprotected abstract AbstractGeometryQueryBuilder<QB>newShapeQueryBuilder(java.lang.String fieldName, Geometry shape)creates a new ShapeQueryBuilder from the provided field name and shape builderstatic AbstractGeometryQueryBuilder.ParsedGeometryQueryParamsparsedParamsFromXContent(XContentParser parser, AbstractGeometryQueryBuilder.ParsedGeometryQueryParams params)protected abstract java.lang.StringqueryFieldType()returns expected content type for this queryShapeRelationrelation()QBrelation(ShapeRelation relation)Sets the relation of query shape and indexed shape.Geometryshape()QBshape(Geometry geometry)Sets the shapeBuilder for the query shape.protected abstract java.util.ListvalidContentTypes()list of content types this shape query is compatible with-
Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, 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.io.stream.NamedWriteable
getWriteableName
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
DEFAULT_SHAPE_INDEX_NAME
public static final java.lang.String DEFAULT_SHAPE_INDEX_NAME
- See Also:
- Constant Field Values
-
DEFAULT_SHAPE_FIELD_NAME
public static final java.lang.String DEFAULT_SHAPE_FIELD_NAME
- See Also:
- Constant Field Values
-
DEFAULT_SHAPE_RELATION
public static final ShapeRelation DEFAULT_SHAPE_RELATION
-
validContentTypes
protected final java.util.List<java.lang.String> validContentTypes
registry of content types this query can be used with
-
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPED
The default value for ignore_unmapped.- See Also:
- Constant Field Values
-
SHAPE_FIELD
protected static final ParseField SHAPE_FIELD
-
RELATION_FIELD
protected static final ParseField RELATION_FIELD
-
INDEXED_SHAPE_FIELD
protected static final ParseField INDEXED_SHAPE_FIELD
-
SHAPE_ID_FIELD
protected static final ParseField SHAPE_ID_FIELD
-
SHAPE_TYPE_FIELD
protected static final ParseField SHAPE_TYPE_FIELD
-
SHAPE_INDEX_FIELD
protected static final ParseField SHAPE_INDEX_FIELD
-
SHAPE_PATH_FIELD
protected static final ParseField SHAPE_PATH_FIELD
-
SHAPE_ROUTING_FIELD
protected static final ParseField SHAPE_ROUTING_FIELD
-
IGNORE_UNMAPPED_FIELD
protected static final ParseField IGNORE_UNMAPPED_FIELD
-
fieldName
protected final java.lang.String fieldName
-
supplier
protected final java.util.function.Supplier<Geometry> supplier
-
indexedShapeId
protected final java.lang.String indexedShapeId
-
indexedShapeType
protected final java.lang.String indexedShapeType
-
shape
protected Geometry shape
-
indexedShapeIndex
protected java.lang.String indexedShapeIndex
-
indexedShapePath
protected java.lang.String indexedShapePath
-
indexedShapeRouting
protected java.lang.String indexedShapeRouting
-
relation
protected ShapeRelation relation
-
ignoreUnmapped
protected boolean ignoreUnmapped
-
-
Constructor Detail
-
AbstractGeometryQueryBuilder
@Deprecated protected AbstractGeometryQueryBuilder(java.lang.String fieldName, ShapeBuilder shape)Deprecated.useAbstractGeometryQueryBuilder(String, Geometry)insteadCreates a new ShapeQueryBuilder 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
-
AbstractGeometryQueryBuilder
public AbstractGeometryQueryBuilder(java.lang.String fieldName, Geometry shape)Creates a new AbstractGeometryQueryBuilder 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
-
AbstractGeometryQueryBuilder
protected AbstractGeometryQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId)Creates a new ShapeQueryBuilder 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
-
AbstractGeometryQueryBuilder
@Deprecated protected AbstractGeometryQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId, java.lang.String indexedShapeType)Deprecated.useAbstractGeometryQueryBuilder(String, String)insteadCreates a new AbstractGeometryQueryBuilder 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
-
AbstractGeometryQueryBuilder
protected AbstractGeometryQueryBuilder(java.lang.String fieldName, Geometry shape, java.lang.String indexedShapeId, @Nullable java.lang.String indexedShapeType)
-
AbstractGeometryQueryBuilder
protected AbstractGeometryQueryBuilder(java.lang.String fieldName, java.util.function.Supplier<Geometry> supplier, java.lang.String indexedShapeId, @Nullable java.lang.String indexedShapeType)
-
AbstractGeometryQueryBuilder
protected AbstractGeometryQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- Specified by:
doWriteToin classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()
- Returns:
- the name of the field that will be queried
-
shape
public QB shape(Geometry geometry)
Sets the shapeBuilder for the query shape.- Parameters:
geometry- the geometry- Returns:
- this
-
shape
public Geometry shape()
- Returns:
- the shape used in the Query
-
indexedShapeId
public java.lang.String indexedShapeId()
- Returns:
- the ID of the indexed Shape that will be used in the Query
-
indexedShapeType
@Deprecated public java.lang.String indexedShapeType()
Deprecated.Types are in the process of being removed.- Returns:
- the document type of the indexed Shape that will be used in the Query
-
indexedShapeIndex
public QB indexedShapeIndex(java.lang.String indexedShapeIndex)
Sets the name of the index where the indexed Shape can be found- Parameters:
indexedShapeIndex- Name of the index where the indexed Shape is- Returns:
- this
-
indexedShapeIndex
public java.lang.String indexedShapeIndex()
- Returns:
- the index name for the indexed Shape that will be used in the Query
-
indexedShapePath
public QB indexedShapePath(java.lang.String indexedShapePath)
Sets the path of the field in the indexed Shape document that has the Shape itself- Parameters:
indexedShapePath- Path of the field where the Shape itself is defined- Returns:
- this
-
indexedShapePath
public java.lang.String indexedShapePath()
- Returns:
- the path of the indexed Shape that will be used in the Query
-
indexedShapeRouting
public QB indexedShapeRouting(java.lang.String indexedShapeRouting)
Sets the optional routing to the indexed Shape that will be used in the query- Parameters:
indexedShapeRouting- indexed shape routing- Returns:
- this
-
indexedShapeRouting
public java.lang.String indexedShapeRouting()
- Returns:
- the optional routing to the indexed Shape that will be used in the Query
-
relation
public QB relation(ShapeRelation relation)
Sets the relation of query shape and indexed shape.- Parameters:
relation- relation of the shapes- Returns:
- this
-
relation
public ShapeRelation relation()
- Returns:
- the relation of query shape and indexed shape to use in the Query
-
ignoreUnmapped
public AbstractGeometryQueryBuilder<QB> 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.
-
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.
-
validContentTypes
protected abstract java.util.List validContentTypes()
list of content types this shape query is compatible with
-
buildShapeQuery
protected abstract org.apache.lucene.search.Query buildShapeQuery(QueryShardContext context, MappedFieldType fieldType)
builds the appropriate lucene shape query
-
queryFieldType
protected abstract java.lang.String queryFieldType()
returns expected content type for this query
-
doShapeQueryXContent
protected abstract void doShapeQueryXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
writes the xcontent specific to this shape query- Throws:
java.io.IOException
-
newShapeQueryBuilder
protected abstract AbstractGeometryQueryBuilder<QB> newShapeQueryBuilder(java.lang.String fieldName, Geometry shape)
creates a new ShapeQueryBuilder from the provided field name and shape builder
-
newShapeQueryBuilder
protected abstract AbstractGeometryQueryBuilder<QB> newShapeQueryBuilder(java.lang.String fieldName, java.util.function.Supplier<Geometry> shapeSupplier, java.lang.String indexedShapeId, java.lang.String indexedShapeType)
creates a new ShapeQueryBuilder from the provided field name, supplier, indexed shape id, and indexed shape type
-
isValidContentType
protected boolean isValidContentType(java.lang.String typeName)
returns true if the provided field type is valid for this query
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context)
- Specified by:
doToQueryin classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContentin classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>- Throws:
java.io.IOException
-
doEquals
protected boolean doEquals(AbstractGeometryQueryBuilder other)
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCodein classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException
- Overrides:
doRewritein classAbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>- Throws:
java.io.IOException
-
parsedParamsFromXContent
public static AbstractGeometryQueryBuilder.ParsedGeometryQueryParams parsedParamsFromXContent(XContentParser parser, AbstractGeometryQueryBuilder.ParsedGeometryQueryParams params) throws java.io.IOException
- Throws:
java.io.IOException
-
-