Package org.apache.lucene.document
Class DocumentStoredFieldVisitor
- java.lang.Object
-
- org.apache.lucene.index.StoredFieldVisitor
-
- org.apache.lucene.document.DocumentStoredFieldVisitor
-
public class DocumentStoredFieldVisitor extends StoredFieldVisitor
AStoredFieldVisitor
that creates aDocument
containing all stored fields, or only specific requested fields provided toDocumentStoredFieldVisitor(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
Constructors Constructor Description DocumentStoredFieldVisitor()
Load 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.Document
getDocument()
Retrieve the visited document.void
intField(FieldInfo fieldInfo, int value)
Process a int numeric field.void
longField(FieldInfo fieldInfo, long value)
Process a long numeric field.StoredFieldVisitor.Status
needsField(FieldInfo fieldInfo)
Hook before processing a field.void
stringField(FieldInfo fieldInfo, String value)
Process a string field
-
-
-
Constructor Detail
-
DocumentStoredFieldVisitor
public DocumentStoredFieldVisitor(Set<String> fieldsToAdd)
Load only fields named in the providedSet<String>
.- Parameters:
fieldsToAdd
- Set of fields to load, ornull
(all fields).
-
DocumentStoredFieldVisitor
public DocumentStoredFieldVisitor(String... fields)
Load only fields named in the provided fields.
-
DocumentStoredFieldVisitor
public DocumentStoredFieldVisitor()
Load all stored fields.
-
-
Method Detail
-
binaryField
public void binaryField(FieldInfo fieldInfo, byte[] value) throws IOException
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
public void stringField(FieldInfo fieldInfo, String value) throws IOException
Description copied from class:StoredFieldVisitor
Process a string field- Overrides:
stringField
in classStoredFieldVisitor
- Throws:
IOException
-
intField
public void intField(FieldInfo fieldInfo, int value)
Description copied from class:StoredFieldVisitor
Process a int numeric field.- Overrides:
intField
in classStoredFieldVisitor
-
longField
public void longField(FieldInfo fieldInfo, long value)
Description copied from class:StoredFieldVisitor
Process a long numeric field.- Overrides:
longField
in classStoredFieldVisitor
-
floatField
public void floatField(FieldInfo fieldInfo, float value)
Description copied from class:StoredFieldVisitor
Process a float numeric field.- Overrides:
floatField
in classStoredFieldVisitor
-
doubleField
public void doubleField(FieldInfo fieldInfo, double value)
Description copied from class:StoredFieldVisitor
Process a double numeric field.- Overrides:
doubleField
in classStoredFieldVisitor
-
needsField
public StoredFieldVisitor.Status needsField(FieldInfo fieldInfo) throws IOException
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
public Document 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.
-
-