FAQ
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

Search Discussions

  • Ahmet Arslan at May 28, 2010 at 8:09 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMay 28, '10 at 2:16p
activeMay 28, '10 at 8:09p
posts2
users2
websitelucene.apache.org

2 users in discussion

Emmanuel Bernard: 1 post Ahmet Arslan: 1 post

People

Translate

site design / logo © 2022 Grokbase