squallsama commented on code in PR #4552:
URL: https://github.com/apache/solr/pull/4552#discussion_r3502877609
##########
solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java:
##########
@@ -1901,4 +1901,42 @@ public void testFieldExistsQueries() throws SyntaxError {
}
}
}
+
+ @Test
+ 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"),
Review Comment:
This query still contains must clause. Could you please try assert with pure
negative like {!bool must_not='{!term f=v_t v=bar}'} ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]