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

Package org.apache.lucene.queries.payloads

# Class PayloadScoreQuery

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

public class PayloadScoreQuery extends SpanQuery
A Query class that uses a `PayloadFunction` to modify the score of a wrapped `SpanQuery`. A wrapped span query is used due to the way that payload values are indexed, see `PostingsEnum.PAYLOADS`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PayloadScoreQuery(SpanQuery wrappedQuery, PayloadFunction function, PayloadDecoder decoder)`
  Creates a new PayloadScoreQuery that includes the underlying span scores
  `PayloadScoreQuery(SpanQuery wrappedQuery, PayloadFunction function, PayloadDecoder decoder, boolean includeSpanScore)`
  Creates a new PayloadScoreQuery

- ## 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.
  `int`
  `hashCode()`
  `Query`
  `rewrite(IndexSearcher indexSearcher)`
  `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, sameClassAs, toString`

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

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

- ## Constructor Details

  - ### PayloadScoreQuery

    public PayloadScoreQuery(SpanQuery wrappedQuery, PayloadFunction function, PayloadDecoder decoder, boolean includeSpanScore)
    Creates a new PayloadScoreQuery
    Parameters:
      `wrappedQuery` - the query to wrap
      `function` - a PayloadFunction to use to modify the scores
      `decoder` - a PayloadDecoder to convert payloads into float values
      `includeSpanScore` - include both span score and payload score in the scoring algorithm

  - ### PayloadScoreQuery

    public PayloadScoreQuery(SpanQuery wrappedQuery, PayloadFunction function, PayloadDecoder decoder)
    Creates a new PayloadScoreQuery that includes the underlying span scores
    Parameters:
      `wrappedQuery` - the query to wrap
      `function` - a PayloadFunction to use to modify the scores

- ## Method Details

  - ### 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`

  - ### rewrite

    public Query rewrite(IndexSearcher indexSearcher) throws IOException
    Overrides:
      `rewrite` in class `Query`
    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`

  - ### createWeight

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

  - ### equals

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

  - ### hashCode

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