|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.document.AbstractField
org.apache.lucene.document.Field
public final class Field
A field is a section of a Document. Each field has two parts, a name and a value. Values may be free text, provided as a String or as a Reader, or they may be atomic keywords, which are not further processed. Such keywords may be used to represent dates, urls, etc. Fields are optionally stored in the index, so that they may be returned with hits on the document.
Nested Class Summary | |
---|---|
static class |
Field.Index
Specifies whether and how a field should be indexed. |
static class |
Field.Store
Specifies whether and how a field should be stored. |
static class |
Field.TermVector
Specifies whether and how a field should have term vectors. |
Field Summary |
---|
Fields inherited from class org.apache.lucene.document.AbstractField |
---|
binaryLength, binaryOffset, boost, fieldsData, isBinary, isCompressed, isIndexed, isStored, isTokenized, lazy, name, omitNorms, omitTf, storeOffsetWithTermVector, storePositionWithTermVector, storeTermVector |
Constructor Summary | |
---|---|
Field(String name,
byte[] value,
Field.Store store)
Create a stored field with binary value. |
|
Field(String name,
byte[] value,
int offset,
int length,
Field.Store store)
Create a stored field with binary value. |
|
Field(String name,
Reader reader)
Create a tokenized and indexed field that is not stored. |
|
Field(String name,
Reader reader,
Field.TermVector termVector)
Create a tokenized and indexed field that is not stored, optionally with storing term vectors. |
|
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. |
|
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. |
|
Field(String name,
TokenStream tokenStream)
Create a tokenized and indexed field that is not stored. |
|
Field(String name,
TokenStream tokenStream,
Field.TermVector termVector)
Create a tokenized and indexed field that is not stored, optionally with storing term vectors. |
Method Summary | |
---|---|
byte[] |
binaryValue()
Deprecated. This method must allocate a new byte[] if the AbstractField.getBinaryOffset() is non-zero
or AbstractField.getBinaryLength() is not the
full length of the byte[]. Please use AbstractField.getBinaryValue() instead, which simply
returns the byte[]. |
Reader |
readerValue()
The value of the field as a Reader, or null. |
void |
setValue(byte[] value)
Expert: change the value of this field. |
void |
setValue(byte[] value,
int offset,
int length)
Expert: change the value of this field. |
void |
setValue(Reader value)
Expert: change the value of this field. |
void |
setValue(String value)
Expert: change the value of this field. |
void |
setValue(TokenStream value)
Expert: change the value of this field. |
String |
stringValue()
The value of the field as a String, or null. |
TokenStream |
tokenStreamValue()
The value of the field as a TokesStream, or null. |
Methods inherited from class org.apache.lucene.document.AbstractField |
---|
getBinaryLength, getBinaryOffset, getBinaryValue, getBinaryValue, getBoost, getOmitNorms, getOmitTf, isBinary, isCompressed, isIndexed, isLazy, isStored, isStoreOffsetWithTermVector, isStorePositionWithTermVector, isTermVectorStored, isTokenized, name, setBoost, setOmitNorms, setOmitTf, setStoreTermVector, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.lucene.document.Fieldable |
---|
getBinaryLength, getBinaryOffset, getBinaryValue, getBinaryValue, getBoost, getOmitNorms, getOmitTf, isBinary, isCompressed, isIndexed, isLazy, isStored, isStoreOffsetWithTermVector, isStorePositionWithTermVector, isTermVectorStored, isTokenized, name, setBoost, setOmitNorms, setOmitTf |
Constructor Detail |
---|
public Field(String name, String value, Field.Store store, Field.Index index)
name
- The name of the fieldvalue
- The string to processstore
- Whether value
should be stored in the indexindex
- Whether the field should be indexed, and if so, if it should
be tokenized before indexing
NullPointerException
- if name or value is null
IllegalArgumentException
- if the field is neither stored nor indexedpublic Field(String name, String value, Field.Store store, Field.Index index, Field.TermVector termVector)
name
- The name of the fieldvalue
- The string to processstore
- Whether value
should be stored in the indexindex
- Whether the field should be indexed, and if so, if it should
be tokenized before indexingtermVector
- Whether term vector should be stored
NullPointerException
- if name or value is null
IllegalArgumentException
- in any of the following situations:
TermVector.YES
public Field(String name, Reader reader)
IndexWriter.addDocument(Document)
has been called.
name
- The name of the fieldreader
- The reader with the content
NullPointerException
- if name or reader is null
public Field(String name, Reader reader, Field.TermVector termVector)
IndexWriter.addDocument(Document)
has been called.
name
- The name of the fieldreader
- The reader with the contenttermVector
- Whether term vector should be stored
NullPointerException
- if name or reader is null
public Field(String name, TokenStream tokenStream)
IndexWriter.addDocument(Document)
has been called.
name
- The name of the fieldtokenStream
- The TokenStream with the content
NullPointerException
- if name or tokenStream is null
public Field(String name, TokenStream tokenStream, Field.TermVector termVector)
IndexWriter.addDocument(Document)
has been called.
name
- The name of the fieldtokenStream
- The TokenStream with the contenttermVector
- Whether term vector should be stored
NullPointerException
- if name or tokenStream is null
public Field(String name, byte[] value, Field.Store store)
name
- The name of the fieldvalue
- The binary valuestore
- How value
should be stored (compressed or not)
IllegalArgumentException
- if store is Store.NO
public Field(String name, byte[] value, int offset, int length, Field.Store store)
name
- The name of the fieldvalue
- The binary valueoffset
- Starting offset in value where this Field's bytes arelength
- Number of bytes to use for this Field, starting at offsetstore
- How value
should be stored (compressed or not)
IllegalArgumentException
- if store is Store.NO
Method Detail |
---|
public String stringValue()
stringValue
in interface Fieldable
public Reader readerValue()
readerValue
in interface Fieldable
public byte[] binaryValue()
AbstractField.getBinaryOffset()
is non-zero
or AbstractField.getBinaryLength()
is not the
full length of the byte[]. Please use AbstractField.getBinaryValue()
instead, which simply
returns the byte[].
binaryValue
in interface Fieldable
public TokenStream tokenStreamValue()
tokenStreamValue
in interface Fieldable
public void setValue(String value)
Expert: change the value of this field. This can
be used during indexing to re-use a single Field
instance to improve indexing speed by avoiding GC cost
of new'ing and reclaiming Field instances. Typically
a single Document
instance is re-used as
well. This helps most on small documents.
Note that you should only use this method after the
Field has been consumed (ie, the Document
containing this Field has been added to the index).
Also, each Field instance should only be used once
within a single Document
instance. See ImproveIndexingSpeed
for details.
public void setValue(Reader value)
public void setValue(byte[] value)
public void setValue(byte[] value, int offset, int length)
public void setValue(TokenStream value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |