+ * NOTE: If for a given document and a given field using + * {@link org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy} + * multiple 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 a {@link com.spatial4j.core.shape.ShapeCollection} (or WKT equivalent). Or + * calculate a suitable level/distErr to index both and call + * {@link org.apache.lucene.spatial.prefix.PrefixTreeStrategy#createIndexableFields(com.spatial4j.core.shape.Shape, int)} + * with the same value for all shapes for a given document/field. * * @lucene.experimental */ @@ -114,8 +125,7 @@ //AbstractVisitingPrefixTreeFilter is a Lucene Filter. We don't need a filter; we use it for its great prefix-tree // traversal code. TODO consider refactoring if/when it makes sense (more use cases than this) - new AbstractVisitingPrefixTreeFilter(queryShape, strategy.getFieldName(), tree, facetLevel, scanLevel, - !strategy.isPointsOnly()) { + new AbstractVisitingPrefixTreeFilter(queryShape, strategy.getFieldName(), tree, facetLevel, scanLevel) { @Override public String toString(String field) { @@ -139,7 +149,7 @@ } @Override - protected boolean visit(Cell cell) throws IOException { + protected boolean visitPrefix(Cell cell) throws IOException { // At facetLevel... if (cell.getLevel() == facetLevel) { // Count docs