abstract class ShapeQuery extends Query
LatLonShape
and XYShape
.
The field must be indexed using either LatLonShape.createIndexableFields(java.lang.String, org.apache.lucene.geo.Polygon)
or
XYShape.createIndexableFields(java.lang.String, org.apache.lucene.geo.XYPolygon)
and the corresponding factory method must be used:
newBoxQuery()
for matching geo shapes that have some ShapeField.QueryRelation
with a bounding box.
newLineQuery()
for matching geo shapes that have some ShapeField.QueryRelation
with a linestring.
newPolygonQuery()
for matching geo shapes that have some ShapeField.QueryRelation
with a polygon.
newBoxQuery()
for matching cartesian shapes that have some ShapeField.QueryRelation
with a bounding box.
newLineQuery()
for matching cartesian shapes that have some ShapeField.QueryRelation
with a linestring.
newPolygonQuery()
for matching cartesian shapes that have some ShapeField.QueryRelation
with a polygon.
Modifier and Type | Class and Description |
---|---|
private static class |
ShapeQuery.RelationScorerSupplier
utility class for implementing constant score logic specific to INTERSECT, WITHIN, and DISJOINT
|
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String |
field
field name
|
(package private) ShapeField.QueryRelation |
queryRelation
query relation
disjoint:
ShapeField.QueryRelation.DISJOINT ,
intersects: ShapeField.QueryRelation.INTERSECTS ,
within: ShapeField.QueryRelation.DISJOINT ,
contains: ShapeField.QueryRelation.CONTAINS |
Modifier | Constructor and Description |
---|---|
protected |
ShapeQuery(java.lang.String field,
ShapeField.QueryRelation queryType) |
Modifier and Type | Method and Description |
---|---|
Weight |
createWeight(IndexSearcher searcher,
ScoreMode scoreMode,
float boost)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(java.lang.Object o)
Override and implement query instance equivalence properly in a subclass.
|
protected boolean |
equalsTo(java.lang.Object o) |
private static PointValues.IntersectVisitor |
getContainsDenseVisitor(ShapeQuery query,
FixedBitSet result,
FixedBitSet excluded,
long[] cost)
create a visitor that adds documents that match the query using a dense bitset; used with CONTAINS
|
private static PointValues.IntersectVisitor |
getDenseVisitor(ShapeQuery query,
FixedBitSet result,
FixedBitSet excluded,
long[] cost)
create a visitor that adds documents that match the query using a dense bitset; used with WITHIN & DISJOINT
|
private static PointValues.IntersectVisitor |
getEstimateVisitor(ShapeQuery query)
create a visitor for calculating point count estimates for the provided relation
|
java.lang.String |
getField()
returns the field name
|
private static PointValues.IntersectVisitor |
getInverseDenseVisitor(ShapeQuery query,
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
|
ShapeField.QueryRelation |
getQueryRelation()
returns the query relation
|
private static PointValues.IntersectVisitor |
getShallowInverseDenseVisitor(ShapeQuery query,
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(ShapeQuery query,
DocIdSetBuilder result)
create a visitor that adds documents that match the query using a sparse bitset.
|
private static boolean |
hasAnyHits(ShapeQuery query,
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 abstract boolean |
queryMatches(byte[] triangle,
ShapeField.DecodedTriangle scratchTriangle,
ShapeField.QueryRelation queryRelation)
returns true if the provided triangle matches the query
|
protected abstract Component2D.WithinRelation |
queryWithin(byte[] triangle,
ShapeField.DecodedTriangle scratchTriangle)
Return the within relationship between the query and the indexed shape.
|
protected abstract PointValues.Relation |
relateRangeBBoxToQuery(int minXOffset,
int minYOffset,
byte[] minTriangle,
int maxXOffset,
int maxYOffset,
byte[] maxTriangle)
relates an internal node (bounding box of a range of triangles) to the target query
Note: logic is specific to query type
see
relateRangeToQuery(byte[], byte[], org.apache.lucene.document.ShapeField.QueryRelation) and relateRangeToQuery(byte[], byte[], org.apache.lucene.document.ShapeField.QueryRelation) |
protected PointValues.Relation |
relateRangeToQuery(byte[] minTriangle,
byte[] maxTriangle,
ShapeField.QueryRelation queryRelation)
relates a range of triangles (internal node) to the query
|
private static PointValues.Relation |
transposeRelation(PointValues.Relation r)
transpose the relation; INSIDE becomes OUTSIDE, OUTSIDE becomes INSIDE, CROSSES remains unchanged
|
void |
visit(QueryVisitor visitor)
Recurse through the query tree, visiting any child queries
|
final java.lang.String field
final ShapeField.QueryRelation queryRelation
ShapeField.QueryRelation.DISJOINT
,
intersects: ShapeField.QueryRelation.INTERSECTS
,
within: ShapeField.QueryRelation.DISJOINT
,
contains: ShapeField.QueryRelation.CONTAINS
protected ShapeQuery(java.lang.String field, ShapeField.QueryRelation queryType)
protected abstract PointValues.Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
relateRangeToQuery(byte[], byte[], org.apache.lucene.document.ShapeField.QueryRelation)
and relateRangeToQuery(byte[], byte[], org.apache.lucene.document.ShapeField.QueryRelation)
protected abstract boolean queryMatches(byte[] triangle, ShapeField.DecodedTriangle scratchTriangle, ShapeField.QueryRelation queryRelation)
protected abstract Component2D.WithinRelation queryWithin(byte[] triangle, ShapeField.DecodedTriangle scratchTriangle)
protected PointValues.Relation relateRangeToQuery(byte[] minTriangle, byte[] maxTriangle, ShapeField.QueryRelation queryRelation)
public void visit(QueryVisitor visitor)
Query
public final Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
scoreMode
- How the produced scorers will be consumed.boost
- The boost that is propagated by the parent queries.public java.lang.String getField()
public ShapeField.QueryRelation getQueryRelation()
public int hashCode()
Query
QueryCache
works properly.hashCode
in class Query
Query.equals(Object)
public boolean equals(java.lang.Object o)
Query
QueryCache
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 that other
instance. Utility methods are provided for certain repetitive code.equals
in class Query
Query.sameClassAs(Object)
,
Query.classHash()
protected boolean equalsTo(java.lang.Object o)
private static PointValues.Relation transposeRelation(PointValues.Relation r)
private static PointValues.IntersectVisitor getEstimateVisitor(ShapeQuery query)
private static PointValues.IntersectVisitor getSparseVisitor(ShapeQuery query, DocIdSetBuilder result)
private static PointValues.IntersectVisitor getDenseVisitor(ShapeQuery query, FixedBitSet result, FixedBitSet excluded, long[] cost)
private static PointValues.IntersectVisitor getContainsDenseVisitor(ShapeQuery query, FixedBitSet result, FixedBitSet excluded, long[] cost)
private static PointValues.IntersectVisitor getInverseDenseVisitor(ShapeQuery query, FixedBitSet result, long[] cost)
private static PointValues.IntersectVisitor getShallowInverseDenseVisitor(ShapeQuery query, FixedBitSet result)
private static boolean hasAnyHits(ShapeQuery query, PointValues values) throws java.io.IOException
java.io.IOException