lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Diviacco <patrick.divia...@gmail.com>
Subject Re: Building a query of single terms...
Date Tue, 22 Mar 2011 13:37:33 GMT
all right. I still have one last question. If I pass a new QueryParser to
booleanQuery.add method, am I actually passing multiple single terms or it
is the same than just passing the string ?

See example below, please...

booleanQuery.add(new QueryParser(org.apache.lucene.util.Version.LUCENE_40,
"title", new
WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)).parse("my
multiple terms"), BooleanClause.Occur.SHOULD);




On 22 March 2011 14:18, Erick Erickson <erickerickson@gmail.com> wrote:

> The easiest way to figure out this kind of thing is to print out the
> toString() on the queries after they're assembled. I believe you'll
> find that the difference is that the PhraseQuery would find text like
> "Term1 Term2 Term3" but not text like "Term1 some stuff Term2 more
> stuff Term3" whereas BooleanQuery would.
>
> Best
> Erick
>
> On Mon, Mar 21, 2011 at 1:43 PM, Patrick Diviacco
> <patrick.diviacco@gmail.com> wrote:
> > I'm new to Lucene and I would like to know what's the difference (if
> there
> > is any) between
> >
> > PhraseQuery.add(Term1)
> > PhraseQuery.add(Term2)
> > PhraseQuery.add(Term3)
> >
> > and
> >
> > term1 = new TermQuery(new Term(...));
> > booleanQuery.add(term1, BooleanClause.Occur.SHOULD);
> >
> > term2 = new TermQuery(new Term(...));
> > booleanQuery.add(term2, BooleanClause.Occur.SHOULD);
> >
> > thanks
> >
>
> ---------------------------------------------------------------------
> 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