Repository navigation
Score a prefix term the same for each node that holds it, as Lucene's prefix query does, on the SQL stores (#427) - #433
Draft
jasperblues wants to merge 2 commits into
Draft
jasperblues wants to merge 2 commits into
jasperblues wants to merge 2 commits into
Conversation
… prefix query does, on the SQL stores (#427) Port of liberation-data/drivine4j#612 (drivine4j PR #623). A prefix term adds k1 + 1 to each node that holds it: Lucene's constant of 1 on the scale of bm25_score.
…that a prefix term adds the same to each node (#427)
This branch has not been deployed
This file contains hidden or 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
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.
Closes #427. Port of liberation-data/drivine4j#612 (drivine4j PR #623), as liberation-data/drivine#638 ports it. Not to merge until train 2026.11.1 is cut, and not before drivine#638.
On Postgres, SQLite and Oracle without Oracle Text, a prefix term (
kiw*) was weighed by BM25, while Neo4j's Lucene scores a prefix query as a constant.bm25_ranked(drivine/backend/sql/bm25.py) now addsPREFIX,k1 + 1= 2.2, to each node that holds a prefix term (is_prefix). That is Lucene's constant of 1 onbm25_score's scale. Every other term scores as before.Goldens: unchanged, since none of them pins a prefix query.
Tests
tests/integration/test_bm25.py, and its sync copy, on Neo4j, Postgres, Postgres indexed, SQLite and Oracle:kiw*scores every hit 1.0;kiw* birdranks the node with both first;kiw*andkiwi*give every hit 1.0, andkiw* melonand+kiw* melongive the formula's figure, within 0.01 of Neo4j's measured 0.5409. On Neo4j, with lengths in tokens, it's within 1e-4.tests/unit/test_bm25.py: the score SQL forkiw* melon.Verification
docs/02-connecting.md,docs/07-schema.md); pass 2 came back clean.