Skip to content

Apache Lucene open-source search software

Build SpatialVisitor once per index (#11825)

Ignacio Vera78b58b8e2ecd
diff --git a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
index f429f1cc046..612c1e0c16d 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SpatialQuery.java
@@ -208,6 +208,7 @@ abstract class SpatialQuery extends Query {
@Override
public final Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) {
final SpatialQuery query = this;
+ final SpatialVisitor spatialVisitor = getSpatialVisitor();
return new ConstantScoreWeight(query, boost) {
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
@@ -221,7 +222,7 @@ abstract class SpatialQuery extends Query {
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
final LeafReader reader = context.reader();
- return getScorerSupplier(reader, getSpatialVisitor(), scoreMode, this, boost, score());
+ return getScorerSupplier(reader, spatialVisitor, scoreMode, this, boost, score());
}
@Override