-
Notifications
You must be signed in to change notification settings - Fork 839
SOLR-18256: Fix lucene QParser to support nested pure negative queries #4552
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
Open
abumarjikar
wants to merge
1
commit into
apache:main
Choose a base branch
from
abumarjikar:SOLR_18256_autofix_negative_lucene_clauses
base: main
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.
+44
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
changelog/unreleased/SOLR_18256_autofix_negative_lucene_clauses.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| type: fixed | ||
| title: Fix pure negative (NOT) sub-expression queries in lucene QParser | ||
| authors: | ||
| - name: Abhishek Umarjikar | ||
| nick: abumarjikar | ||
| links: | ||
| - name: SOLR-18256 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18256 |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1901,4 +1901,32 @@ public void testFieldExistsQueries() throws SyntaxError { | |
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not seeing here a pure negative query... you've put a MUST clause on each one. |
||
| public void testNestedPureNegativeQuery() throws Exception { | ||
| // Standard sample data with completely unique field values to isolate matches | ||
| assertU(adoc("id", "9414", "v_t", "pureneg foo bar")); | ||
| assertU(adoc("id", "9415", "v_t", "pureneg foo baz")); | ||
| assertU(adoc("id", "9416", "v_t", "pureneg baz")); | ||
| assertU(commit()); | ||
|
|
||
| // Top-level negative query must exclude 'bar' but successfully find our other docs | ||
| // Force sort by ID so the array index expectations always line up perfectly | ||
| assertJQ( | ||
| req("q", "v_t:pureneg AND -v_t:bar", "df", "v_t", "sort", "id asc"), | ||
| "/response/docs/[0]/id=='9415'", | ||
| "/response/docs/[1]/id=='9416'"); | ||
|
|
||
| // Nested pure negative query inside a parenthesized group with AND | ||
| assertJQ( | ||
| req("q", "v_t:pureneg AND v_t:foo AND (-v_t:bar)", "df", "v_t"), | ||
| "/response/numFound==1", | ||
| "/response/docs/[0]/id=='9415'"); | ||
|
|
||
| // Nested pure negative query using explicit NOT syntax | ||
| assertJQ( | ||
| req("q", "v_t:pureneg AND v_t:foo AND (NOT v_t:bar)", "df", "v_t"), | ||
| "/response/numFound==1", | ||
| "/response/docs/[0]/id=='9415'"); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow... boy this was simple.