lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Griffin" <jgrif...@thebluezone.net>
Subject RE: Search question (newbie)
Date Thu, 03 Jul 2008 21:43:19 GMT
Chris,

I've had similar requirements in the past. First strip the quotes then
create a BooleanQuery consisting of two separate queries.

1. TermQuery for the first term - Fred
2. PrefixQuery for the second term - Flintstone

When you add each individual query to the BooleanQuery make sure the
BooleanClause.Occur parameter is set to MUST (look at the BooleanQuery API
docs). 

Use the toString() method on the BooleanQuery after it's created to make
sure you did it correctly.

John G.

-----Original Message-----
From: Chris Bamford [mailto:chris.bamford@scalix.com] 
Sent: Thursday, July 03, 2008 7:39 AM
To: java-user@lucene.apache.org
Subject: Search question (newbie)

Hi,

Can someone point me in the right direction please?
How can I trap this situation correctly?  I receive user queries like 
this (quotes included):

    /from:"fred flintston*"/

Which produces a query string of

    /+from:fred  body:flintston/       (where /body/ is the default field)

What I want is:

/    +from:fred +from:flintston*/

In other words, I want quoted expressions to be treated as single units..
Thanks for any pointers,

- Chris



---------------------------------------------------------------------
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