It is simply: A OR B
(or just A B
)
This will generate two BooleanClause
s with Occur.SHOULD
. In this case, at least one clause has to match for the whole BooleanQuery
to match:
/** Use this operator for clauses that <i>should</i> appear in the
* matching documents. For a BooleanQuery with no <code>MUST</code>
* clauses one or more <code>SHOULD</code> clauses must match a document
* for the BooleanQuery to match.
* @see BooleanQuery#setMinimumNumberShouldMatch
*/
SHOULD { @Override public String toString() { return ""; } },
Answer to the updated question:
(A OR B) AND C
should do what you want.
I'm not really sure about +(A OR B) +C
since it looks like it should work but you stated that +(A OR B)
doesn't work like you expect it to in your original question.
To make sure, you can take a look at what QueryParser
generates. You'd need this kind of query structure:
BooleanQuery
- Must:
BooleanQuery
- Should:
TermQuery
: A
- Should:
TermQuery
: B
- Must:
TermQuery
: C