lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: How create Query
Date Mon, 07 Nov 2005 13:53:49 GMT

On 7 Nov 2005, at 08:27, Anton Potehin wrote:
> I have two fields in the index called "first" and "second". Is it
> possible to make search using following condition: the "first" field
> must have "car" and the "second" field must have "java" or "sun"?  
> If it
> is possible, please tell me how?

Using QueryParser, this expression would give you the query you desire:

     first:car AND second:(java OR sun)

Using the API, you can construct this query using BooleanQuery with  
two required clauses, the first clause being a TermQuery for car on  
the "first" field, and the second clause being a nested BooleanQuery  
with two optional TermQuery's for java and sun on the "second" field.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message