Package org.apache.lucene.document
Class StringField
java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.StringField
- All Implemented Interfaces:
IndexableField
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.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FieldTypeIndexed, not tokenized, omits norms, indexes DOCS_ONLY, not stored.static final FieldTypeIndexed, not tokenized, omits norms, indexes DOCS_ONLY, storedFields inherited from class org.apache.lucene.document.Field
fieldsData, name, type -
Constructor Summary
ConstructorsConstructorDescriptionStringField(String name, String value, Field.Store stored) Creates a new textual StringField, indexing the provided String value as a single token.StringField(String name, BytesRef value, Field.Store stored) Creates a new binary StringField, indexing the provided binary (BytesRef) value as a single token. -
Method Summary
Modifier and TypeMethodDescriptionNon-null if this field has a binary valueDescribes how this field should be inverted.voidsetBytesValue(BytesRef value) Expert: change the value of this field.voidsetStringValue(String value) Expert: change the value of this field.Stored value.Methods inherited from class org.apache.lucene.document.Field
fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setTokenStream, stringValue, tokenStream, tokenStreamValue, toString
-
Field Details
-
TYPE_NOT_STORED
Indexed, not tokenized, omits norms, indexes DOCS_ONLY, not stored. -
TYPE_STORED
Indexed, not tokenized, omits norms, indexes DOCS_ONLY, stored
-
-
Constructor Details
-
StringField
Creates a new textual StringField, indexing the provided String value as a single token.- Parameters:
name- field namevalue- String valuestored- Store.YES if the content should also be stored- Throws:
IllegalArgumentException- if the field name or value is null.
-
StringField
Creates a new binary StringField, indexing the provided binary (BytesRef) value as a single token.- Parameters:
name- field namevalue- 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.
-
-
Method Details
-
invertableType
Description copied from interface:IndexableFieldDescribes how this field should be inverted. This must return a non-null value if the field indexes terms and postings.- Specified by:
invertableTypein interfaceIndexableField- Overrides:
invertableTypein classField
-
binaryValue
Description copied from interface:IndexableFieldNon-null if this field has a binary value- Specified by:
binaryValuein interfaceIndexableField- Overrides:
binaryValuein classField
-
setStringValue
Description copied from class:FieldExpert: change the value of this field. This can be used during indexing to re-use a single Field instance to improve indexing speed by avoiding GC cost of new'ing and reclaiming Field instances. Typically a singleDocumentinstance is re-used as well. This helps most on small documents.Each Field instance should only be used once within a single
Documentinstance. See ImproveIndexingSpeed for details.- Overrides:
setStringValuein classField
-
setBytesValue
Description copied from class:FieldExpert: change the value of this field. SeeField.setStringValue(String).NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.
- Overrides:
setBytesValuein classField
-
storedValue
Description copied from interface:IndexableFieldStored value. This method is called to populate stored fields and must return a non-null value if the field stored.- Specified by:
storedValuein interfaceIndexableField- Overrides:
storedValuein classField
-