fix: wrap group_ids OR clause in parentheses for BM25 fulltext query#1311
fix: wrap group_ids OR clause in parentheses for BM25 fulltext query#1311giulio-leone wants to merge 1 commit intogetzep:mainfrom
Conversation
Without parentheses around the OR-joined group_id filters, Lucene's operator precedence causes AND to bind tighter than OR. This means only the last group_id is effectively combined with the search query. Before: group_id:"1" OR group_id:"2" OR group_id:"3" AND (query) After: (group_id:"1" OR group_id:"2" OR group_id:"3") AND (query) Closes getzep#1249
|
I have read the CLA Document and I hereby sign the CLA giulio-leone seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
|
I have read the CLA Document and I hereby sign the CLA |
|
I have read the CLA Document and I hereby sign the CLA |
|
I have read the Zep CLA and I sign and agree to its terms. |
Summary
Fixes #1249 — BM25 fulltext search with multiple
group_idsonly filtered by the last group due to missing parentheses around the OR clause.Problem
Without parentheses, Lucene operator precedence causes
ANDto bind tighter thanOR:is parsed as:
Fix
Wrap the OR clause in parentheses in
fulltext_query()(search_utils.pyline 101):Now produces the correct query:
Tests
Added
tests/utils/search/test_fulltext_query.pywith 4 test cases covering single, multiple, no, and empty group_ids.