Hello, Arun.
Please check the great explanation generously provided by Shawn.
https://cwiki.apache.org/confluence/display/solr/NegativeQueryProblems

Enjoy.

On Mon, Jan 31, 2022 at 11:54 AM Arun Kumar <d.i.a...@gmail.com> wrote:

> Hi,
>
> I am using solr(v8.10.1) in one of my project and have recently noticed
> that when executing a query with negative term query enclosed in
> parentheses as shown below with q.op as AND it returns 0 results.
>
> *(-title:legend AND -title:Urban) OR releaseYear:[1900 TO 2022]*
>
> When enabling debugQuery I could see that it is running following parsed
> query string
>
> *+(-title:legend -title:urban) +releaseYear:[1900 TO 2022]*
>
> However the same query return results if I do not enclose first two terms
> in parentheses as shown below
>
> *-title:legend AND -title:Urban AND releaseYear:[1900 TO 2022]*
>
> It's parsed query string is
>
> *-title:legend -title:urban +releaseYear:[1900 TO 2022]*
>
> Could you please explain as to why the second query returns results while
> the first does not as I could not find anything in the documentation to
> explain this behavior?
>
> Thanks,
> Arun
>


-- 
Sincerely yours
Mikhail Khludnev

Reply via email to