-
Notifications
You must be signed in to change notification settings - Fork 841
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
base: main
Are you sure you want to change the base?
Changes from all commits
5e3f7eb
7eff9d2
dd87dfc
dd2fd5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1901,4 +1901,42 @@ public void testFieldExistsQueries() throws SyntaxError { | |
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
|
abumarjikar marked this conversation as resolved.
|
||
| 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", "type_t", "negativetest")); | ||
| assertU(adoc("id", "9415", "v_t", "pureneg foo baz", "type_t", "negativetest")); | ||
| assertU(adoc("id", "9416", "v_t", "pureneg baz", "type_t", "negativetest")); | ||
| 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"), | ||
|
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. This query still contains must clause. Could you please try assert with pure negative like {!bool must_not='{!term f=v_t v=bar}'} ?
Contributor
Author
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. This does check the similar i just restricted to my test documents. Please let me know if i still need to add another test. |
||
| "/response/numFound==1", | ||
| "/response/docs/[0]/id=='9415'"); | ||
|
|
||
| assertJQ( | ||
| req("q", "v_t:pureneg NOT v_t:foo", "df", "v_t"), | ||
| "/response/numFound==1", | ||
| "/response/docs/[0]/id=='9416'"); | ||
|
|
||
| assertJQ( | ||
| req("q", "NOT v_t:pureneg", "df", "v_t", "fq", "type_t:negativetest"), | ||
| "/response/numFound==0"); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.