elastic / elastic/elasticsearch
Support the `_explain` API for retrievers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 77.9k
- Forks
- 26.1k
- PR merge metrics
- PR metrics pending
Description
Description
As it stands right now, to gather explanations for retrievers, you must use explain: true in the _search API. However, its nice to have a score explanation and such for a particular document, even if its not in the top results in _search.
This is why we have the https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html API.
We should add support for retrievers. This sort of gets tricky as retrievers like rrf need to effectively run all sub-queries and then check if the provided doc is there. This is akin to what we do for knn and verifying if the provided document is in the top-k or not.
However, for other retrievers (standard, etc.), this should be fairly straight forward.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the existing _search explanation handling with the documented _explain API, then trace how standard, knn, and rrf retrievers execute. Define how a supplied document is checked for each retriever, including running rrf sub-queries, and verify that the API returns an explanation for both matching and non-top-result documents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, search
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100