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 a4896ee82..d5cd80934 100644 --- a/src/main/java/org/opensearch/knn/index/query/KNNWeight.java +++ b/src/main/java/org/opensearch/knn/index/query/KNNWeight.java @@ -140,6 +140,9 @@ public Map searchLeaf(LeafReaderContext context, int k) throws I return doExactSearch(context, filterBitSet, k); } Map docIdsToScoreMap = doANNSearch(context, filterBitSet, cardinality, k); + // 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 BitSet docs = filterWeight != null ? filterBitSet : null; return doExactSearch(context, docs, k); @@ -265,7 +268,7 @@ private Map doANNSearch( List engineFiles = KNNCodecUtil.getEngineFiles(knnEngine.getExtension(), knnQuery.getField(), reader.getSegmentInfo().info); if (engineFiles.isEmpty()) { - log.info("[KNN] No native engine files found for field {} for segment {}", knnQuery.getField(), reader.getSegmentName()); + log.debug("[KNN] No native engine files found for field {} for segment {}", knnQuery.getField(), reader.getSegmentName()); return Collections.emptyMap(); } @@ -437,7 +440,7 @@ private boolean isExactSearchThresholdSettingSet(int filterThresholdValue) { */ private boolean isExactSearchRequire(final LeafReaderContext context, final int filterIdsCount, final int annResultCount) { if (annResultCount == 0 && isMissingNativeEngineFiles(context)) { - log.info("Perform exact search after approximate search since no native engine files are available"); + log.debug("Perform exact search after approximate search since no native engine files are available"); return true; } if (isFilteredExactSearchRequireAfterANNSearch(filterIdsCount, annResultCount)) {