-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MB-58901: Introduce support for BM25 scoring #2113
Open
Thejas-bhat
wants to merge
18
commits into
master
Choose a base branch
from
bm25-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thejas-bhat
force-pushed
the
bm25-refactor
branch
from
December 6, 2024 06:51
2b54a8d
to
738dfe1
Compare
Thejas-bhat
force-pushed
the
presearchRefactor
branch
from
December 6, 2024 06:54
8b10cdf
to
d58474f
Compare
Thejas-bhat
force-pushed
the
bm25-refactor
branch
5 times, most recently
from
December 12, 2024 10:39
4b626d0
to
45efde1
Compare
Thejas-bhat
force-pushed
the
bm25-refactor
branch
from
January 6, 2025 07:16
f385ba6
to
e83cca0
Compare
Thejas-bhat
changed the title
WIP: BM25 scoring
MB-58901: Introduce support for BM25 scoring
Jan 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introducing support for BM25 scoring
Key stats necessary for the scoring
Introduces a mechanism to maintain consistent scoring in a situation where the index is partitioned as a
bleve.IndexAlias
. This is achieved using the existing preSearch mechanism where the first phase of the entire search involves fetching the above mentioned stats, aggregating them and redistributing back to the bleve indexes which would use them while calculating the score for a hit.Implementation wise, the user needs to explicitly mention BM25 as the scoring mechanism either at
indexMapping.DefaultSimilarity
or thefieldMapping.Similarity
level to actually use this scoring mechanism.The storage layer exposes an API which returns the number of terms in a field's term dictionary which is used to compute the
avgDocLength
. At the indexing layer, we check if the queried field supports BM25 scoring and if consistent scoring is availed. This is followed by fetching the stats either from the local bleve index or from a context (in the case where we're availing the consistent scoring) to compute the actual score.Note: The scoring is highly dependent on the size of an individual bleve index's termDictionary (specific to a field) so there can be some discrepancies especially given that each index is further composed of multiple 'segments'. However in large scale use cases these discrepancies can be quite small and don't affect the order of the doc hits - in which case the user may choose to avoid this altogether.