Lucene - Document



Document represents a virtual document with Fields where Field is an object which can contain the physical document's contents, its meta data and so on. Analyzer can understand a Document only.

Class Declaration

Following is the declaration for org.apache.lucene.document.Document class −

public final class Document
   extends Object
      implements Serializable

Class Constructors

Following tables shows a class constructor −

S.No. Constructor & Description
1

Document()

Constructs a new document with no fields.

Class Methods

Following table shows the different class methods −

S.No. Method & Description
1

void clearLock(String name)

Attempt to clear (forcefully unlock and remove) the specified lock.

2

void add(Fieldable field)

Adds a field to a document.

3

String get(String name)

Returns the string value of the field with the given name if any in this document, or null.

4

byte[] getBinaryValue(String name)

Returns an array of bytes for the first (or only) field that has the name specified as the method parameter.

5

byte[][] getBinaryValues(String name)

Returns an array of byte arrays for the fields that have the name specified as the method parameter.

6

float getBoost()

Returns, at indexing time, the boost factor as set by setBoost(float).

7

Field getField(String name)

Deprecated. Use getFieldable(java.lang.String) instead and cast depending on data type.

8

Fieldable getFieldable(String name)

Returns a field with the given name if any exist in this document, or null.

9

Fieldable[] getFieldables(String name)

Returns an array of Fieldables with the given name.

10

List<Fieldable> getFields()

Returns a List of all the fields in a document.

11

Field[] getFields(String name)

Deprecated. Use getFieldable(java.lang.String) instead and cast depending on data type.

12

String[] getValues(String name)

Returns an array of values of the field specified as the method parameter.

13

void removeField(String name)

Removes field with the specified name from the document.

14

void removeFields(String name)

Removes all fields with the given name from the document.

15

void setBoost(float boost)

Sets a boost factor for hits on any field of this document.

16

String toString()

Prints the fields of a document for human consumption.

Methods Inherited

This class inherits methods from the following classes −

  • java.lang.Object
lucene_indexing_classes.htm
Advertisements