opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.83k stars 1.83k forks source link

[Enhancement Request] Extend search by allowing to choose the score mode for empty query collector #16659

Open martin-gaievski opened 6 days ago

martin-gaievski commented 6 days ago

Is your feature request related to a problem? Please describe

The current implementation of MultiCollector in Lucene has limitations that can lead to several undesirable side effects in OpenSearch, including:

the limitation is in method public ScoreMode scoreMode(), in case of multiple collectors (which is the typical use case for MultiCollector) the score mode can fall back to ScoreMode.COMPLETE or ScoreMode.COMPLETE_NO_SCORES. This can happen in case score modes are not the same among all the collectors.

One specific scenario affected by this limitation is when a client uses EMPTY_CONTEXT from QueryCollectorContext. The EMPTY_CONTEXT is initialized by EMPTY_COLLECTOR, which has a hardcoded score mode value as COMPLETE_NO_SCORES.

Describe the solution you'd like

To address this issue, I propose allowing clients to specify the score mode for EMPTY_CONTEXT. This enhancement will maintain the original functionality of allowing callers to omit the default top docs collector (as introduced in PR #13481) while providing more flexibility and control over the score mode.

Related component

Search

Describe alternatives you've considered

No response

Additional context

No response