You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Preston Price <pr...@strands.com> on 2008/05/01 00:25:49 UTC

Simple query API question

This should be a pretty easy question to answer but I haven't been  
able to figure out how to do this with the API.

I want to search two fields in my index; field 1 is and ID, field 2 is  
a date of the form yyyymmdd.
Now I can write a query string by hand to do a search like this on  
both fields: "field1:(x or y or z) AND field2:[20080400 TO 20080500]"
But I don't see how to generate an equivalent query using the API.

Thanks in advance!

Preston Price
price@strands.com


Re: Simple query API question

Posted by Mark Miller <ma...@gmail.com>.
When using the API you will create a Term object that specifies the
field for each term...so visually its more like field1:x or field1:y or
field1:z
and then a rangequery set to field2, all joined using the BooleanQuery
object setting Occur.must Occur.should Occur.mustnot.

Take a look at the range of classes that extend Query. Start with
TermQuery and BooleanQuery.

- mark

On Wed, 2008-04-30 at 16:25 -0600, Preston Price wrote:
> This should be a pretty easy question to answer but I haven't been  
> able to figure out how to do this with the API.
> 
> I want to search two fields in my index; field 1 is and ID, field 2 is  
> a date of the form yyyymmdd.
> Now I can write a query string by hand to do a search like this on  
> both fields: "field1:(x or y or z) AND field2:[20080400 TO 20080500]"
> But I don't see how to generate an equivalent query using the API.
> 
> Thanks in advance!
> 
> Preston Price
> price@strands.com
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org