public final class Field extends AbstractField implements Fieldable, Serializable
| Modifier and Type | Class and Description |
|---|---|
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.
|
binaryLength, binaryOffset, boost, fieldsData, isBinary, isCompressed, isIndexed, isStored, isTokenized, lazy, name, omitNorms, omitTermFreqAndPositions, storeOffsetWithTermVector, storePositionWithTermVector, storeTermVector, tokenStream| Constructor and Description |
|---|
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.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
setTokenStream(TokenStream tokenStream)
Expert: sets the token stream to be used for indexing and causes isIndexed() and isTokenized() to return true.
|
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)
Deprecated.
|
String |
stringValue()
The value of the field as a String, or null.
|
TokenStream |
tokenStreamValue()
The TokesStream for this field to be used when indexing, or null.
|
getBinaryLength, getBinaryOffset, getBinaryValue, getBinaryValue, getBoost, getOmitNorms, getOmitTermFreqAndPositions, getOmitTf, isBinary, isCompressed, isIndexed, isLazy, isStored, isStoreOffsetWithTermVector, isStorePositionWithTermVector, isTermVectorStored, isTokenized, name, setBoost, setOmitNorms, setOmitTermFreqAndPositions, setOmitTf, setStoreTermVector, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBinaryLength, getBinaryOffset, getBinaryValue, getBinaryValue, getBoost, getOmitNorms, getOmitTf, isBinary, isCompressed, isIndexed, isLazy, isStored, isStoreOffsetWithTermVector, isStorePositionWithTermVector, isTermVectorStored, isTokenized, name, setBoost, setOmitNorms, setOmitTfpublic 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 indexingNullPointerException - if name or value is nullIllegalArgumentException - 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 storedNullPointerException - if name or value is nullIllegalArgumentException - in any of the following situations:
TermVector.YESpublic Field(String name, boolean internName, String value, Field.Store store, Field.Index index, Field.TermVector termVector)
name - The name of the fieldinternName - Whether to .intern() name or notvalue - 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 storedNullPointerException - if name or value is nullIllegalArgumentException - in any of the following situations:
TermVector.YESpublic Field(String name, Reader reader)
IndexWriter.addDocument(Document)
has been called.name - The name of the fieldreader - The reader with the contentNullPointerException - if name or reader is nullpublic 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 storedNullPointerException - if name or reader is nullpublic Field(String name, TokenStream tokenStream)
IndexWriter.addDocument(Document)
has been called.name - The name of the fieldtokenStream - The TokenStream with the contentNullPointerException - if name or tokenStream is nullpublic 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 storedNullPointerException - if name or tokenStream is nullpublic 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.NOpublic 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.NOpublic String stringValue()
stringValue in interface Fieldablepublic Reader readerValue()
readerValue in interface FieldableFieldable.stringValue()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 FieldableFieldable.stringValue()public TokenStream tokenStreamValue()
tokenStreamValue in interface FieldableFieldable.stringValue()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.
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)
setTokenStream(org.apache.lucene.analysis.TokenStream)public void setTokenStream(TokenStream tokenStream)
Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.