Build SpatialVisitor once per index (#11825)

Address a performance regression on polygon queries using LatLonPoint field.
This commit is contained in:
Ignacio Vera 2022-09-27 10:51:49 +02:00 committed by GitHub
parent 971ae01164
commit 78b58b8e2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -208,6 +208,7 @@ abstract class SpatialQuery extends Query {
@Override @Override
public final Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) { public final Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) {
final SpatialQuery query = this; final SpatialQuery query = this;
final SpatialVisitor spatialVisitor = getSpatialVisitor();
return new ConstantScoreWeight(query, boost) { return new ConstantScoreWeight(query, boost) {
@Override @Override
public Scorer scorer(LeafReaderContext context) throws IOException { public Scorer scorer(LeafReaderContext context) throws IOException {
@ -221,7 +222,7 @@ abstract class SpatialQuery extends Query {
@Override @Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException { public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
final LeafReader reader = context.reader(); final LeafReader reader = context.reader();
return getScorerSupplier(reader, getSpatialVisitor(), scoreMode, this, boost, score()); return getScorerSupplier(reader, spatialVisitor, scoreMode, this, boost, score());
} }
@Override @Override