lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Kim" <p...@cymfony.com>
Subject RE: How to combine multiple fielded queries in Lucene
Date Thu, 27 Oct 2005 15:32:06 GMT
If you're using the QueryParser, you just prefix the field-specific part
with the field. For example, the query in your email should be submitted
to the query parser as:

(Title:"baseball" OR Summary:"white sox") AND Publication_date:"199501
TO 200412"

or if you're creating is programmatically, the constructor to the
TermQuery takes a Term(field_name, search term)

You'll hear this a million times if you're on this mailing list long
enough, but buy Lucene in Action. The time you'll lose without it is far
more costly than the $30 it'll cost to buy the book.

Peter

> -----Original Message-----
> From: Xin Herbert Wu [mailto:xinwu@pathf.com] 
> Sent: Thursday, October 27, 2005 11:25 AM
> To: java-user@lucene.apache.org
> Subject: How to combine multiple fielded queries in Lucene
> 
> I am developing a search application via Lucene and ran into 
> a problem can be described as:
> 
>   Assume we have document schema with these fields:
> 
>   Title, Author, Summary, Publication_date(Date), Content
> 
>   The user query is like this:
> 
>   Find all documents where either Title field has word 
> "baseball" or Summary field has word "white sox" and the 
> Pubblication_date is between Jan. 1995 and Dec. 2004. 
> 
>   In other words, I want the query somewhat like this:
> 
>   (Title = "baseball" OR Summary = "white sox") AND Publication_date =
> "199501 TO 200412"
> 
>  
> 
>   Based on Lucene API, it seems that a basic query is applied 
> on a single document field only, but how can I hook up 
> multiple field queries together with Boolean logic AND or OR 
> as demoed in above example?
> 
>  
> 
> Your help is greatly appreciated!
> 
>  
> 
> -Xin
> 
>  
> 
>  
> 
> 
> 

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


Mime
View raw message