Lucene Query using NOT
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2007 07:49 PM
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
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
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2007 06:58 AM
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
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
