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 classHolds spatial logic for a bounding box that works in the encoded spaceprivate static classutility class for implementing constant score logic specific to INTERSECT, WITHIN, and DISJOINTprotected static classVisitor used for walking the BKD tree. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Stringfield name(package private) final Geometry[](package private) final Component2D(package private) final ShapeField.QueryRelationquery relation disjoint:ShapeField.QueryRelation.DISJOINT, intersects:ShapeField.QueryRelation.INTERSECTS, within:ShapeField.QueryRelation.DISJOINT, contains:ShapeField.QueryRelation.CONTAINS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSpatialQuery(String field, ShapeField.QueryRelation queryRelation, Geometry... geometries) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Component2DcreateComponent2D(Geometry... geometries) final WeightcreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.booleanOverride and implement query instance equivalence properly in a subclass.protected booleanclass specific equals checkprivate static PointValues.IntersectVisitorgetContainsDenseVisitor(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.IntersectVisitorgetDenseVisitor(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 invalid input: '&' DISJOINTprivate static PointValues.IntersectVisitorgetEstimateVisitor(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation) create a visitor for calculating point count estimates for the provided relationgetField()returns the field nameprivate static PointValues.IntersectVisitorgetIntersectsDenseVisitor(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.IntersectVisitorgetInverseDenseVisitor(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 invalid input: '&' DISJOINTreturns the query relationprotected ScorerSuppliergetScorerSupplier(LeafReader reader, SpatialQuery.SpatialVisitor spatialVisitor, ScoreMode scoreMode, ConstantScoreWeight weight, float boost, float score) private static PointValues.IntersectVisitorgetShallowInverseDenseVisitor(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 invalid input: '&' DISJOINT.private static PointValues.IntersectVisitorgetSparseVisitor(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.SpatialVisitorreturns the spatial visitor to be used for this query.private static booleanhasAnyHits(SpatialQuery.SpatialVisitor spatialVisitor, ShapeField.QueryRelation queryRelation, PointValues values) Return true if the query matches at least one document.inthashCode()Override and implement query hash code properly in a subclass.protected booleanPrints a query to a string, withfieldassumed to be the default field and omitted.protected static PointValues.Relationtranspose the relation; INSIDE becomes OUTSIDE, OUTSIDE becomes INSIDE, CROSSES remains unchangedvoidvisit(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:QueryRecurse 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:QueryExpert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeightin classQuery- Parameters:
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:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly. -
equals
Description copied from class:QueryOverride and implement query instance equivalence properly in a subclass. This is required so thatQueryCacheworks 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 invalid input: '<'= 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 invalid input: '&' 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 invalid input: '&' 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 invalid input: '&' 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:QueryPrints a query to a string, withfieldassumed to be the default field and omitted.
-