FieldInvertState (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.index, class: FieldInvertState

Package org.apache.lucene.index

# Class FieldInvertState

java.lang.Object
org.apache.lucene.index.FieldInvertState

public final class FieldInvertState extends Object
This class tracks the number and position / offset parameters of terms being added to the index. The information collected in this class is also used to calculate the normalization factor for a field.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FieldInvertState(int indexCreatedVersionMajor, String name, IndexOptions indexOptions)`
  Creates {code FieldInvertState} for the specified field name.
  `FieldInvertState(int indexCreatedVersionMajor, String name, IndexOptions indexOptions, int position, int length, int numOverlap, int offset, int maxTermFrequency, int uniqueTermCount)`
  Creates {code FieldInvertState} for the specified field name and values for all fields.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AttributeSource`
  `getAttributeSource()`
  Returns the `AttributeSource` from the `TokenStream` that provided the indexed tokens for this field.
  `int`
  `getIndexCreatedVersionMajor()`
  Return the version that was used to create the index, or 6 if it was created before 7.0.
  `IndexOptions`
  `getIndexOptions()`
  Get the index options for this field
  `int`
  `getLength()`
  Get total number of terms in this field.
  `int`
  `getMaxTermFrequency()`
  Get the maximum term-frequency encountered for any term in the field.
  `String`
  `getName()`
  Return the field's name
  `int`
  `getNumOverlap()`
  Get the number of terms with `positionIncrement == 0`.
  `int`
  `getOffset()`
  Get end offset of the last processed term.
  `int`
  `getPosition()`
  Get the last processed term position.
  `int`
  `getUniqueTermCount()`
  Return the number of unique terms encountered in this field.
  `void`
  `setLength(int length)`
  Set length value.
  `void`
  `setNumOverlap(int numOverlap)`
  Set number of terms with `positionIncrement == 0`.

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FieldInvertState

    public FieldInvertState(int indexCreatedVersionMajor, String name, IndexOptions indexOptions)
    Creates {code FieldInvertState} for the specified field name.

  - ### FieldInvertState

    public FieldInvertState(int indexCreatedVersionMajor, String name, IndexOptions indexOptions, int position, int length, int numOverlap, int offset, int maxTermFrequency, int uniqueTermCount)
    Creates {code FieldInvertState} for the specified field name and values for all fields.

- ## Method Details

  - ### getPosition

    public int getPosition()
    Get the last processed term position.
    Returns:
      the position

  - ### getLength

    public int getLength()
    Get total number of terms in this field.
    Returns:
      the length

  - ### setLength

    public void setLength(int length)
    Set length value.

  - ### getNumOverlap

    public int getNumOverlap()
    Get the number of terms with `positionIncrement == 0`.
    Returns:
      the numOverlap

  - ### setNumOverlap

    public void setNumOverlap(int numOverlap)
    Set number of terms with `positionIncrement == 0`.

  - ### getOffset

    public int getOffset()
    Get end offset of the last processed term.
    Returns:
      the offset

  - ### getMaxTermFrequency

    public int getMaxTermFrequency()
    Get the maximum term-frequency encountered for any term in the field. A field containing "the quick brown fox jumps over the lazy dog" would have a value of 2, because "the" appears twice.

  - ### getUniqueTermCount

    public int getUniqueTermCount()
    Return the number of unique terms encountered in this field.

  - ### getAttributeSource

    public AttributeSource getAttributeSource()
    Returns the `AttributeSource` from the `TokenStream` that provided the indexed tokens for this field.

  - ### getName

    public String getName()
    Return the field's name

  - ### getIndexCreatedVersionMajor

    public int getIndexCreatedVersionMajor()
    Return the version that was used to create the index, or 6 if it was created before 7.0.

  - ### getIndexOptions

    public IndexOptions getIndexOptions()
    Get the index options for this field