mirror of https://github.com/apache/lucene.git
LUCENE-7845: spatial-extras undo optimize; don't consider any rect or circle to be a point
This commit is contained in:
parent
78d95014e7
commit
6b022c98f9
|
@ -32,9 +32,7 @@ import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
|||
import org.apache.lucene.spatial.query.SpatialArgs;
|
||||
import org.apache.lucene.spatial.util.ShapeFieldCacheDistanceValueSource;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.locationtech.spatial4j.shape.Circle;
|
||||
import org.locationtech.spatial4j.shape.Point;
|
||||
import org.locationtech.spatial4j.shape.Rectangle;
|
||||
import org.locationtech.spatial4j.shape.Shape;
|
||||
|
||||
/**
|
||||
|
@ -208,15 +206,12 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
|
|||
return HeatmapFacetCounter.calcFacets(this, context, topAcceptDocs, inputShape, facetLevel, maxCells);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the {@code shape} is a {@link Point}. For custom spatial contexts, it may make sense to
|
||||
* have certain other shapes return true.
|
||||
* @lucene.experimental
|
||||
*/
|
||||
protected boolean isPointShape(Shape shape) {
|
||||
if (shape instanceof Point) {
|
||||
return true;
|
||||
} else if (shape instanceof Circle) {
|
||||
return ((Circle) shape).getRadius() == 0.0;
|
||||
} else if (shape instanceof Rectangle) {
|
||||
Rectangle rect = (Rectangle) shape;
|
||||
return rect.getWidth() == 0.0 && rect.getHeight() == 0.0;
|
||||
}
|
||||
return false;
|
||||
return shape instanceof Point;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,6 +216,7 @@ public class RecursivePrefixTreeStrategy extends PrefixTreeStrategy {
|
|||
cell = cellIterator.next();
|
||||
assert prevLevel < cell.getLevel();
|
||||
}
|
||||
assert cell.isLeaf();
|
||||
return new TermQuery(new Term(getFieldName(), cell.getTokenBytesWithLeaf(null)));
|
||||
} else {
|
||||
// Well there could be parent cells. But we can reduce the "scan level" which will be slower for a point query.
|
||||
|
|
|
@ -164,6 +164,19 @@ public class RandomSpatialOpFuzzyPrefixTreeTest extends StrategyTestCase {
|
|||
assertEquals(1, executeQuery(query, 1).numFound);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPointsOnlyOptBug() throws IOException {
|
||||
setupQuadGrid(8, false);
|
||||
setupCtx2D(ctx);
|
||||
((PrefixTreeStrategy) strategy).setPointsOnly(true);
|
||||
Point point = ctx.makePoint(86, -127.44362190053255);
|
||||
adoc("0", point);
|
||||
commit();
|
||||
Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects,
|
||||
ctx.makeRectangle(point, point)));
|
||||
assertEquals(1, executeQuery(query, 1).numFound);
|
||||
}
|
||||
|
||||
/** See LUCENE-5062, {@link ContainsPrefixTreeQuery#multiOverlappingIndexedShapes}. */
|
||||
@Test
|
||||
public void testContainsPairOverlap() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue