Documentation of 'org.apache.lucene.search.MultiPhraseQuery' Java class
MultiPhraseQuery
org.apache.lucene.search

Class MultiPhraseQuery

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class MultiPhraseQuery
    extends Query
    MultiPhraseQuery is a generalized version of PhraseQuery, with an added method add(Term[]). To use this class, to search for the phrase "Microsoft app*" first use add(Term) on the term "Microsoft", then find all terms that have "app" as prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[] terms) to add them to the query.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      MultiPhraseQuery() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void add(Term term)
      Add a single term at the next position in the phrase.
      void add(Term[] terms)
      Add multiple terms at the next position in the phrase.
      void add(Term[] terms, int position)
      Allows to specify the relative position of terms within the phrase.
      boolean equals(java.lang.Object o)
      Returns true if o is equal to this.
      void extractTerms(java.util.Set terms)
      Expert: adds all terms occuring in this query to the terms set.
      int[] getPositions()
      Returns the relative positions of terms in this phrase.
      int getSlop()
      Sets the phrase slop for this query.
      java.util.List getTermArrays()
      Returns a List of the terms in the multiphrase.
      int hashCode()
      Returns a hash code value for this object.
      Query rewrite(IndexReader reader)
      Expert: called to re-write queries into primitive queries.
      void setSlop(int s)
      Sets the phrase slop for this query.
      java.lang.String toString(java.lang.String f)
      Prints a user-readable version of this query.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MultiPhraseQuery

        public MultiPhraseQuery()
    • Method Detail

      • add

        public void add(Term[] terms)
        Add multiple terms at the next position in the phrase. Any of the terms may match.
        See Also:
        PhraseQuery.add(Term)
      • add

        public void add(Term[] terms,
                        int position)
        Allows to specify the relative position of terms within the phrase.
        Parameters:
        terms -
        position -
        See Also:
        PhraseQuery.add(Term, int)
      • getTermArrays

        public java.util.List getTermArrays()
        Returns a List of the terms in the multiphrase. Do not modify the List or its contents.
      • getPositions

        public int[] getPositions()
        Returns the relative positions of terms in this phrase.
      • extractTerms

        public void extractTerms(java.util.Set terms)
        Description copied from class: Query
        Expert: adds all terms occuring in this query to the terms set. Only works if this query is in its rewritten form.
        Overrides:
        extractTerms in class Query
      • rewrite

        public Query rewrite(IndexReader reader)
        Description copied from class: Query
        Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
        Overrides:
        rewrite in class Query
      • toString

        public final java.lang.String toString(java.lang.String f)
        Prints a user-readable version of this query.
        Specified by:
        toString in class Query
      • equals

        public boolean equals(java.lang.Object o)
        Returns true if o is equal to this.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Returns a hash code value for this object.
        Overrides:
        hashCode in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.