java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.document.SpatialQuery
- Direct Known Subclasses:
BaseShapeDocValuesQuery
,LatLonPointQuery
,LatLonShapeBoundingBoxQuery
,LatLonShapeQuery
,XYShapeQuery
Base query class for all spatial geometries:
LatLonShape
, LatLonPoint
and XYShape
. In order to create a query, use the factory methods on those classes.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Holds spatial logic for a bounding box that works in the encoded spaceprivate static class
utility class for implementing constant score logic specific to INTERSECT, WITHIN, and DISJOINTprotected static class
Visitor used for walking the BKD tree. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final String
field name(package private) final Geometry[]
(package private) final Component2D
(package private) final ShapeField.QueryRelation
query relation disjoint:ShapeField.QueryRelation.DISJOINT
, intersects:ShapeField.QueryRelation.INTERSECTS
, within:ShapeField.QueryRelation.DISJOINT
, contains:ShapeField.QueryRelation.CONTAINS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SpatialQuery
(String field, ShapeField.QueryRelation queryRelation, Geometry... geometries) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Component2D
createComponent2D
(Geometry... geometries) final Weight
createWeight
(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.boolean
Override and implement query instance equivalence properly in a subclass.protected boolean
class specific equals checkprivate static PointValues.IntersectVisitor
getContainsDenseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, FixedBitSet excluded, long[] cost) create a visitor that adds documents that match the query using a dense bitset; used with CONTAINSprivate static PointValues.IntersectVisitor
getDenseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, FixedBitSet excluded, long[] cost) create a visitor that adds documents that match the query using a dense bitset; used with WITHIN & DISJOINTprivate static PointValues.IntersectVisitor
getEstimateVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation) create a visitor for calculating point count estimates for the provided relationgetField()
returns the field nameprivate static PointValues.IntersectVisitor
getIntersectsDenseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, long[] cost) Scorer used for INTERSECTS when the number of points > 4 * number of docsprivate static PointValues.IntersectVisitor
getInverseDenseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, long[] cost) create a visitor that clears documents that do not match the polygon query using a dense bitset; used with WITHIN & DISJOINTreturns the query relationprotected ScorerSupplier
getScorerSupplier
(LeafReader reader, SpatialQuery.SpatialVisitor spatialVisitor, ScoreMode scoreMode, ConstantScoreWeight weight, float boost, float score) private static PointValues.IntersectVisitor
getShallowInverseDenseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result) create a visitor that clears documents that do not match the polygon query using a dense bitset; used with WITHIN & DISJOINT.private static PointValues.IntersectVisitor
getSparseVisitor
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, DocIdSetBuilder result) create a visitor that adds documents that match the query using a sparse bitset.protected abstract SpatialQuery.SpatialVisitor
returns the spatial visitor to be used for this query.private static boolean
hasAnyHits
(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, PointValues values) Return true if the query matches at least one document.int
hashCode()
Override and implement query hash code properly in a subclass.protected boolean
Prints a query to a string, withfield
assumed to be the default field and omitted.protected static PointValues.Relation
transpose the relation; INSIDE becomes OUTSIDE, OUTSIDE becomes INSIDE, CROSSES remains unchangedvoid
visit
(QueryVisitor visitor) Recurse through the query tree, visiting any child queries.
-
Field Details
-
field
field name -
queryRelation
query relation disjoint:ShapeField.QueryRelation.DISJOINT
, intersects:ShapeField.QueryRelation.INTERSECTS
, within:ShapeField.QueryRelation.DISJOINT
, contains:ShapeField.QueryRelation.CONTAINS
-
geometries
-
queryComponent2D
-
-
Constructor Details
-
SpatialQuery
protected SpatialQuery(String field, ShapeField.QueryRelation queryRelation, Geometry... geometries)
-
-
Method Details
-
createComponent2D
-
getSpatialVisitor
returns the spatial visitor to be used for this query. Called before generating the queryWeight
-
visit
Description copied from class:Query
Recurse through the query tree, visiting any child queries. -
queryIsCacheable
-
getScorerSupplier
protected ScorerSupplier getScorerSupplier(LeafReader reader, SpatialQuery.SpatialVisitor spatialVisitor, ScoreMode scoreMode, ConstantScoreWeight weight, float boost, float score) throws IOException - Throws:
IOException
-
createWeight
Description copied from class:Query
Expert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeight
in classQuery
scoreMode
- How the produced scorers will be consumed.boost
- The boost that is propagated by the parent queries.
-
getField
returns the field name -
getQueryRelation
returns the query relation -
hashCode
public int hashCode()Description copied from class:Query
Override and implement query hash code properly in a subclass. This is required so thatQueryCache
works properly. -
equals
Description copied from class:Query
Override and implement query instance equivalence properly in a subclass. This is required so thatQueryCache
works properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical to those of the other instance. Utility methods are provided for certain repetitive code.
-
equalsTo
class specific equals check -
transposeRelation
transpose the relation; INSIDE becomes OUTSIDE, OUTSIDE becomes INSIDE, CROSSES remains unchanged -
getEstimateVisitor
private static PointValues.IntersectVisitor getEstimateVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation) create a visitor for calculating point count estimates for the provided relation -
getSparseVisitor
private static PointValues.IntersectVisitor getSparseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, DocIdSetBuilder result) create a visitor that adds documents that match the query using a sparse bitset. (Used by INTERSECT when the number of docs <= 4 * number of points ) -
getIntersectsDenseVisitor
private static PointValues.IntersectVisitor getIntersectsDenseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, long[] cost) Scorer used for INTERSECTS when the number of points > 4 * number of docs -
getDenseVisitor
private static PointValues.IntersectVisitor getDenseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, FixedBitSet excluded, long[] cost) create a visitor that adds documents that match the query using a dense bitset; used with WITHIN & DISJOINT -
getContainsDenseVisitor
private static PointValues.IntersectVisitor getContainsDenseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, FixedBitSet excluded, long[] cost) create a visitor that adds documents that match the query using a dense bitset; used with CONTAINS -
getInverseDenseVisitor
private static PointValues.IntersectVisitor getInverseDenseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result, long[] cost) create a visitor that clears documents that do not match the polygon query using a dense bitset; used with WITHIN & DISJOINT -
getShallowInverseDenseVisitor
private static PointValues.IntersectVisitor getShallowInverseDenseVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, FixedBitSet result) create a visitor that clears documents that do not match the polygon query using a dense bitset; used with WITHIN & DISJOINT. This visitor only takes into account inner nodes -
hasAnyHits
private static boolean hasAnyHits(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, PointValues values) throws IOException Return true if the query matches at least one document. It creates a visitor that terminates as soon as one or more docs are matched.- Throws:
IOException
-
toString
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted.
-