Chris, Yes, when there are multiple types of queries involved (Term & Wildcard in this case) that's how I handle it. A disadvantage of this is that the user input must be somewhat restricted since you need to know what's coming.
An important thing to remember is that Wildcard, Prefix and one other I can't remember at the moment (sorry :>() are not passed through an analyzer. So, the QueryParser's analyzer has no effect on them. John G. -----Original Message----- From: Chris Bamford [mailto:[EMAIL PROTECTED] Sent: Friday, July 04, 2008 6:10 AM To: java-user@lucene.apache.org Subject: Re: Search question (newbie) John, Thanks, I think I'm getting this now.... So you created your own BooleanQuery and parsed the string yourself, adding strings as TermQuerys etc., rather than using a QueryParser ? Cheers, - Chris John Griffin wrote: > 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:[EMAIL PROTECTED] > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- ------------------------------------------------------------------------ *Chris Bamford* Senior Development Engineer <http://www.scalix.com> ------------------------------------------------------------------------ /Email / MSN/ [EMAIL PROTECTED] /Tel/ +44 (0)1344 381814 /Skype/ c.bamford --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]