SQL IN operator behaves as OR operator. So as Occur.SHOULD does. It will match
document only if _one or more_ of the child queries match.
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term("accountId", "1")), Occur.SHOULD);
query.add(new TermQuery(new Term("accountId", "2")), Occur.SHOULD);
query.add(new TermQuery(new Term("accountId", "3")), Occur.SHOULD);
On Jun 21, 2011, at 11:01 AM, Hiller, Dean x66079 wrote:
> But the issue is that it MUST be 1, OR MUST be 2 so does that still work?
>
> Also, how do you write that in the query syntax?
>
> Thanks,
> Dean
>
> -----Original Message-----
> From: Denis Bazhenov [mailto:[email protected]]
> Sent: Monday, June 20, 2011 5:50 PM
> To: [email protected]
> Subject: Re: how to do something like sql in () clause
>
> You could use BooleanQuery with Occur.SHOULD quantificator
>
> http://lucene.apache.org/java/3_0_3/api/core/org/apache/lucene/search/BooleanClause.Occur.html#SHOULD
>
> On Jun 21, 2011, at 9:24 AM, Hiller, Dean x66079 wrote:
>
>> I need to do something like a lucene query with
>>
>> Where accountId in ( 1, 2, 3, 4)
>>
>> Is there a way to do that in Lucene Query language?
>>
>> Thanks,
>> Dean
>>
>> This message and any attachments are intended only for the use of the
>> addressee and
>> may contain information that is privileged and confidential. If the reader
>> of the
>> message is not the intended recipient or an authorized representative of the
>> intended recipient, you are hereby notified that any dissemination of this
>> communication is strictly prohibited. If you have received this
>> communication in
>> error, please notify us immediately by e-mail and delete the message and any
>> attachments from your system.
>>
>
> ---
> Denis Bazhenov <[email protected]>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
> This message and any attachments are intended only for the use of the
> addressee and
> may contain information that is privileged and confidential. If the reader of
> the
> message is not the intended recipient or an authorized representative of the
> intended recipient, you are hereby notified that any dissemination of this
> communication is strictly prohibited. If you have received this communication
> in
> error, please notify us immediately by e-mail and delete the message and any
> attachments from your system.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---
Denis Bazhenov <[email protected]>