You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Emmanuel Bernard <em...@hibernate.org> on 2010/05/28 16:15:25 UTC

PhraseQuery vs MultiPhraseQuery

Hello,
I am a bit confused by the two.

Is there a fundamental difference between

PhraseQuery query = new PhraseQuery();
query.add(term1, 0);
query.add(term2, 0);

and

MultiPhraseQuery query = new MultiPhraseQuery();
query.add( new Term[] { term1, term2 } );

The only different I could think of is that MPQ somehow does a OR between terms at the same position while PQ does a AND. Am I off base?

Thanks for you help.

Emmanuel


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: PhraseQuery vs MultiPhraseQuery

Posted by Ahmet Arslan <io...@yahoo.com>.

> Is there a fundamental difference between
> 
> PhraseQuery query = new PhraseQuery();
> query.add(term1, 0);
> query.add(term2, 0);
> 
> and
> 
> MultiPhraseQuery query = new MultiPhraseQuery();
> query.add( new Term[] { term1, term2 } );
> 
> The only different I could think of is that MPQ somehow
> does a OR between terms at the same position while PQ does a
> AND. Am I off base?

MPQ can support "(quick OR fast) (cat OR mice OR dog)" type of queries so that these docs are retrieved:

quick rat
fast mice
fast dog

etc.

In your example term1=quick and term2=fast. You need to add another Term array. 
query.add( new Term[] { term1, term2 } );
query.add( new Term[] { term3, term4, term5 } );



      

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org