Skip to content

Commit

Permalink
create weight once
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Oct 15, 2018
1 parent 779c5c7 commit 4255bee
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.lucene.search.SearcherFactory;
import org.apache.lucene.search.SearcherManager;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.Weight;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
Expand Down Expand Up @@ -263,8 +264,9 @@ private static LocalCheckpointTracker createLocalCheckpointTracker(EngineConfig
final IndexSearcher searcher = new IndexSearcher(reader);
searcher.setQueryCache(null);
final Query query = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, localCheckpoint + 1, maxSeqNo);
final Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1.0f);
for (LeafReaderContext leaf : reader.leaves()) {
final Scorer scorer = searcher.createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1.0f).scorer(leaf);
final Scorer scorer = weight.scorer(leaf);
if (scorer == null) {
continue;
}
Expand Down

0 comments on commit 4255bee

Please sign in to comment.