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 containing all stored fields, or only specific
requested fields provided to DocumentStoredFieldVisitor(Set).
This is used by IndexReader.document(int) to load a
document.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.StoredFieldVisitor
StoredFieldVisitor.Status -
Constructor Summary
ConstructorsConstructorDescriptionLoad 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 TypeMethodDescriptionvoidbinaryField(FieldInfo fieldInfo, byte[] value) Process a binary field.voiddoubleField(FieldInfo fieldInfo, double value) Process a double numeric field.voidfloatField(FieldInfo fieldInfo, float value) Process a float numeric field.Retrieve the visited document.voidProcess a int numeric field.voidProcess a long numeric field.needsField(FieldInfo fieldInfo) Hook before processing a field.voidstringField(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:StoredFieldVisitorProcess a binary field.- Overrides:
binaryFieldin classStoredFieldVisitorvalue- newly allocated byte array with the binary contents.- Throws:
IOException
-
stringField
Description copied from class:StoredFieldVisitorProcess a string field- Overrides:
stringFieldin classStoredFieldVisitor- Throws:
IOException
-
intField
Description copied from class:StoredFieldVisitorProcess a int numeric field.- Overrides:
intFieldin classStoredFieldVisitor
-
longField
Description copied from class:StoredFieldVisitorProcess a long numeric field.- Overrides:
longFieldin classStoredFieldVisitor
-
floatField
Description copied from class:StoredFieldVisitorProcess a float numeric field.- Overrides:
floatFieldin classStoredFieldVisitor
-
doubleField
Description copied from class:StoredFieldVisitorProcess a double numeric field.- Overrides:
doubleFieldin classStoredFieldVisitor
-
needsField
Description copied from class:StoredFieldVisitorHook before processing a field. Before a field is processed, this method is invoked so that subclasses can return aStoredFieldVisitor.Statusrepresenting whether they need that particular field or not, or to stop processing entirely.- Specified by:
needsFieldin 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 boosts, indexing options, term vector options, etc is not set.
-