org.apache.lucene.document

## Class StoredField

- java.lang.Object
- - org.apache.lucene.document.Field
  - - org.apache.lucene.document.StoredField

- All Implemented Interfaces:
    IndexableField

      public class StoredField
      extends Field

  A field whose value is stored so that `IndexSearcher.doc(int)` and `IndexReader.document()` will return the field and its value.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.document.Field

      `Field.Store`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FieldType` | `TYPE` Type for a stored-only field.

    - ### Fields inherited from class org.apache.lucene.document.Field

      `fieldsData, name, tokenStream, type`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `StoredField(String name, byte[] value)` Create a stored-only field with the given binary value.
    `` | `StoredField(String name, byte[] value, int offset, int length)` Create a stored-only field with the given binary value.
    `` | `StoredField(String name, BytesRef value)` Create a stored-only field with the given binary value.
    `` | `StoredField(String name, BytesRef bytes, FieldType type)` Expert: allows you to customize the `FieldType`.
    `` | `StoredField(String name, CharSequence value, FieldType type)` Expert: allows you to customize the `FieldType`.
    `` | `StoredField(String name, double value)` Create a stored-only field with the given double value.
    `protected` | `StoredField(String name, FieldType type)` Expert: allows you to customize the `FieldType`.
    `` | `StoredField(String name, float value)` Create a stored-only field with the given float value.
    `` | `StoredField(String name, int value)` Create a stored-only field with the given integer value.
    `` | `StoredField(String name, long value)` Create a stored-only field with the given long value.
    `` | `StoredField(String name, String value)` Create a stored-only field with the given string value.
    `` | `StoredField(String name, String value, FieldType type)` Expert: allows you to customize the `FieldType`.

  - ### Method Summary

    - ### Methods inherited from class org.apache.lucene.document.Field

      `binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue, toString`

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

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

- - ### Field Detail

    - #### TYPE

          public static final FieldType TYPE

      Type for a stored-only field.

  - ### Constructor Detail

    - #### StoredField

          protected StoredField(String name,
                                FieldType type)

      Expert: allows you to customize the `FieldType`.
      Parameters:
        `name` - field name
        `type` - custom `FieldType` for this field
      Throws:
        `IllegalArgumentException` - if the field name or type is null.

    - #### StoredField

          public StoredField(String name,
                             BytesRef bytes,
                             FieldType type)

      Expert: allows you to customize the `FieldType`.

      NOTE: the provided byte[] is not copied so be sure not to change it until you're done with this field.

      Parameters:
        `name` - field name
        `bytes` - byte array pointing to binary content (not copied)
        `type` - custom `FieldType` for this field
      Throws:
        `IllegalArgumentException` - if the field name, value or type is null.

    - #### StoredField

          public StoredField(String name,
                             byte[] value)

      Create a stored-only field with the given binary value.

      NOTE: the provided byte[] is not copied so be sure not to change it until you're done with this field.

      Parameters:
        `name` - field name
        `value` - byte array pointing to binary content (not copied)
      Throws:
        `IllegalArgumentException` - if the field name or value is null.

    - #### StoredField

          public StoredField(String name,
                             byte[] value,
                             int offset,
                             int length)

      Create a stored-only field with the given binary value.

      NOTE: the provided byte[] is not copied so be sure not to change it until you're done with this field.

      Parameters:
        `name` - field name
        `value` - byte array pointing to binary content (not copied)
        `offset` - starting position of the byte array
        `length` - valid length of the byte array
      Throws:
        `IllegalArgumentException` - if the field name or value is null.

    - #### StoredField

          public StoredField(String name,
                             BytesRef value)

      Create a stored-only field with the given binary value.

      NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.

      Parameters:
        `name` - field name
        `value` - BytesRef pointing to binary content (not copied)
      Throws:
        `IllegalArgumentException` - if the field name or value is null.

    - #### StoredField

          public StoredField(String name,
                             String value)

      Create a stored-only field with the given string value.
      Parameters:
        `name` - field name
        `value` - string value
      Throws:
        `IllegalArgumentException` - if the field name or value is null.

    - #### StoredField

          public StoredField(String name,
                             String value,
                             FieldType type)

      Expert: allows you to customize the `FieldType`.
      Parameters:
        `name` - field name
        `value` - string value
        `type` - custom `FieldType` for this field
      Throws:
        `IllegalArgumentException` - if the field name, value or type is null.

    - #### StoredField

          public StoredField(String name,
                             CharSequence value,
                             FieldType type)

      Expert: allows you to customize the `FieldType`.
      Parameters:
        `name` - field name
        `value` - CharSequence value
        `type` - custom `FieldType` for this field
      Throws:
        `IllegalArgumentException` - if the field name, value or type is null.

    - #### StoredField

          public StoredField(String name,
                             int value)

      Create a stored-only field with the given integer value.
      Parameters:
        `name` - field name
        `value` - integer value
      Throws:
        `IllegalArgumentException` - if the field name is null.

    - #### StoredField

          public StoredField(String name,
                             float value)

      Create a stored-only field with the given float value.
      Parameters:
        `name` - field name
        `value` - float value
      Throws:
        `IllegalArgumentException` - if the field name is null.

    - #### StoredField

          public StoredField(String name,
                             long value)

      Create a stored-only field with the given long value.
      Parameters:
        `name` - field name
        `value` - long value
      Throws:
        `IllegalArgumentException` - if the field name is null.

    - #### StoredField

          public StoredField(String name,
                             double value)

      Create a stored-only field with the given double value.
      Parameters:
        `name` - field name
        `value` - double value
      Throws:
        `IllegalArgumentException` - if the field name is null.

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