Class PhraseQuery.Builder

java.lang.Object
org.apache.lucene.search.PhraseQuery.Builder
Enclosing class:
PhraseQuery

public static class PhraseQuery.Builder extends Object
A builder for phrase queries.
  • Constructor Details

    • Builder

      public Builder()
      Sole constructor.
  • Method Details

    • setSlop

      public PhraseQuery.Builder setSlop(int slop)
      Set the slop.
      See Also:
    • add

      public PhraseQuery.Builder add(Term term)
      Adds a term to the end of the query phrase. The relative position of the term is the one immediately after the last term added.
    • add

      public PhraseQuery.Builder add(Term term, int position)
      Adds a term to the end of the query phrase. The relative position of the term within the phrase is specified explicitly, but must be greater than or equal to that of the previously added term. A greater position allows phrases with gaps (e.g. in connection with stopwords). If the position is equal, you most likely should be using MultiPhraseQuery instead which only requires one term at each position to match; this class requires all of them.
    • build

      public PhraseQuery build()
      Build a phrase query based on the terms that have been added.