cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Query using NOT

venkat
Champ in-the-making
Champ in-the-making
Hi all,

    I wrote a lucene query that searches for contents with attribute name containing "One" and not containing "Two" as:

    query = "+@cm\\:name:\"One\" -@cm\\:name:\"Two\"";

This works well. Now if I want to just search for contents not containing "Two", I assumed the query would like

   query = "-@cm\\:name:\"Two\"";    But it does not work. I modified the

query as:   query = "+@cm\\:name:\"*\"* -@cm\\:name:\"Two\""; and it seems working.

   I am not sure why the previous query is not working. Please shed some light on this.

Thanks,
Venkat
1 REPLY 1

andy
Champ on-the-rise
Champ on-the-rise
Hi

Lucene internally does not support a query that is just NOT in its query parser. It annoys me too! It is on my list of things to look at in more detail.

Andy