Package org.apache.lucene.index

## Class TermVectors

- java.lang.Object
- - org.apache.lucene.index.TermVectors

- Direct Known Subclasses:
    `TermVectorsReader`

      public abstract class TermVectors
      extends Object

  API for reading term vectors.

  NOTE: This class is not thread-safe and should only be consumed in the thread where it was acquired.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static TermVectors` | `EMPTY` | Instance that never returns term vectors

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `TermVectors()` | Sole constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract Fields` | `get​(int doc)` | Returns term vectors for this document, or null if term vectors were not indexed.
    `Terms` | `get​(int doc, String field)` | Retrieve term vector for this document and field, or null if term vectors were not indexed.

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

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

- - ### Field Detail

    - #### EMPTY

          public static final TermVectors EMPTY

      Instance that never returns term vectors

  - ### Constructor Detail

    - #### TermVectors

          protected TermVectors()

      Sole constructor. (For invocation by subclass constructors, typically implicit.)

  - ### Method Detail

    - #### get

          public abstract Fields get​(int doc)
                              throws IOException

      Returns term vectors for this document, or null if term vectors were not indexed.

      The returned Fields instance acts like a single-document inverted index (the docID will be 0). If offsets are available they are in an `OffsetAttribute` available from the `PostingsEnum`.

      Throws:
        `IOException`

    - #### get

          public final Terms get​(int doc,
                                 String field)
                          throws IOException

      Retrieve term vector for this document and field, or null if term vectors were not indexed.

      The returned Terms instance acts like a single-document inverted index (the docID will be 0). If offsets are available they are in an `OffsetAttribute` available from the `PostingsEnum`.

      Throws:
        `IOException`