Package org.elasticsearch.index.query
Class GeoShapeQueryBuilder
- java.lang.Object
-
- org.elasticsearch.index.query.AbstractQueryBuilder<GeoShapeQueryBuilder>
-
- org.elasticsearch.index.query.GeoShapeQueryBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,QueryBuilder,Rewriteable<QueryBuilder>
public class GeoShapeQueryBuilder extends AbstractQueryBuilder<GeoShapeQueryBuilder>
QueryBuilderthat builds a GeoShape Query
-
-
Nested Class Summary
-
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_RELATIONstatic java.lang.StringNAME-
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 Constructor Description GeoShapeQueryBuilder(java.lang.String fieldName, java.lang.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(java.lang.String fieldName, java.lang.String indexedShapeId, java.lang.String indexedShapeType)Deprecated.useGeoShapeQueryBuilder(String, String)insteadGeoShapeQueryBuilder(java.lang.String fieldName, ShapeBuilder shape)Creates a new GeoShapeQueryBuilder whose Query will be against the given field name using the given ShapeGeoShapeQueryBuilder(StreamInput in)Read from a stream.
-
Method Summary
Modifier and Type Method Description protected booleandoEquals(GeoShapeQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(XContentBuilder builder, ToXContent.Params params)java.lang.StringfieldName()static GeoShapeQueryBuilderfromXContent(XContentParser parser)static org.apache.lucene.spatial.query.SpatialArgsgetArgs(ShapeBuilder shape, ShapeRelation relation)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.GeoShapeQueryBuilderignoreUnmapped(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()GeoShapeQueryBuilderindexedShapeIndex(java.lang.String indexedShapeIndex)Sets the name of the index where the indexed Shape can be foundjava.lang.StringindexedShapePath()GeoShapeQueryBuilderindexedShapePath(java.lang.String indexedShapePath)Sets the path of the field in the indexed Shape document that has the Shape itselfjava.lang.StringindexedShapeRouting()GeoShapeQueryBuilderindexedShapeRouting(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.ShapeRelationrelation()GeoShapeQueryBuilderrelation(ShapeRelation relation)Sets the relation of query shape and indexed shape.ShapeBuildershape()SpatialStrategystrategy()GeoShapeQueryBuilderstrategy(SpatialStrategy strategy)Defines which spatial strategy will be used for building the geo shape Query.-
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.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
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
-
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPED
The default value for ignore_unmapped.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeoShapeQueryBuilder
public GeoShapeQueryBuilder(java.lang.String fieldName, ShapeBuilder shape)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
public GeoShapeQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId)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
@Deprecated public GeoShapeQueryBuilder(java.lang.String fieldName, java.lang.String indexedShapeId, java.lang.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
public GeoShapeQueryBuilder(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<GeoShapeQueryBuilder>- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()
- Returns:
- the name of the field that will be queried
-
shape
public ShapeBuilder 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
-
strategy
public GeoShapeQueryBuilder strategy(SpatialStrategy 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
public SpatialStrategy strategy()
- Returns:
- The spatial strategy to use for building the geo shape Query
-
indexedShapeIndex
public GeoShapeQueryBuilder 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 GeoShapeQueryBuilder 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 GeoShapeQueryBuilder 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 GeoShapeQueryBuilder 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 GeoShapeQueryBuilder 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.
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context)
- Specified by:
doToQueryin classAbstractQueryBuilder<GeoShapeQueryBuilder>
-
getArgs
public static org.apache.lucene.spatial.query.SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation)
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContentin classAbstractQueryBuilder<GeoShapeQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static GeoShapeQueryBuilder fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
doEquals
protected boolean doEquals(GeoShapeQueryBuilder other)
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<GeoShapeQueryBuilder>
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCodein classAbstractQueryBuilder<GeoShapeQueryBuilder>
-
getWriteableName
public java.lang.String getWriteableName()
Description copied from interface:NamedWriteableReturns the name of the writeable object
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException
- Overrides:
doRewritein classAbstractQueryBuilder<GeoShapeQueryBuilder>- Throws:
java.io.IOException
-
-