Undo the changes in 54c49e6. I believe that commit changes the original NOT NOT _exists_:field to NOT _exists_:field, which is incorrect as it flips the condition. My bad for not noticing when I saw the original commit!
Fix #19 by overriding convert_condition_not to generate _exists_:field instead for that specific double NOT case.
The parentheses around that _exists_:field are not needed when it appears in an expression, so override compare_precedence to skip parentheses if it is given a field null condition.
Also override compare_precedence to add parentheses around other cases of NOT _exists_:field to prevent weird issues with the precedence of an unenclosed NOT in Lucene when used in AND/OR expressions.[^1]
[^1]: The LuceneBackend already generates (NOT fieldA:valueA) AND (NOT fieldB:valueB), so it makes sense to enclose (NOT _exists_:field).
Hello, here is a proposed fix for #19 and #24.
Here are the changes:
NOT NOT _exists_:field
toNOT _exists_:field
, which is incorrect as it flips the condition. My bad for not noticing when I saw the original commit!convert_condition_not
to generate_exists_:field
instead for that specific double NOT case._exists_:field
are not needed when it appears in an expression, so overridecompare_precedence
to skip parentheses if it is given a field null condition.compare_precedence
to add parentheses around other cases ofNOT _exists_:field
to prevent weird issues with the precedence of an unenclosedNOT
in Lucene when used inAND
/OR
expressions.[^1][^1]: The
LuceneBackend
already generates(NOT fieldA:valueA) AND (NOT fieldB:valueB)
, so it makes sense to enclose(NOT _exists_:field)
.