Class PrefixTreeFacetCounter
- java.lang.Object
-
- org.apache.lucene.spatial.prefix.PrefixTreeFacetCounter
-
public class PrefixTreeFacetCounter extends Object
Computes facets on cells forPrefixTreeStrategy.NOTE: If for a given document and a given field using
RecursivePrefixTreeStrategymultiple values are indexed (i.e. multi-valued) and at least one of them is a non-point, then there is a possibility of double-counting the document in the facet results. Since each shape is independently turned into grid cells at a resolution chosen by the shape's size, it's possible they will be indexed at different resolutions. This means the document could be present in BOTH the postings for a cell in both its prefix and leaf variants. To avoid this, use a single valued field with aShapeCollection(or WKT equivalent). Or calculate a suitable level/distErr to index both and callPrefixTreeStrategy.createIndexableFields(org.locationtech.spatial4j.shape.Shape, int)with the same value for all shapes for a given document/field.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPrefixTreeFacetCounter.FacetVisitorA callback/visitor of facet counts.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcompute(PrefixTreeStrategy strategy, IndexReaderContext context, Bits topAcceptDocs, org.locationtech.spatial4j.shape.Shape queryShape, int facetLevel, PrefixTreeFacetCounter.FacetVisitor facetVisitor)Computes facets using a callback/visitor style design, allowing flexibility for the caller to determine what to do with each underlying count.static voidcompute(PrefixTreeStrategy strategy, LeafReaderContext context, Bits acceptDocs, org.locationtech.spatial4j.shape.Shape queryShape, int facetLevel, PrefixTreeFacetCounter.FacetVisitor facetVisitor)Lower-level per-leaf segment method.
-
-
-
Method Detail
-
compute
public static void compute(PrefixTreeStrategy strategy, IndexReaderContext context, Bits topAcceptDocs, org.locationtech.spatial4j.shape.Shape queryShape, int facetLevel, PrefixTreeFacetCounter.FacetVisitor facetVisitor) throws IOException
Computes facets using a callback/visitor style design, allowing flexibility for the caller to determine what to do with each underlying count.- Parameters:
strategy- the prefix tree strategy (contains the field reference, grid, max levels)context- the IndexReader's contexttopAcceptDocs- a Bits to limit counted docs. If null, live docs are counted.queryShape- the shape to limit the range of facet counts tofacetLevel- the maximum depth (detail) of faceted cellsfacetVisitor- the visitor/callback to receive the counts- Throws:
IOException
-
compute
public static void compute(PrefixTreeStrategy strategy, LeafReaderContext context, Bits acceptDocs, org.locationtech.spatial4j.shape.Shape queryShape, int facetLevel, PrefixTreeFacetCounter.FacetVisitor facetVisitor) throws IOException
Lower-level per-leaf segment method.- Throws:
IOException
-
-