Repository navigation
Conversation
_stopwords and _text_weights were consulted after TokenEscaper.escape, so the word the user typed never matched: it's was tested as it\'s against the English stopword set, and a text_weights key like don't never applied. Compare the raw normalized word, escape only after the filter and weight decisions, and keep the AGENTS.md normalization expression byte-identical. Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
Move the helper tests from the private _tokenize_and_escape_query to build_query_string, the entry point both query classes call, and run the clause check over HybridQuery and AggregateHybridQuery. Add a test that pins the new ValueError for text made only of contractions and stopwords, and rename the loop variable that held the weighted term. Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
vishal-bala
left a comment
There was a problem hiding this comment.
This looks good now, thanks. Since #831 has merged, could the Release Notes describe TextQuery as it behaves today? Specifically:
- Name
TextQueryin the opening line alongsideHybridQueryandAggregateHybridQuery, since all three now use this helper. - Change "
TextQueryraises it too once #831 moves it onto this helper" to say it raises now. With this PR on currentmain,TextQuery("it's", "body")raisesValueError.
|
Looks like the test suite isn't passing for redis-py 6.x - can you take a look and sort the issue out? |
chrikrah
left a comment
There was a problem hiding this comment.
@vishal-bala you're right about the weights; I took your Redis 8.10 numbers, having no server here. The follow-up commit routes tests through build_query_string, covers both hybrid classes, pins the contraction-only ValueError, and renames escaped to term.
The Release Notes drop the weights claim and list your three behavior changes. Changes says the weighted term matches nothing on 8.10.
I'd keep the weight half so key matching stops depending on escaping. Fine with you?
|
Yes, keeping the weight half is fine. Two things before merge: the redis-py 6.x failure is the |
vishal-bala
left a comment
There was a problem hiding this comment.
Separately, the Release Notes still describe TextQuery as it behaved before #831 merged. Could you update them?
- Name
TextQueryin the opening line alongsideHybridQueryandAggregateHybridQuery, since all three now use this helper. - Change "
TextQueryraises it too once #831 moves it onto this helper" to say it raises now. With this PR on currentmain,TextQuery("it's", "body")raisesValueError.
redisvl.query.hybrid imports on any redis-py and only needs redis-py's hybrid API once a HybridQuery is built, so the import guard never set HybridQuery to None and the redis-py 6.x jobs failed with ImportError. Import redis.commands.search.hybrid_query first, as tests/unit/test_hybrid_types.py does, so the skip applies. Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
chrikrah
left a comment
There was a problem hiding this comment.
@vishal-bala both are in, as bd2c7bf. The guard now imports redis.commands.search.hybrid_query as you suggested, and the Release Notes name TextQuery and say it raises now.
# PR head 52127ce, old guard, redis-py 6.4.0, Python 3.12
$ pytest -q --noconftest tests/unit/test_full_text_query_helper.py
1 failed, 6 passed # ImportError in the HybridQuery case
# branch with the new guard, applied on main 84c6188
$ pytest -q --noconftest tests/unit/test_full_text_query_helper.py tests/unit/test_text_query_weights.py tests/unit/test_query_types.py tests/unit/test_aggregation_types.py tests/unit/test_hybrid_types.py tests/unit/test_filter.py
258 passed, 48 skipped # redis-py 6.4.0
305 passed, 1 skipped, 131 warnings # redis-py 8.1.0
# not run: live Redis
The workflows on bd2c7bf are waiting for approval. Could you start them, and is anything else left once the 6.x jobs pass?
Motivation
Second bug of #821, as @vishal-bala invited there. The helper escaped each word before it looked up stopwords and
text_weights. It testedit\'sagainst a set that holdsit's.Changes
Membership runs on the raw normalized word and escaping feeds only the clause. Tests go through
build_query_string.A
text_weightskey such asdon'tnow reaches the clause asdon\'t=>{$weight:2.0}. Redis indexesdon'tasdonandt, so on Redis 8.10 that term matches nothing and ranking is unchanged.Release Notes
TextQuery,HybridQueryandAggregateHybridQuerynow match stopwords against the typed word, punctuation included.TextQuery("it's", "body"), now raisesValueErrorin all three classes.stopwords={"it\\'s"}ortext_weights={"don\\'t": 2.0}silently stop matching.d'un, take effect as well.Reviewer Brief
Fixes #821 (the second bug; #831 covers the first).