Hi All,

When running vector search with grouping in multi-shard setting, the
KnnFloatVectorQuery is executed (2+rows) times.

The culprit is this function call in
https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java#L202

if (needScores) {
  for (GroupDocs<?> group : topGroups.groups) {
    TopFieldCollector.populateScores(group.scoreDocs, searcher, query);
  }
}

Where
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java#L403
does

final Weight weight = searcher.createWeight(searcher.rewrite(query),
ScoreMode.COMPLETE, 1);

Here, if the query is KnnFloatVectorQuery, *searcher.rewrite(query) *will
execute the same vector search for each topGroups.groups

a simple fix could be moving *searcher.rewrite(query) *out of the
topGroups.groups loop. Thoughts?

Best,

Yue

Reply via email to