Lucene - Field


Advertisements


Introduction

Field is the lowest unit or the starting point of the indexing process. It represents the key value pair relationship where a key is used to identify the value to be indexed. Say a field used to represent contents of a document will have key as "contents" and the value may contain the part or all of the text or numeric content of the document.

Lucene can index only text or numeric contents only.This class represents the storage location of the indexes and generally it is a list of files. These files are called index files. Index files are normally created once and then used for read operation or can be deleted.

Class declaration

Following is the declaration for org.apache.lucene.document.Field class:

public final class Field
   extends AbstractField 
      implements Fieldable, Serializable

Class constructors

S.N.Constructor & Description
1

Field(String name, boolean internName, String value, Field.Store store, Field.Index index, Field.TermVector termVector)

Create a field by specifying its name, value and how it will be saved in the index.

2

Field(String name, byte[] value)

Create a stored field with binary value.

3

Field(String name, byte[] value, Field.Store store)

Deprecated.

4

Field(String name, byte[] value, int offset, int length)

Create a stored field with binary value.

5

Field(String name, byte[] value, int offset, int length, Field.Store store)

Deprecated.

6

Field(String name, Reader reader)

Create a tokenized and indexed field that is not stored.

7

Field(String name, Reader reader, Field.TermVector termVector)

Create a tokenized and indexed field that is not stored, optionally with storing term vectors.

8

Field(String name, String value, Field.Store store, Field.Index index)

Create a field by specifying its name, value and how it will be saved in the index.

9

Field(String name, String value, Field.Store store, Field.Index index, Field.TermVector termVector)

Create a field by specifying its name, value and how it will be saved in the index.

10

Field(String name, TokenStream tokenStream)

Create a tokenized and indexed field that is not stored.

11

Field(String name, TokenStream tokenStream, Field.TermVector termVector)

Create a tokenized and indexed field that is not stored, optionally with storing term vectors.

Class methods

S.N.Method & Description
1

void clearLock(String name)

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

2

Reader readerValue()

The value of the field as a Reader, or null.

3

void setTokenStream(TokenStream tokenStream)

Expert: sets the token stream to be used for indexing and causes isIndexed() and isTokenized() to return true.

4

void setValue(byte[] value)

Expert: change the value of this field.

5

void setValue(byte[] value, int offset, int length)

Expert: change the value of this field.

6

void setValue(Reader value)

Expert: change the value of this field.

7

void setValue(String value)

Expert: change the value of this field.

8

String stringValue()

The value of the field as a String, or null.

9

TokenStream tokenStreamValue()

The TokesStream for this field to be used when indexing, or null.

Methods inherited

This class inherits methods from the following classes:

  • org.apache.lucene.document.AbstractField

  • java.lang.Object


lucene_indexing_classes.htm

Advertisements