org.apache.lucene.queries.payloads

## Class PayloadScoreQuery

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

- All Implemented Interfaces:
    Cloneable

      public class PayloadScoreQuery
      extends SpanQuery

  A Query class that uses a `PayloadFunction` to modify the score of a wrapped SpanQuery NOTE: In order to take advantage of this with the default scoring implementation (`DefaultSimilarity`), you must override `ClassicSimilarity.scorePayload(int, int, int, BytesRef)`, which returns 1 by default.
  See Also:
    `Similarity.SimScorer.computePayloadFactor(int, int, int, BytesRef)`

- - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SpanWeight` | `createWeight(IndexSearcher searcher, boolean needsScores)`
    `boolean` | `equals(Object o)`
    `String` | `getField()`
    `int` | `hashCode()`
    `String` | `toString(String field)`

    - ### Methods inherited from class org.apache.lucene.search.spans.SpanQuery

      `getTermContexts, getTermContexts, rewrite`

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

      `clone, getBoost, setBoost, toString`

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

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

- - ### Constructor Detail

    - #### PayloadScoreQuery

          public PayloadScoreQuery(SpanQuery wrappedQuery,
                           PayloadFunction function,
                           boolean includeSpanScore)

      Creates a new PayloadScoreQuery
      Parameters:
        `wrappedQuery` - the query to wrap
        `function` - a PayloadFunction to use to modify the scores
        `includeSpanScore` - include both span score and payload score in the scoring algorithm

    - #### PayloadScoreQuery

          public PayloadScoreQuery(SpanQuery wrappedQuery,
                           PayloadFunction function)

      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 Detail

    - #### getField

          public String getField()

      Specified by:
        `getField` in class `SpanQuery`

    - #### toString

          public String toString(String field)

      Specified by:
        `toString` in class `Query`

    - #### createWeight

          public SpanWeight createWeight(IndexSearcher searcher,
                                boolean needsScores)
                                  throws IOException

      Overrides:
        `createWeight` in class `SpanQuery`
      Throws:
        `IOException`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Query`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.