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

Package org.apache.lucene.index

# Class FieldInfos

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

All Implemented Interfaces:
  `Iterable<FieldInfo>`

public class FieldInfos extends Object implements Iterable<FieldInfo>
Collection of `FieldInfo`s (accessible by number or by name).

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final FieldInfos`
  `EMPTY`
  An instance without any fields.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FieldInfos(FieldInfo[] infos)`
  Constructs a new FieldInfos from an array of FieldInfo objects.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FieldInfo`
  `fieldInfo(int fieldNumber)`
  Return the fieldinfo object referenced by the fieldNumber.
  `FieldInfo`
  `fieldInfo(String fieldName)`
  Return the fieldinfo object referenced by the field name
  `static Collection<String>`
  `getIndexedFields(IndexReader reader)`
  Returns a set of names of fields that have a terms index.
  `static FieldInfos`
  `getMergedFieldInfos(IndexReader reader)`
  Call this to get the (merged) FieldInfos for a composite reader.
  `String`
  `getParentField()`
  Returns the parent document field name if exists; otherwise returns null
  `String`
  `getSoftDeletesField()`
  Returns the soft-deletes field name if exists; otherwise returns null
  `boolean`
  `hasDocValues()`
  Returns true if any fields have DocValues
  `boolean`
  `hasFreq()`
  Returns true if any fields have freqs
  `boolean`
  `hasNorms()`
  Returns true if any fields have norms
  `boolean`
  `hasOffsets()`
  Returns true if any fields have offsets
  `boolean`
  `hasPayloads()`
  Returns true if any fields have payloads
  `boolean`
  `hasPointValues()`
  Returns true if any fields have PointValues
  `boolean`
  `hasPostings()`
  Returns true if any fields have postings
  `boolean`
  `hasProx()`
  Returns true if any fields have positions
  `boolean`
  `hasTermVectors()`
  Returns true if any fields have term vectors
  `boolean`
  `hasVectorValues()`
  Returns true if any fields have vector values
  `Iterator<FieldInfo>`
  `iterator()`
  Returns an iterator over all the fieldinfo objects present, ordered by ascending field number
  `int`
  `size()`
  Returns the number of fields

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

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

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Field Details

  - ### EMPTY

    public static final FieldInfos EMPTY
    An instance without any fields.

- ## Constructor Details

  - ### FieldInfos

    public FieldInfos(FieldInfo[] infos)
    Constructs a new FieldInfos from an array of FieldInfo objects. The array can be used directly as the backing structure.

- ## Method Details

  - ### getMergedFieldInfos

    public static FieldInfos getMergedFieldInfos(IndexReader reader)
    Call this to get the (merged) FieldInfos for a composite reader.

    NOTE: the returned field numbers will likely not correspond to the actual field numbers in the underlying readers, and codec metadata (`FieldInfo.getAttribute(String)` will be unavailable.

  - ### getIndexedFields

    public static Collection<String> getIndexedFields(IndexReader reader)
    Returns a set of names of fields that have a terms index. The order is undefined.

  - ### hasFreq

    public boolean hasFreq()
    Returns true if any fields have freqs

  - ### hasPostings

    public boolean hasPostings()
    Returns true if any fields have postings

  - ### hasProx

    public boolean hasProx()
    Returns true if any fields have positions

  - ### hasPayloads

    public boolean hasPayloads()
    Returns true if any fields have payloads

  - ### hasOffsets

    public boolean hasOffsets()
    Returns true if any fields have offsets

  - ### hasTermVectors

    public boolean hasTermVectors()
    Returns true if any fields have term vectors

  - ### hasNorms

    public boolean hasNorms()
    Returns true if any fields have norms

  - ### hasDocValues

    public boolean hasDocValues()
    Returns true if any fields have DocValues

  - ### hasPointValues

    public boolean hasPointValues()
    Returns true if any fields have PointValues

  - ### hasVectorValues

    public boolean hasVectorValues()
    Returns true if any fields have vector values

  - ### getSoftDeletesField

    public String getSoftDeletesField()
    Returns the soft-deletes field name if exists; otherwise returns null

  - ### getParentField

    public String getParentField()
    Returns the parent document field name if exists; otherwise returns null

  - ### size

    public int size()
    Returns the number of fields

  - ### iterator

    public Iterator<FieldInfo> iterator()
    Returns an iterator over all the fieldinfo objects present, ordered by ascending field number
    Specified by:
      `iterator` in interface `Iterable<FieldInfo>`

  - ### fieldInfo

    public FieldInfo fieldInfo(String fieldName)
    Return the fieldinfo object referenced by the field name
    Returns:
      the FieldInfo object or null when the given fieldName doesn't exist.

  - ### fieldInfo

    public FieldInfo fieldInfo(int fieldNumber)
    Return the fieldinfo object referenced by the fieldNumber.
    Parameters:
      `fieldNumber` - field's number.
    Returns:
      the FieldInfo object or null when the given fieldNumber doesn't exist.
    Throws:
      `IllegalArgumentException` - if fieldNumber is negative