SpanTermQuery (Lucene 10.5.1 queries API)
Description: declaration: package: org.apache.lucene.queries.spans, class: SpanTermQuery

Package org.apache.lucene.queries.spans

# Class SpanTermQuery

java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.queries.spans.SpanQuery
org.apache.lucene.queries.spans.SpanTermQuery

public class SpanTermQuery extends SpanQuery
Matches spans containing a term. This should not be used for terms that are indexed at position Integer.MAX_VALUE.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `class`
  `SpanTermQuery.SpanTermWeight`
  Creates SpanTermQuery scorer instances

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Term`
  `term`
  `protected final TermStates`
  `termStates`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SpanTermQuery(Term term)`
  Construct a SpanTermQuery matching the named term's spans.
  `SpanTermQuery(Term term, TermStates termStates)`
  Expert: Construct a SpanTermQuery matching the named term's spans, using the provided TermStates

- ## Method Summary

  Modifier and Type
  Method
  Description
  `SpanWeight`
  `createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)`
  `boolean`
  `equals(Object other)`
  `String`
  `getField()`
  Returns the name of the field matched by this query.
  `Term`
  `getTerm()`
  Return the term whose spans are matched.
  `TermStates`
  `getTermStates()`
  Returns the `TermStates` passed to the constructor, or null if it was not passed.
  `int`
  `hashCode()`
  `String`
  `toString(String field)`
  `void`
  `visit(QueryVisitor visitor)`

  ### Methods inherited from class org.apache.lucene.queries.spans.SpanQuery

  `getTermStates, getTermStates`

  ### Methods inherited from class org.apache.lucene.search.Query

  `classHash, rewrite, sameClassAs, toString`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### term

    protected final Term term

  - ### termStates

    protected final TermStates termStates

- ## Constructor Details

  - ### SpanTermQuery

    public SpanTermQuery(Term term)
    Construct a SpanTermQuery matching the named term's spans.

  - ### SpanTermQuery

    public SpanTermQuery(Term term, TermStates termStates)
    Expert: Construct a SpanTermQuery matching the named term's spans, using the provided TermStates

- ## Method Details

  - ### getTerm

    public Term getTerm()
    Return the term whose spans are matched.

  - ### getTermStates

    public TermStates getTermStates()
    Returns the `TermStates` passed to the constructor, or null if it was not passed.
    WARNING: This API is experimental and might change in incompatible ways in the next release.

  - ### getField

    public String getField()
    Description copied from class: `SpanQuery`
    Returns the name of the field matched by this query.
    Specified by:
      `getField` in class `SpanQuery`

  - ### createWeight

    public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
    Specified by:
      `createWeight` in class `SpanQuery`
    Throws:
      `IOException`

  - ### visit

    public void visit(QueryVisitor visitor)
    Specified by:
      `visit` in class `Query`

  - ### toString

    public String toString(String field)
    Specified by:
      `toString` in class `Query`

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in class `Query`

  - ### equals

    public boolean equals(Object other)
    Specified by:
      `equals` in class `Query`