Java Mailing List Archive

http://www.java2.5341.com/

Home » java-user.lucene »

RE: Search question (newbie)

John Griffin

2008-07-03

Replies: Find Java Web Hosting

Author LoginPost Reply
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@(protected)]
Sent: Thursday, July 03, 2008 7:39 AM
To: java-user@(protected)
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@(protected)
For additional commands, e-mail: java-user-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.