Package org.apache.lucene.document
Class DocumentStoredFieldVisitor
java.lang.Object
org.apache.lucene.index.StoredFieldVisitor
org.apache.lucene.document.DocumentStoredFieldVisitor
A
StoredFieldVisitor
that creates a Document
from stored fields.
This visitor supports loading all stored fields, or only specific requested fields provided
from a Set
.
This is used by IndexReader.document(int)
to load a document.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.StoredFieldVisitor
StoredFieldVisitor.Status
-
Constructor Summary
ConstructorDescriptionLoad all stored fields.DocumentStoredFieldVisitor
(String... fields) Load only fields named in the provided fields.DocumentStoredFieldVisitor
(Set<String> fieldsToAdd) Load only fields named in the providedSet<String>
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
binaryField
(FieldInfo fieldInfo, byte[] value) Process a binary field.void
doubleField
(FieldInfo fieldInfo, double value) Process a double numeric field.void
floatField
(FieldInfo fieldInfo, float value) Process a float numeric field.Retrieve the visited document.void
Process a int numeric field.void
Process a long numeric field.needsField
(FieldInfo fieldInfo) Hook before processing a field.void
stringField
(FieldInfo fieldInfo, String value) Process a string field.
-
Constructor Details
-
DocumentStoredFieldVisitor
Load only fields named in the providedSet<String>
.- Parameters:
fieldsToAdd
- Set of fields to load, ornull
(all fields).
-
DocumentStoredFieldVisitor
Load only fields named in the provided fields. -
DocumentStoredFieldVisitor
public DocumentStoredFieldVisitor()Load all stored fields.
-
-
Method Details
-
binaryField
Description copied from class:StoredFieldVisitor
Process a binary field.- Overrides:
binaryField
in classStoredFieldVisitor
value
- newly allocated byte array with the binary contents.- Throws:
IOException
-
stringField
Description copied from class:StoredFieldVisitor
Process a string field.- Overrides:
stringField
in classStoredFieldVisitor
- Throws:
IOException
-
intField
Description copied from class:StoredFieldVisitor
Process a int numeric field.- Overrides:
intField
in classStoredFieldVisitor
-
longField
Description copied from class:StoredFieldVisitor
Process a long numeric field.- Overrides:
longField
in classStoredFieldVisitor
-
floatField
Description copied from class:StoredFieldVisitor
Process a float numeric field.- Overrides:
floatField
in classStoredFieldVisitor
-
doubleField
Description copied from class:StoredFieldVisitor
Process a double numeric field.- Overrides:
doubleField
in classStoredFieldVisitor
-
needsField
Description copied from class:StoredFieldVisitor
Hook before processing a field. Before a field is processed, this method is invoked so that subclasses can return aStoredFieldVisitor.Status
representing whether they need that particular field or not, or to stop processing entirely.- Specified by:
needsField
in classStoredFieldVisitor
- Throws:
IOException
-
getDocument
Retrieve the visited document.- Returns:
Document
populated with stored fields. Note that only the stored information in the field instances is valid, data such as indexing options, term vector options, etc is not set.
-