From c526a1334e67a4364a79208e5f0d078c049a34f2 Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 11:21:35 -0800 Subject: [PATCH 1/6] Adds debug logs for KNNQuery and KNNWeight Signed-off-by: Tejas Shah --- .../org/opensearch/knn/index/query/KNNQuery.java | 6 ++++++ .../org/opensearch/knn/index/query/KNNWeight.java | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java index 1a03f4b99..6049af0d6 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java @@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import lombok.extern.log4j.Log4j2; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.FieldExistsQuery; @@ -19,6 +20,7 @@ import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.Weight; import org.apache.lucene.search.join.BitSetProducer; +import org.opensearch.common.StopWatch; import org.opensearch.knn.index.KNNSettings; import org.opensearch.knn.index.VectorDataType; import org.opensearch.knn.index.query.rescore.RescoreContext; @@ -32,6 +34,7 @@ * Custom KNN query. Query is used for KNNEngine's that create their own custom segment files. These files need to be * loaded and queried in a custom manner throughout the query path. */ +@Log4j2 @Getter @Builder @AllArgsConstructor @@ -168,7 +171,10 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo if (!KNNSettings.isKNNPluginEnabled()) { throw new IllegalStateException("KNN plugin is disabled. To enable update knn.plugin.enabled to true"); } + StopWatch stopWatch = new StopWatch().start(); final Weight filterWeight = getFilterWeight(searcher); + stopWatch.stop(); + log.debug("Creating filter weight for field [{}] took [{}] nanos", field, stopWatch.totalTime().nanos()); if (filterWeight != null) { return new KNNWeight(this, boost, filterWeight); } diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index d5912d758..77a5474b7 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -20,6 +20,7 @@ import org.apache.lucene.util.BitSetIterator; import org.apache.lucene.util.Bits; import org.apache.lucene.util.FixedBitSet; +import org.opensearch.common.StopWatch; import org.opensearch.common.lucene.Lucene; import org.opensearch.knn.common.FieldInfoExtractor; import org.opensearch.knn.common.KNNConstants; @@ -129,7 +130,11 @@ public Scorer scorer(LeafReaderContext context) throws IOException { * @return A Map of docId to scores for top k results */ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOException { + StopWatch stopWatch = new StopWatch().start(); final BitSet filterBitSet = getFilteredDocsBitSet(context); + stopWatch.stop(); + log.debug("Creating filter bitset for field [{}] took [{}] nanos", knnQuery.getField(), stopWatch.totalTime().nanos()); + final int maxDoc = context.reader().maxDoc(); int cardinality = filterBitSet.cardinality(); // We don't need to go to JNI layer if no documents are found which satisfy the filters @@ -153,7 +158,10 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep * so that it will not do a bitset look up in bottom search layer. */ final BitSet annFilter = (filterWeight != null && cardinality == maxDoc) ? null : filterBitSet; + StopWatch annStopWatch = new StopWatch().start(); final Map docIdsToScoreMap = doANNSearch(context, annFilter, cardinality, k); + annStopWatch.stop(); + log.debug("ANN search for field [{}] took [{}] nanos", knnQuery.getField(), annStopWatch.totalTime().nanos()); // See whether we have to perform exact search based on approx search results // This is required if there are no native engine files or if approximate search returned @@ -402,7 +410,11 @@ public Map exactSearch( final LeafReaderContext leafReaderContext, final ExactSearcher.ExactSearcherContext exactSearcherContext ) throws IOException { - return exactSearcher.searchLeaf(leafReaderContext, exactSearcherContext); + StopWatch stopWatch = new StopWatch().start(); + Map exactSearchResults = exactSearcher.searchLeaf(leafReaderContext, exactSearcherContext); + stopWatch.stop(); + log.debug("Exact search for field [{}] took [{}] nanos", knnQuery.getField(), stopWatch.totalTime().nanos()); + return exactSearchResults; } @Override From 2883e80d13ed6aaf476015e3a228e5f9397c34ff Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 12:12:58 -0800 Subject: [PATCH 2/6] Adds check to see if log is enabled to start and stop StopWatch Signed-off-by: Tejas Shah --- .../opensearch/knn/index/query/KNNQuery.java | 13 ++++++-- .../opensearch/knn/index/query/KNNWeight.java | 31 +++++++++++++------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java index 6049af0d6..a5f7b72a2 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java @@ -171,10 +171,17 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo if (!KNNSettings.isKNNPluginEnabled()) { throw new IllegalStateException("KNN plugin is disabled. To enable update knn.plugin.enabled to true"); } - StopWatch stopWatch = new StopWatch().start(); + StopWatch stopWatch = null; + if (log.isDebugEnabled()) { + stopWatch = new StopWatch().start(); + } + final Weight filterWeight = getFilterWeight(searcher); - stopWatch.stop(); - log.debug("Creating filter weight for field [{}] took [{}] nanos", field, stopWatch.totalTime().nanos()); + if (log.isDebugEnabled() && stopWatch != null) { + stopWatch.stop(); + log.debug("Creating filter weight for field [{}] took [{}] nanos", field, stopWatch.totalTime().nanos()); + } + if (filterWeight != null) { return new KNNWeight(this, boost, filterWeight); } diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index 77a5474b7..88ad89850 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -20,6 +20,7 @@ import org.apache.lucene.util.BitSetIterator; import org.apache.lucene.util.Bits; import org.apache.lucene.util.FixedBitSet; +import org.opensearch.common.Nullable; import org.opensearch.common.StopWatch; import org.opensearch.common.lucene.Lucene; import org.opensearch.knn.common.FieldInfoExtractor; @@ -130,10 +131,9 @@ public Scorer scorer(LeafReaderContext context) throws IOException { * @return A Map of docId to scores for top k results */ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOException { - StopWatch stopWatch = new StopWatch().start(); + StopWatch stopWatch = startStopWatch(); final BitSet filterBitSet = getFilteredDocsBitSet(context); - stopWatch.stop(); - log.debug("Creating filter bitset for field [{}] took [{}] nanos", knnQuery.getField(), stopWatch.totalTime().nanos()); + stopStopWatchAndLog(stopWatch, "Creating filter bitset for field [{}] took [{}] nanos"); final int maxDoc = context.reader().maxDoc(); int cardinality = filterBitSet.cardinality(); @@ -158,10 +158,10 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep * so that it will not do a bitset look up in bottom search layer. */ final BitSet annFilter = (filterWeight != null && cardinality == maxDoc) ? null : filterBitSet; - StopWatch annStopWatch = new StopWatch().start(); + StopWatch annStopWatch = startStopWatch(); + ; final Map docIdsToScoreMap = doANNSearch(context, annFilter, cardinality, k); - annStopWatch.stop(); - log.debug("ANN search for field [{}] took [{}] nanos", knnQuery.getField(), annStopWatch.totalTime().nanos()); + stopStopWatchAndLog(annStopWatch, "ANN search for field [{}] took [{}] nanos"); // See whether we have to perform exact search based on approx search results // This is required if there are no native engine files or if approximate search returned @@ -174,6 +174,13 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep return new PerLeafResult(filterWeight == null ? null : filterBitSet, docIdsToScoreMap); } + private void stopStopWatchAndLog(@Nullable StopWatch stopWatch, String message) { + if (log.isDebugEnabled() && stopWatch != null) { + stopWatch.stop(); + log.debug(message, knnQuery.getField(), stopWatch.totalTime().nanos()); + } + } + private BitSet getFilteredDocsBitSet(final LeafReaderContext ctx) throws IOException { if (this.filterWeight == null) { return new FixedBitSet(0); @@ -410,10 +417,9 @@ public Map exactSearch( final LeafReaderContext leafReaderContext, final ExactSearcher.ExactSearcherContext exactSearcherContext ) throws IOException { - StopWatch stopWatch = new StopWatch().start(); + StopWatch stopWatch = startStopWatch(); Map exactSearchResults = exactSearcher.searchLeaf(leafReaderContext, exactSearcherContext); - stopWatch.stop(); - log.debug("Exact search for field [{}] took [{}] nanos", knnQuery.getField(), stopWatch.totalTime().nanos()); + stopStopWatchAndLog(stopWatch, "Exact search for field [{}] took [{}] nanos"); return exactSearchResults; } @@ -535,4 +541,11 @@ private boolean isMissingNativeEngineFiles(LeafReaderContext context) { ); return engineFiles.isEmpty(); } + + private StopWatch startStopWatch() { + if (log.isDebugEnabled()) { + return new StopWatch().start(); + } + return null; + } } From 38756c3e89267922c438882fcc64b9991a85ea8f Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 14:05:47 -0800 Subject: [PATCH 3/6] Addressing comments on the PR Signed-off-by: Tejas Shah --- .../org/opensearch/knn/index/query/KNNWeight.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index 88ad89850..fc598abdc 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -133,7 +133,7 @@ public Scorer scorer(LeafReaderContext context) throws IOException { public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOException { StopWatch stopWatch = startStopWatch(); final BitSet filterBitSet = getFilteredDocsBitSet(context); - stopStopWatchAndLog(stopWatch, "Creating filter bitset for field [{}] took [{}] nanos"); + stopStopWatchAndLog(stopWatch, "FilterBitSet creation"); final int maxDoc = context.reader().maxDoc(); int cardinality = filterBitSet.cardinality(); @@ -158,10 +158,10 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep * so that it will not do a bitset look up in bottom search layer. */ final BitSet annFilter = (filterWeight != null && cardinality == maxDoc) ? null : filterBitSet; + StopWatch annStopWatch = startStopWatch(); - ; final Map docIdsToScoreMap = doANNSearch(context, annFilter, cardinality, k); - stopStopWatchAndLog(annStopWatch, "ANN search for field [{}] took [{}] nanos"); + stopStopWatchAndLog(annStopWatch, "ANN search"); // See whether we have to perform exact search based on approx search results // This is required if there are no native engine files or if approximate search returned @@ -174,10 +174,11 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep return new PerLeafResult(filterWeight == null ? null : filterBitSet, docIdsToScoreMap); } - private void stopStopWatchAndLog(@Nullable StopWatch stopWatch, String message) { + private void stopStopWatchAndLog(@Nullable final StopWatch stopWatch, final String prefixMessage) { if (log.isDebugEnabled() && stopWatch != null) { stopWatch.stop(); - log.debug(message, knnQuery.getField(), stopWatch.totalTime().nanos()); + final String logMessage = prefixMessage + ", field: [{}], time in nanos:[{}] "; + log.debug(logMessage, knnQuery.getField(), stopWatch.totalTime().nanos()); } } @@ -419,7 +420,7 @@ public Map exactSearch( ) throws IOException { StopWatch stopWatch = startStopWatch(); Map exactSearchResults = exactSearcher.searchLeaf(leafReaderContext, exactSearcherContext); - stopStopWatchAndLog(stopWatch, "Exact search for field [{}] took [{}] nanos"); + stopStopWatchAndLog(stopWatch, "Exact search"); return exactSearchResults; } From d855696b73c92214f3767b9d79a240eb06b84262 Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 16:26:49 -0800 Subject: [PATCH 4/6] Adds shard and segment info in the logs Signed-off-by: Tejas Shah --- .../opensearch/knn/index/query/KNNQuery.java | 12 ++++++-- .../knn/index/query/KNNQueryFactory.java | 4 +++ .../opensearch/knn/index/query/KNNWeight.java | 28 +++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java index a5f7b72a2..3a4201bff 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQuery.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQuery.java @@ -48,7 +48,6 @@ public class KNNQuery extends Query { private final String indexName; private final VectorDataType vectorDataType; private final RescoreContext rescoreContext; - @Setter private Query filterQuery; @Getter @@ -56,6 +55,10 @@ public class KNNQuery extends Query { private Float radius; private Context context; + // Note: ideally query should not have to deal with shard level information. Adding it for logging purposes only + // TODO: ThreadContext does not work with logger, remove this from here once its figured out + private int shardId; + public KNNQuery( final String field, final float[] queryVector, @@ -179,7 +182,12 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo final Weight filterWeight = getFilterWeight(searcher); if (log.isDebugEnabled() && stopWatch != null) { stopWatch.stop(); - log.debug("Creating filter weight for field [{}] took [{}] nanos", field, stopWatch.totalTime().nanos()); + log.debug( + "Creating filter weight, Shard: [{}], field: [{}] took in nanos: [{}]", + shardId, + field, + stopWatch.totalTime().nanos() + ); } if (filterWeight != null) { diff --git a/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java b/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java index 8e6c97f05..498a1e602 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNQueryFactory.java @@ -52,9 +52,11 @@ public static Query create(CreateQueryRequest createQueryRequest) { final KNNEngine knnEngine = createQueryRequest.getKnnEngine(); final boolean expandNested = createQueryRequest.getExpandNested().orElse(false); BitSetProducer parentFilter = null; + int shardId = -1; if (createQueryRequest.getContext().isPresent()) { QueryShardContext context = createQueryRequest.getContext().get(); parentFilter = context.getParentFilter(); + shardId = context.getShardId(); } if (parentFilter == null && expandNested) { @@ -93,6 +95,7 @@ public static Query create(CreateQueryRequest createQueryRequest) { .filterQuery(validatedFilterQuery) .vectorDataType(vectorDataType) .rescoreContext(rescoreContext) + .shardId(shardId) .build(); break; default: @@ -106,6 +109,7 @@ public static Query create(CreateQueryRequest createQueryRequest) { .filterQuery(validatedFilterQuery) .vectorDataType(vectorDataType) .rescoreContext(rescoreContext) + .shardId(shardId) .build(); } diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index fc598abdc..3d759716c 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -131,9 +131,12 @@ public Scorer scorer(LeafReaderContext context) throws IOException { * @return A Map of docId to scores for top k results */ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOException { + final SegmentReader reader = Lucene.segmentReader(context.reader()); + final String segmentName = reader.getSegmentName(); + StopWatch stopWatch = startStopWatch(); final BitSet filterBitSet = getFilteredDocsBitSet(context); - stopStopWatchAndLog(stopWatch, "FilterBitSet creation"); + stopStopWatchAndLog(stopWatch, "FilterBitSet creation", segmentName); final int maxDoc = context.reader().maxDoc(); int cardinality = filterBitSet.cardinality(); @@ -149,7 +152,7 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep * This improves the recall. */ if (isFilteredExactSearchPreferred(cardinality)) { - Map result = doExactSearch(context, new BitSetIterator(filterBitSet, cardinality), cardinality, k); + Map result = doExactSearch(context, new BitSetIterator(filterBitSet, cardinality), cardinality, k, segmentName); return new PerLeafResult(filterWeight == null ? null : filterBitSet, result); } @@ -160,25 +163,25 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep final BitSet annFilter = (filterWeight != null && cardinality == maxDoc) ? null : filterBitSet; StopWatch annStopWatch = startStopWatch(); - final Map docIdsToScoreMap = doANNSearch(context, annFilter, cardinality, k); - stopStopWatchAndLog(annStopWatch, "ANN search"); + final Map docIdsToScoreMap = doANNSearch(reader, context, annFilter, cardinality, k); + stopStopWatchAndLog(annStopWatch, "ANN search", segmentName); // See whether we have to perform exact search based on approx search results // This is required if there are no native engine files or if approximate search returned // results less than K, though we have more than k filtered docs if (isExactSearchRequire(context, cardinality, docIdsToScoreMap.size())) { final BitSetIterator docs = filterWeight != null ? new BitSetIterator(filterBitSet, cardinality) : null; - Map result = doExactSearch(context, docs, cardinality, k); + Map result = doExactSearch(context, docs, cardinality, k, segmentName); return new PerLeafResult(filterWeight == null ? null : filterBitSet, result); } return new PerLeafResult(filterWeight == null ? null : filterBitSet, docIdsToScoreMap); } - private void stopStopWatchAndLog(@Nullable final StopWatch stopWatch, final String prefixMessage) { + private void stopStopWatchAndLog(@Nullable final StopWatch stopWatch, final String prefixMessage, String segmentName) { if (log.isDebugEnabled() && stopWatch != null) { stopWatch.stop(); - final String logMessage = prefixMessage + ", field: [{}], time in nanos:[{}] "; - log.debug(logMessage, knnQuery.getField(), stopWatch.totalTime().nanos()); + final String logMessage = prefixMessage + " shard: [{}], segment: [{}], field: [{}], time in nanos:[{}] "; + log.debug(logMessage, knnQuery.getShardId(), segmentName, knnQuery.getField(), stopWatch.totalTime().nanos()); } } @@ -238,7 +241,8 @@ private Map doExactSearch( final LeafReaderContext context, final DocIdSetIterator acceptedDocs, final long numberOfAcceptedDocs, - int k + final int k, + final String segmentName ) throws IOException { final ExactSearcherContextBuilder exactSearcherContextBuilder = ExactSearcher.ExactSearcherContext.builder() .isParentHits(true) @@ -253,13 +257,12 @@ private Map doExactSearch( } private Map doANNSearch( + final SegmentReader reader, final LeafReaderContext context, final BitSet filterIdsBitSet, final int cardinality, final int k ) throws IOException { - final SegmentReader reader = Lucene.segmentReader(context.reader()); - FieldInfo fieldInfo = FieldInfoExtractor.getFieldInfo(reader, knnQuery.getField()); if (fieldInfo == null) { @@ -420,7 +423,8 @@ public Map exactSearch( ) throws IOException { StopWatch stopWatch = startStopWatch(); Map exactSearchResults = exactSearcher.searchLeaf(leafReaderContext, exactSearcherContext); - stopStopWatchAndLog(stopWatch, "Exact search"); + final SegmentReader reader = Lucene.segmentReader(leafReaderContext.reader()); + stopStopWatchAndLog(stopWatch, "Exact search", reader.getSegmentName()); return exactSearchResults; } From 7b0d3f6b991c0ac949af1736f2a62ce8d290b5f2 Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 16:30:33 -0800 Subject: [PATCH 5/6] Removes unnecessary segment name param from exact search Signed-off-by: Tejas Shah --- src/main/java/org/opensearch/knn/index/query/KNNWeight.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index 3d759716c..5b36f567e 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -152,7 +152,7 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep * This improves the recall. */ if (isFilteredExactSearchPreferred(cardinality)) { - Map result = doExactSearch(context, new BitSetIterator(filterBitSet, cardinality), cardinality, k, segmentName); + Map result = doExactSearch(context, new BitSetIterator(filterBitSet, cardinality), cardinality, k); return new PerLeafResult(filterWeight == null ? null : filterBitSet, result); } @@ -241,8 +241,7 @@ private Map doExactSearch( final LeafReaderContext context, final DocIdSetIterator acceptedDocs, final long numberOfAcceptedDocs, - final int k, - final String segmentName + final int k ) throws IOException { final ExactSearcherContextBuilder exactSearcherContextBuilder = ExactSearcher.ExactSearcherContext.builder() .isParentHits(true) From 10821cdccd3d5c1f06db365e4017fa369e6f887a Mon Sep 17 00:00:00 2001 From: Tejas Shah Date: Wed, 29 Jan 2025 16:35:58 -0800 Subject: [PATCH 6/6] Fixes the build Signed-off-by: Tejas Shah --- src/main/java/org/opensearch/knn/index/query/KNNWeight.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java index 5b36f567e..d07d57bda 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -171,7 +171,7 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep // results less than K, though we have more than k filtered docs if (isExactSearchRequire(context, cardinality, docIdsToScoreMap.size())) { final BitSetIterator docs = filterWeight != null ? new BitSetIterator(filterBitSet, cardinality) : null; - Map result = doExactSearch(context, docs, cardinality, k, segmentName); + Map result = doExactSearch(context, docs, cardinality, k); return new PerLeafResult(filterWeight == null ? null : filterBitSet, result); } return new PerLeafResult(filterWeight == null ? null : filterBitSet, docIdsToScoreMap);