From 0461f7ec245c3470b51efde43d623a06990cc3df Mon Sep 17 00:00:00 2001 From: iverase Date: Tue, 27 Sep 2022 10:25:57 +0200 Subject: [PATCH] Build SpatialVisitor once per index --- .../core/src/java/org/apache/lucene/document/SpatialQuery.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ public Scorer get(long leadCost) throws IOException { @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 @@ public Scorer scorer(LeafReaderContext context) throws IOException { @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