Hi,

I have a problem when using BooleanQuery with NOT-Operators.

When I want to search my documents for elements where a special field is NOT a 
special value AND another field is a special value, I do the following in my 
code:

Query query1 = ...; // -field1:value1
Query query2=...;  // field2:*value2*

I combine them via a BooleanQuery like this:

BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(query1, Occur.MUST);
booleanQuery.add(query2, Occur.MUST);

This generates a query like this: +(- field1:value1) +field2:*value2*

which does not work because of the brackets around the NOT part. What can I do 
to prevent this?

It could also be possible that query1 is more complex like this:
Query query1 = ...; // -field1:value1 AND field3:value3

which finally leads to:  +(+(- field1:value1) +(field3:value3)) +field2:*value2*

How can I solve this? Maybe there are some special queries or strategies when 
using NOT operators?

Thanks and regards,
Jacqueline.


Reply via email to