## org.apache.lucene.search.payloads
Class PayloadTermQuery

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

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable

Direct Known Subclasses:
  BoostingTermQuery

    public class PayloadTermQuery

extends SpanTermQuery

This class is very similar to `SpanTermQuery` except that it factors in the value of the payload located at each of the positions where the `Term` occurs.

In order to take advantage of this, you must override `Similarity.scorePayload(String, byte[],int,int)` which returns 1 by default.

Payload scores are aggregated using a pluggable `PayloadFunction`.

See Also:
  Serialized Form

Nested Class Summary
`protected class` `PayloadTermQuery.PayloadTermWeight`

Field Summary
`protected PayloadFunction` `function`

Fields inherited from class org.apache.lucene.search.spans.SpanTermQuery
`term`

Constructor Summary
`PayloadTermQuery(Term term, PayloadFunction function)`
`PayloadTermQuery(Term term, PayloadFunction function, boolean includeSpanScore)`

Method Summary
`Weight` `createWeight(Searcher searcher)` Expert: Constructs an appropriate Weight implementation for this query.
`boolean` `equals(java.lang.Object obj)`
`int` `hashCode()`

Methods inherited from class org.apache.lucene.search.spans.SpanTermQuery
`extractTerms, getField, getSpans, getTerm, getTerms, toString`

Methods inherited from class org.apache.lucene.search.Query
`clone, combine, getBoost, getSimilarity, mergeBooleanQueries, rewrite, setBoost, toString, weight`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### function

    protected PayloadFunction function

Constructor Detail

### PayloadTermQuery

    public PayloadTermQuery(Term term,
                            PayloadFunction function)

### PayloadTermQuery

    public PayloadTermQuery(Term term,
                            PayloadFunction function,
                            boolean includeSpanScore)

Method Detail

### createWeight

    public Weight createWeight(Searcher searcher)
                        throws java.io.IOException

  Description copied from class: `Query`
  Expert: Constructs an appropriate Weight implementation for this query.

  Only implemented by primitive queries, which re-write to themselves.

  Overrides:
    `createWeight` in class `SpanQuery`
  Throws:
    `java.io.IOException`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `SpanTermQuery`

### equals

    public boolean equals(java.lang.Object obj)

  Overrides:
    `equals` in class `SpanTermQuery`

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