Class StringField

  • All Implemented Interfaces:
    IndexableField

    public final class StringField
    extends Field
    A field that is indexed but not tokenized: the entire String value is indexed as a single token. For example this might be used for a 'country' field or an 'id' field. If you also need to sort on this field, separately add a SortedDocValuesField to your document.
    • Field Detail

      • TYPE_NOT_STORED

        public static final FieldType TYPE_NOT_STORED
        Indexed, not tokenized, omits norms, indexes DOCS_ONLY, not stored.
      • TYPE_STORED

        public static final FieldType TYPE_STORED
        Indexed, not tokenized, omits norms, indexes DOCS_ONLY, stored
    • Constructor Detail

      • StringField

        public StringField​(String name,
                           String value,
                           Field.Store stored)
        Creates a new textual StringField, indexing the provided String value as a single token.
        Parameters:
        name - field name
        value - String value
        stored - Store.YES if the content should also be stored
        Throws:
        IllegalArgumentException - if the field name or value is null.
      • StringField

        public StringField​(String name,
                           BytesRef value,
                           Field.Store stored)
        Creates a new binary StringField, indexing the provided binary (BytesRef) value as a single token.
        Parameters:
        name - field name
        value - BytesRef value. The provided value is not cloned so you must not change it until the document(s) holding it have been indexed.
        stored - Store.YES if the content should also be stored
        Throws:
        IllegalArgumentException - if the field name or value is null.