lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Askar Zaidi" <askar.za...@gmail.com>
Subject Re: Assembling a query from multiple fields
Date Thu, 26 Jul 2007 13:14:38 GMT
I did this yesterday. Manually appended an extra field to the query. It
works fine.

On 7/26/07, Erik Hatcher <erik@ehatchersolutions.com> wrote:
>
>
> On Jul 25, 2007, at 5:05 PM, Joe Attardi wrote:
> > As far as I can tell, I basically have two options:
> > (1) Manually prepend the field identifier to the query text, for
> > example:
> >          String fullQuery = field + ":" + queryText;
> >     then parse this query normally with QueryParser, OR
> > (2) Since I know it is only going to be searching one term,
> > manually create
> > a TermQuery with a Term object representing what the user typed in,
> > for
> > example:
> >          Query query = new TermQuery(new Term(field, queryText));
> >
> > Is there any advantage or disadvantage to any of these, or is one
> > preferable
> > over the other? My gut tells me that directly creating the
> > TermQuery is more
> > efficient since it doesn't have to perform parsing, but I'm not sure.
>
> I recommend constructing the Query manually whenever possible to
> avoid the possibility of QueryParser escaping or other syntax getting
> in the way.  The only note to that is to be sure that the terms you
> pass to things like TermQuery are in the same state as they got
> indexed (lowercased, stemmed, whatever).  You can manually run
> through an Analyzer if you need to get the terms normalized in some
> fashion.
>
>         Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message