org.apache.lucene.document

## Class FieldType

- java.lang.Object
- - org.apache.lucene.document.FieldType

- All Implemented Interfaces:
    IndexableFieldType

      public class FieldType
      extends Object
      implements IndexableFieldType

  Describes the properties of a field.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FieldType.LegacyNumericType` Deprecated. Please switch to `PointValues` instead

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FieldType()` Create a new FieldType with default properties.
    `FieldType(FieldType ref)` Create a new mutable FieldType with all of the properties from `ref`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkIfFrozen()` Throws an exception if this FieldType is frozen.
    `DocValuesType` | `docValuesType()` DocValues `DocValuesType`: how the field's value will be indexed into docValues.
    `boolean` | `equals(Object obj)`
    `void` | `freeze()` Prevents future changes.
    `int` | `hashCode()`
    `IndexOptions` | `indexOptions()` `IndexOptions`, describing what should be recorded into the inverted index
    `int` | `numericPrecisionStep()` Deprecated. Please switch to `PointValues` instead
    `FieldType.LegacyNumericType` | `numericType()` Deprecated. Please switch to `PointValues` instead
    `boolean` | `omitNorms()` True if normalization values should be omitted for the field.
    `int` | `pointDimensionCount()` If this is positive, the field is indexed as a point.
    `int` | `pointNumBytes()` The number of bytes in each dimension's values.
    `void` | `setDimensions(int dimensionCount, int dimensionNumBytes)` Enables points indexing.
    `void` | `setDocValuesType(DocValuesType type)` Sets the field's DocValuesType
    `void` | `setIndexOptions(IndexOptions value)` Sets the indexing options for the field:
    `void` | `setNumericPrecisionStep(int precisionStep)` Deprecated. Please switch to `PointValues` instead
    `void` | `setNumericType(FieldType.LegacyNumericType type)` Deprecated. Please switch to `PointValues` instead
    `void` | `setOmitNorms(boolean value)` Set to `true` to omit normalization values for the field.
    `void` | `setStored(boolean value)` Set to `true` to store this field.
    `void` | `setStoreTermVectorOffsets(boolean value)` Set to `true` to also store token character offsets into the term vector for this field.
    `void` | `setStoreTermVectorPayloads(boolean value)` Set to `true` to also store token payloads into the term vector for this field.
    `void` | `setStoreTermVectorPositions(boolean value)` Set to `true` to also store token positions into the term vector for this field.
    `void` | `setStoreTermVectors(boolean value)` Set to `true` if this field's indexed form should be also stored into term vectors.
    `void` | `setTokenized(boolean value)` Set to `true` to tokenize this field's contents via the configured `Analyzer`.
    `boolean` | `stored()` True if the field's value should be stored
    `boolean` | `storeTermVectorOffsets()` True if this field's token character offsets should also be stored into term vectors.
    `boolean` | `storeTermVectorPayloads()` True if this field's token payloads should also be stored into the term vectors.
    `boolean` | `storeTermVectorPositions()` True if this field's token positions should also be stored into the term vectors.
    `boolean` | `storeTermVectors()` True if this field's indexed form should be also stored into term vectors.
    `boolean` | `tokenized()` True if this field's value should be analyzed by the `Analyzer`.
    `String` | `toString()` Prints a Field for human consumption.

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FieldType

          public FieldType(FieldType ref)

      Create a new mutable FieldType with all of the properties from `ref`

    - #### FieldType

          public FieldType()

      Create a new FieldType with default properties.

  - ### Method Detail

    - #### checkIfFrozen

          protected void checkIfFrozen()

      Throws an exception if this FieldType is frozen. Subclasses should call this within setters for additional state.

    - #### freeze

          public void freeze()

      Prevents future changes. Note, it is recommended that this is called once the FieldTypes's properties have been set, to prevent unintentional state changes.

    - #### stored

          public boolean stored()

      True if the field's value should be stored

      The default is `false`.

      Specified by:
        `stored` in interface `IndexableFieldType`
      See Also:
        `setStored(boolean)`

    - #### setStored

          public void setStored(boolean value)

      Set to `true` to store this field.
      Parameters:
        `value` - true if this field should be stored.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `stored()`

    - #### tokenized

          public boolean tokenized()

      True if this field's value should be analyzed by the `Analyzer`.

      This has no effect if `IndexableFieldType.indexOptions()` returns IndexOptions.NONE.

      The default is `true`.

      Specified by:
        `tokenized` in interface `IndexableFieldType`
      See Also:
        `setTokenized(boolean)`

    - #### setTokenized

          public void setTokenized(boolean value)

      Set to `true` to tokenize this field's contents via the configured `Analyzer`.
      Parameters:
        `value` - true if this field should be tokenized.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `tokenized()`

    - #### storeTermVectors

          public boolean storeTermVectors()

      True if this field's indexed form should be also stored into term vectors.

      This builds a miniature inverted-index for this field which can be accessed in a document-oriented way from `IndexReader.getTermVector(int,String)`.

      This option is illegal if `IndexableFieldType.indexOptions()` returns IndexOptions.NONE.

      The default is `false`.

      Specified by:
        `storeTermVectors` in interface `IndexableFieldType`
      See Also:
        `setStoreTermVectors(boolean)`

    - #### setStoreTermVectors

          public void setStoreTermVectors(boolean value)

      Set to `true` if this field's indexed form should be also stored into term vectors.
      Parameters:
        `value` - true if this field should store term vectors.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `storeTermVectors()`

    - #### storeTermVectorOffsets

          public boolean storeTermVectorOffsets()

      True if this field's token character offsets should also be stored into term vectors.

      This option is illegal if term vectors are not enabled for the field (`IndexableFieldType.storeTermVectors()` is false)

      The default is `false`.

      Specified by:
        `storeTermVectorOffsets` in interface `IndexableFieldType`
      See Also:
        `setStoreTermVectorOffsets(boolean)`

    - #### setStoreTermVectorOffsets

          public void setStoreTermVectorOffsets(boolean value)

      Set to `true` to also store token character offsets into the term vector for this field.
      Parameters:
        `value` - true if this field should store term vector offsets.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `storeTermVectorOffsets()`

    - #### storeTermVectorPositions

          public boolean storeTermVectorPositions()

      True if this field's token positions should also be stored into the term vectors.

      This option is illegal if term vectors are not enabled for the field (`IndexableFieldType.storeTermVectors()` is false).

      The default is `false`.

      Specified by:
        `storeTermVectorPositions` in interface `IndexableFieldType`
      See Also:
        `setStoreTermVectorPositions(boolean)`

    - #### setStoreTermVectorPositions

          public void setStoreTermVectorPositions(boolean value)

      Set to `true` to also store token positions into the term vector for this field.
      Parameters:
        `value` - true if this field should store term vector positions.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `storeTermVectorPositions()`

    - #### storeTermVectorPayloads

          public boolean storeTermVectorPayloads()

      True if this field's token payloads should also be stored into the term vectors.

      This option is illegal if term vector positions are not enabled for the field (`IndexableFieldType.storeTermVectors()` is false).

      The default is `false`.

      Specified by:
        `storeTermVectorPayloads` in interface `IndexableFieldType`
      See Also:
        `setStoreTermVectorPayloads(boolean)`

    - #### setStoreTermVectorPayloads

          public void setStoreTermVectorPayloads(boolean value)

      Set to `true` to also store token payloads into the term vector for this field.
      Parameters:
        `value` - true if this field should store term vector payloads.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `storeTermVectorPayloads()`

    - #### omitNorms

          public boolean omitNorms()

      True if normalization values should be omitted for the field.

      This saves memory, but at the expense of scoring quality (length normalization will be disabled), and if you omit norms, you cannot use index-time boosts.

      The default is `false`.

      Specified by:
        `omitNorms` in interface `IndexableFieldType`
      See Also:
        `setOmitNorms(boolean)`

    - #### setOmitNorms

          public void setOmitNorms(boolean value)

      Set to `true` to omit normalization values for the field.
      Parameters:
        `value` - true if this field should omit norms.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `omitNorms()`

    - #### indexOptions

          public IndexOptions indexOptions()

      `IndexOptions`, describing what should be recorded into the inverted index

      The default is `IndexOptions.DOCS_AND_FREQS_AND_POSITIONS`.

      Specified by:
        `indexOptions` in interface `IndexableFieldType`
      See Also:
        `setIndexOptions(IndexOptions)`

    - #### setIndexOptions

          public void setIndexOptions(IndexOptions value)

      Sets the indexing options for the field:
      Parameters:
        `value` - indexing options
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `indexOptions()`

    - #### setNumericType

          @Deprecated
          public void setNumericType(FieldType.LegacyNumericType type)

      Deprecated. Please switch to `PointValues` instead
      Specifies the field's numeric type.
      Parameters:
        `type` - numeric type, or null if the field has no numeric type.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `numericType()`

    - #### numericType

          @Deprecated
          public FieldType.LegacyNumericType numericType()

      Deprecated. Please switch to `PointValues` instead
      LegacyNumericType: if non-null then the field's value will be indexed numerically so that `LegacyNumericRangeQuery` can be used at search time.

      The default is `null` (no numeric type)

      See Also:
        `setNumericType(org.apache.lucene.document.FieldType.LegacyNumericType)`

    - #### setNumericPrecisionStep

          @Deprecated
          public void setNumericPrecisionStep(int precisionStep)

      Deprecated. Please switch to `PointValues` instead
      Sets the numeric precision step for the field.
      Parameters:
        `precisionStep` - numeric precision step for the field
      Throws:
        `IllegalArgumentException` - if precisionStep is less than 1.
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `numericPrecisionStep()`

    - #### numericPrecisionStep

          @Deprecated
          public int numericPrecisionStep()

      Deprecated. Please switch to `PointValues` instead
      Precision step for numeric field.

      This has no effect if `numericType()` returns null.

      The default is `LegacyNumericUtils.PRECISION_STEP_DEFAULT`

      See Also:
        `setNumericPrecisionStep(int)`

    - #### setDimensions

          public void setDimensions(int dimensionCount,
                                    int dimensionNumBytes)

      Enables points indexing.

    - #### pointDimensionCount

          public int pointDimensionCount()

      Description copied from interface: `IndexableFieldType`
      If this is positive, the field is indexed as a point.
      Specified by:
        `pointDimensionCount` in interface `IndexableFieldType`

    - #### pointNumBytes

          public int pointNumBytes()

      Description copied from interface: `IndexableFieldType`
      The number of bytes in each dimension's values.
      Specified by:
        `pointNumBytes` in interface `IndexableFieldType`

    - #### toString

          public final String toString()

      Prints a Field for human consumption.
      Overrides:
        `toString` in class `Object`

    - #### docValuesType

          public DocValuesType docValuesType()

      DocValues `DocValuesType`: how the field's value will be indexed into docValues.

      The default is `null` (no docValues)

      Specified by:
        `docValuesType` in interface `IndexableFieldType`
      See Also:
        `setDocValuesType(DocValuesType)`

    - #### setDocValuesType

          public void setDocValuesType(DocValuesType type)

      Sets the field's DocValuesType
      Parameters:
        `type` - DocValues type, or null if no DocValues should be stored.
      Throws:
        `IllegalStateException` - if this FieldType is frozen against future modifications.
      See Also:
        `docValuesType()`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

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