PayloadAttribute (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.analysis.tokenattributes, interface: PayloadAttribute

Package org.apache.lucene.analysis.tokenattributes

# Interface PayloadAttribute

All Superinterfaces:
  `Attribute`

All Known Implementing Classes:
  `PayloadAttributeImpl`

public interface PayloadAttribute extends Attribute
The payload of a Token.

The payload is stored in the index at each position, and can be used to influence scoring when using Payload-based queries.

NOTE: because the payload will be stored at each position, it's usually best to use the minimum number of bytes necessary. Some codec implementations may optimize payload storage when all payloads have the same length.

See Also:
  - `PostingsEnum`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BytesRef`
  `getPayload()`
  Returns this Token's payload.
  `void`
  `setPayload(BytesRef payload)`
  Sets this Token's payload.

- ## Method Details

  - ### getPayload

    BytesRef getPayload()
    Returns this Token's payload.
    See Also:
      - `setPayload(BytesRef)`

  - ### setPayload

    void setPayload(BytesRef payload)
    Sets this Token's payload.
    See Also:
      - `getPayload()`