MultiPhraseQuery.Builder (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search, class: MultiPhraseQuery, class: Builder

Package org.apache.lucene.search

# Class MultiPhraseQuery.Builder

java.lang.Object
org.apache.lucene.search.MultiPhraseQuery.Builder

Enclosing class:
  `MultiPhraseQuery`

public static class MultiPhraseQuery.Builder extends Object
A builder for multi-phrase queries

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`
  Default constructor.
  `Builder(MultiPhraseQuery multiPhraseQuery)`
  Copy constructor: this will create a builder that has the same configuration as the provided builder.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MultiPhraseQuery.Builder`
  `add(Term term)`
  Add a single term at the next position in the phrase.
  `MultiPhraseQuery.Builder`
  `add(Term[] terms)`
  Add multiple terms at the next position in the phrase.
  `MultiPhraseQuery.Builder`
  `add(Term[] terms, int position)`
  Allows to specify the relative position of terms within the phrase.
  `MultiPhraseQuery`
  `build()`
  Builds a `MultiPhraseQuery`.
  `MultiPhraseQuery.Builder`
  `setSlop(int s)`
  Sets the phrase slop for this query.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    public Builder()
    Default constructor.

  - ### Builder

    public Builder(MultiPhraseQuery multiPhraseQuery)
    Copy constructor: this will create a builder that has the same configuration as the provided builder.

- ## Method Details

  - ### setSlop

    public MultiPhraseQuery.Builder setSlop(int s)
    Sets the phrase slop for this query.
    See Also:
      - `PhraseQuery.getSlop()`

  - ### add

    public MultiPhraseQuery.Builder add(Term term)
    Add a single term at the next position in the phrase.

  - ### add

    public MultiPhraseQuery.Builder add(Term[] terms)
    Add multiple terms at the next position in the phrase. Any of the terms may match (a disjunction). The array is not copied or mutated, the caller should consider it immutable subsequent to calling this method.

  - ### add

    public MultiPhraseQuery.Builder add(Term[] terms, int position)
    Allows to specify the relative position of terms within the phrase. The array is not copied or mutated, the caller should consider it immutable subsequent to calling this method.

  - ### build

    public MultiPhraseQuery build()
    Builds a `MultiPhraseQuery`.