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, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>
Direct Known Subclasses:
GeoShapeQueryBuilder

public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>> extends AbstractQueryBuilder<QB>
Base QueryBuilder that builds a Geometry Query
  • Field Details

    • DEFAULT_SHAPE_INDEX_NAME

      public static final String DEFAULT_SHAPE_INDEX_NAME
      See Also:
      Constant Field Values
    • DEFAULT_SHAPE_FIELD_NAME

      public static final 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
    • SHAPE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_FIELD
    • RELATION_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField RELATION_FIELD
    • INDEXED_SHAPE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField INDEXED_SHAPE_FIELD
    • SHAPE_ID_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_ID_FIELD
    • SHAPE_TYPE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_TYPE_FIELD
    • SHAPE_INDEX_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_INDEX_FIELD
    • SHAPE_PATH_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_PATH_FIELD
    • SHAPE_ROUTING_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SHAPE_ROUTING_FIELD
    • IGNORE_UNMAPPED_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField IGNORE_UNMAPPED_FIELD
    • fieldName

      protected final String fieldName
    • supplier

      protected final Supplier<org.elasticsearch.geometry.Geometry> supplier
    • indexedShapeId

      protected final String indexedShapeId
    • indexedShapeType

      protected final String indexedShapeType
    • shape

      protected org.elasticsearch.geometry.Geometry shape
    • indexedShapeIndex

      protected String indexedShapeIndex
    • indexedShapePath

      protected String indexedShapePath
    • indexedShapeRouting

      protected String indexedShapeRouting
    • relation

      protected ShapeRelation relation
    • ignoreUnmapped

      protected boolean ignoreUnmapped
  • Constructor Details

    • AbstractGeometryQueryBuilder

      @Deprecated protected AbstractGeometryQueryBuilder(String fieldName, ShapeBuilder shape)
      Creates 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 queried
      shape - Shape used in the Query
    • AbstractGeometryQueryBuilder

      public AbstractGeometryQueryBuilder(String fieldName, org.elasticsearch.geometry.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 queried
      shape - Shape used in the Query
    • AbstractGeometryQueryBuilder

      protected AbstractGeometryQueryBuilder(String fieldName, 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 filtered
      indexedShapeId - ID of the indexed Shape that will be used in the Query
    • AbstractGeometryQueryBuilder

      @Deprecated protected AbstractGeometryQueryBuilder(String fieldName, String indexedShapeId, String indexedShapeType)
      Creates 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 filtered
      indexedShapeId - ID of the indexed Shape that will be used in the Query
      indexedShapeType - Index type of the indexed Shapes
    • AbstractGeometryQueryBuilder

      protected AbstractGeometryQueryBuilder(String fieldName, org.elasticsearch.geometry.Geometry shape, String indexedShapeId, @Nullable String indexedShapeType)
    • AbstractGeometryQueryBuilder

      protected AbstractGeometryQueryBuilder(String fieldName, Supplier<org.elasticsearch.geometry.Geometry> supplier, String indexedShapeId, @Nullable String indexedShapeType)
    • AbstractGeometryQueryBuilder

      protected AbstractGeometryQueryBuilder(StreamInput in) throws IOException
      Read from a stream.
      Throws:
      IOException
  • Method Details

    • doWriteTo

      protected void doWriteTo(StreamOutput out) throws IOException
      Specified by:
      doWriteTo in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
      Throws:
      IOException
    • fieldName

      public String fieldName()
      Returns:
      the name of the field that will be queried
    • shape

      public QB shape(org.elasticsearch.geometry.Geometry geometry)
      Sets the shapeBuilder for the query shape.
      Parameters:
      geometry - the geometry
      Returns:
      this
    • shape

      public org.elasticsearch.geometry.Geometry shape()
      Returns:
      the shape used in the Query
    • indexedShapeId

      public String indexedShapeId()
      Returns:
      the ID of the indexed Shape that will be used in the Query
    • indexedShapeType

      @Deprecated public 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(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 String indexedShapeIndex()
      Returns:
      the index name for the indexed Shape that will be used in the Query
    • indexedShapePath

      public QB indexedShapePath(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 String indexedShapePath()
      Returns:
      the path of the indexed Shape that will be used in the Query
    • indexedShapeRouting

      public QB indexedShapeRouting(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 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 a MatchNoDocsQuery in 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 a MatchNoDocsQuery in place of this query) or throw an exception if the field is unmapped.
    • buildShapeQuery

      protected abstract org.apache.lucene.search.Query buildShapeQuery(SearchExecutionContext context, MappedFieldType fieldType)
      builds the appropriate lucene shape query
    • doShapeQueryXContent

      protected abstract void doShapeQueryXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      writes the xcontent specific to this shape query
      Throws:
      IOException
    • newShapeQueryBuilder

      protected abstract AbstractGeometryQueryBuilder<QB> newShapeQueryBuilder(String fieldName, org.elasticsearch.geometry.Geometry shape)
      creates a new ShapeQueryBuilder from the provided field name and shape builder
    • newShapeQueryBuilder

      protected abstract AbstractGeometryQueryBuilder<QB> 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 type
    • doToQuery

      protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context)
      Specified by:
      doToQuery in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
    • doXContent

      protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      doXContent in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
      Throws:
      IOException
    • doEquals

      protected boolean doEquals(AbstractGeometryQueryBuilder other)
      Description copied from class: AbstractQueryBuilder
      Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
      Specified by:
      doEquals in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
    • doHashCode

      protected int doHashCode()
      Specified by:
      doHashCode in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
    • doRewrite

      protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException
      Overrides:
      doRewrite in class AbstractQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>>
      Throws:
      IOException
    • parsedParamsFromXContent

      public static AbstractGeometryQueryBuilder.ParsedGeometryQueryParams parsedParamsFromXContent(org.elasticsearch.common.xcontent.XContentParser parser, AbstractGeometryQueryBuilder.ParsedGeometryQueryParams params) throws IOException
      Throws:
      IOException