Lucene++ - a full-featured, c++ search engine
API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions
Lucene::Field Class Reference

`#include <Field.h>`

Inheritance diagram for Lucene::Field:

## Public Member Functions

| Field (const String &name, const String &value, Store store, Index index)
| Create a field by specifying its name, value and how it will be saved in the index. Term vectors will not be stored in the index. More...
| Field (const String &name, const String &value, Store store, Index index, TermVector termVector)
| Create a field by specifying its name, value and how it will be saved in the index. More...
| Field (const String &name, const ReaderPtr &reader)
| Create a tokenized and indexed field that is not stored. Term vectors will not be stored. The Reader is read only when the Document is added to the index, ie. you may not close the Reader until {} has been called. More...
| Field (const String &name, const ReaderPtr &reader, TermVector termVector)
| Create a tokenized and indexed field that is not stored, optionally with storing term vectors. The Reader is read only when the Document is added to the index, ie. you may not close the Reader until IndexWriter#addDocument(Document) has been called. More...
| Field (const String &name, const TokenStreamPtr &tokenStream)
| Create a tokenized and indexed field that is not stored. Term vectors will not be stored. This is useful for pre-analyzed fields. The TokenStream is read only when the Document is added to the index, ie. you may not close the TokenStream until IndexWriter#addDocument(Document) has been called. More...
| Field (const String &name, const TokenStreamPtr &tokenStream, TermVector termVector)
| Create a tokenized and indexed field that is not stored, optionally with storing term vectors. This is useful for pre-analyzed fields. The TokenStream is read only when the Document is added to the index, ie. you may not close the TokenStream until IndexWriter#addDocument(Document) has been called. More...
| Field (const String &name, ByteArray value, Store store)
| Create a stored field with binary value. Optionally the value may be compressed. More...
| Field (const String &name, ByteArray value, int32_t offset, int32_t length, Store store)
| Create a stored field with binary value. Optionally the value may be compressed. More...
virtual | ~Field ()
virtual String | getClassName ()
boost::shared_ptr< Field > | shared_from_this ()
virtual String | stringValue ()
| The value of the field as a String, or null. If null, the Reader value or binary value is used. Exactly one of stringValue(), readerValue(), and getBinaryValue() must be set. More...
virtual ReaderPtr | readerValue ()
| The value of the field as a Reader, or null. If null, the String value or binary value is used. Exactly one of stringValue(), readerValue(), and getBinaryValue() must be set. More...
virtual TokenStreamPtr | tokenStreamValue ()
| The value of the field as a TokesStream, or null. If null, the Reader value or String value is analyzed to produce the indexed tokens. More...
virtual void | setValue (const String &value)
| Change the value of this field. This can be used during indexing to re-use a single Field instance to improve indexing speed. Typically a single Document instance is re-used as well. This helps most on small documents. More...
virtual void | setValue (const ReaderPtr &value)
| Change the value of this field. More...
virtual void | setValue (ByteArray value)
| Change the value of this field. More...
virtual void | setValue (ByteArray value, int32_t offset, int32_t length)
| Change the value of this field. More...
virtual void | setTokenStream (const TokenStreamPtr &tokenStream)
| Sets the token stream to be used for indexing and causes isIndexed() and isTokenized() to return true. May be combined with stored values from stringValue() or getBinaryValue() More...
virtual bool | isStored ()
| True if the value of the field is to be stored in the index for return with search hits. It is an error for this to be true if a field is Reader-valued. More...
virtual bool | isIndexed ()
| True if the value of the field is to be indexed, so that it may be searched on. More...
Public Member Functions inherited from Lucene::AbstractField
virtual | ~AbstractField ()
boost::shared_ptr< AbstractField > | shared_from_this ()
virtual void | setBoost (double boost)
| Sets the boost factor hits on this field. This value will be multiplied into the score of all hits on this this field of this document. More...
virtual double | getBoost ()
| Returns the boost factor for hits for this field. More...
virtual String | name ()
| Returns the name of the field as an interned string. For example "date", "title", "body", ... More...
virtual bool | isStored ()
| True if the value of the field is to be stored in the index for return with search hits. It is an error for this to be true if a field is Reader-valued. More...
virtual bool | isIndexed ()
| True if the value of the field is to be indexed, so that it may be searched on. More...
virtual bool | isTokenized ()
| True if the value of the field should be tokenized as text prior to indexing. Un-tokenized fields are indexed as a single word and may not be Reader-valued. More...
virtual bool | isTermVectorStored ()
| True if the term or terms used to index this field are stored as a term vector, available from IndexReader#getTermFreqVector(int,String). These methods do not provide access to the original content of the field, only to terms used to index it. If the original content must be preserved, use the stored attribute instead. More...
virtual bool | isStoreOffsetWithTermVector ()
| True if terms are stored as term vector together with their offsets (start and end position in source text). More...
virtual bool | isStorePositionWithTermVector ()
| True if terms are stored as term vector together with their token positions. More...
virtual bool | isBinary ()
| True if the value of the field is stored as binary. More...
virtual ByteArray | getBinaryValue ()
| Return the raw byte[] for the binary field. Note that you must also call getBinaryLength and getBinaryOffset to know which range of bytes in this returned array belong to the field. More...
virtual ByteArray | getBinaryValue (ByteArray result)
| Return the raw byte[] for the binary field. Note that you must also call getBinaryLength and getBinaryOffset to know which range of bytes in this returned array belong to the field. More...
virtual int32_t | getBinaryLength ()
| Returns length of byte[] segment that is used as value, if Field is not binary returned value is undefined. More...
virtual int32_t | getBinaryOffset ()
| Returns offset into byte[] segment that is used as value, if Field is not binary returned value is undefined. More...
virtual bool | getOmitNorms ()
| True if norms are omitted for this indexed field. More...
virtual bool | getOmitTermFreqAndPositions ()
virtual void | setOmitNorms (bool omitNorms)
| If set, omit normalization factors associated with this indexed field. This effectively disables indexing boosts and length normalization for this field. More...
virtual void | setOmitTermFreqAndPositions (bool omitTermFreqAndPositions)
| If set, omit term freq, positions and payloads from postings for this field. More...
virtual bool | isLazy ()
| Indicates whether a Field is Lazy or not. The semantics of Lazy loading are such that if a Field is lazily loaded, retrieving it's values via stringValue() or getBinaryValue() is only valid as long as the IndexReader that retrieved the Document is still open. More...
virtual String | toString ()
| Prints a Field for human consumption. More...
Public Member Functions inherited from Lucene::Fieldable
virtual | ~Fieldable ()
Public Member Functions inherited from Lucene::LuceneObject
virtual | ~LuceneObject ()
virtual void | initialize ()
| Called directly after instantiation to create objects that depend on this object being fully constructed. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()
static bool | isStored (Store store)
| Specifies whether and how a field should be stored. More...
static bool | isIndexed (Index index)
| Specifies whether and how a field should be indexed. More...
static bool | isAnalyzed (Index index)
static bool | omitNorms (Index index)
static Field::Index | toIndex (bool indexed, bool analyzed)
| Get the best representation of the index given the flags. More...
static Field::Index | toIndex (bool indexed, bool analyzed, bool omitNorms)
| Get the best representation of the index given the flags. More...
static bool | isStored (TermVector termVector)
| Specifies whether and how a field should have term vectors. More...
static bool | withPositions (TermVector termVector)
static bool | withOffsets (TermVector termVector)
static Field::TermVector | toTermVector (bool stored, bool withOffsets, bool withPositions)
| Get the best representation of the index given the flags. More...
Static Public Member Functions inherited from Lucene::AbstractField
static String | _getClassName ()
Static Public Member Functions inherited from Lucene::Fieldable
static String | _getClassName ()

## Protected Member Functions

void | ConstructField (const String &name, const String &value, Store store, Index index, TermVector termVector)
void | ConstructField (const String &name, const ReaderPtr &reader, TermVector termVector)
void | ConstructField (const String &name, const TokenStreamPtr &tokenStream, TermVector termVector)
void | ConstructField (const String &name, ByteArray value, int32_t offset, int32_t length, Store store)
Protected Member Functions inherited from Lucene::AbstractField
| AbstractField ()
| AbstractField (const String &name, Store store, Index index, TermVector termVector)
void | setStoreTermVector (TermVector termVector)
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Additional Inherited Members

Public Types inherited from Lucene::AbstractField
enum | Store { STORE_YES, STORE_NO }
| Specifies whether and how a field should be stored. More...
enum | Index { INDEX_NO, INDEX_ANALYZED, INDEX_NOT_ANALYZED, INDEX_NOT_ANALYZED_NO_NORMS, INDEX_ANALYZED_NO_NORMS }
| Specifies whether and how a field should be indexed. More...
enum | TermVector { TERM_VECTOR_NO, TERM_VECTOR_YES, TERM_VECTOR_WITH_POSITIONS, TERM_VECTOR_WITH_OFFSETS, TERM_VECTOR_WITH_POSITIONS_OFFSETS }
| Specifies whether and how a field should have term vectors. More...
Protected Attributes inherited from Lucene::AbstractField
String | _name
bool | storeTermVector
bool | storeOffsetWithTermVector
bool | storePositionWithTermVector
bool | _omitNorms
bool | _isStored
bool | _isIndexed
bool | _isTokenized
bool | _isBinary
bool | lazy
bool | omitTermFreqAndPositions
double | boost
FieldsData | fieldsData
TokenStreamPtr | tokenStream
int32_t | binaryLength
int32_t | binaryOffset
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Constructor & Destructor Documentation

## ◆ Field() [1/8]

Lucene::Field::Field | ( | const String & | name,
|  | const String & | value,
|  | Store | store,
|  | Index | index
| ) |  |

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

Parameters

  name | The name of the field
  value | The string to process
  store | Whether value should be stored in the index
  index | Whether the field should be indexed, and if so, if it should be tokenized before indexing

## ◆ Field() [2/8]

Lucene::Field::Field | ( | const String & | name,
|  | const String & | value,
|  | Store | store,
|  | Index | index,
|  | TermVector | termVector
| ) |  |

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

Parameters

  name | The name of the field
  value | The string to process
  store | Whether value should be stored in the index
  index | Whether the field should be indexed, and if so, if it should be tokenized before indexing
  termVector | Whether term vector should be stored

## ◆ Field() [3/8]

Lucene::Field::Field | ( | const String & | name,
|  | const ReaderPtr & | reader
| ) |  |

Create a tokenized and indexed field that is not stored. Term vectors will not be stored. The Reader is read only when the Document is added to the index, ie. you may not close the Reader until {} has been called.

Parameters

  name | The name of the field
  reader | The reader with the content

## ◆ Field() [4/8]

Lucene::Field::Field | ( | const String & | name,
|  | const ReaderPtr & | reader,
|  | TermVector | termVector
| ) |  |

Create a tokenized and indexed field that is not stored, optionally with storing term vectors. The Reader is read only when the Document is added to the index, ie. you may not close the Reader until IndexWriter#addDocument(Document) has been called.

Parameters

  name | The name of the field
  reader | The reader with the content
  termVector | Whether term vector should be stored

## ◆ Field() [5/8]

Lucene::Field::Field | ( | const String & | name,
|  | const TokenStreamPtr & | tokenStream
| ) |  |

Create a tokenized and indexed field that is not stored. Term vectors will not be stored. This is useful for pre-analyzed fields. The TokenStream is read only when the Document is added to the index, ie. you may not close the TokenStream until IndexWriter#addDocument(Document) has been called.

Parameters

  name | The name of the field
  tokenStream | The TokenStream with the content

## ◆ Field() [6/8]

Lucene::Field::Field | ( | const String & | name,
|  | const TokenStreamPtr & | tokenStream,
|  | TermVector | termVector
| ) |  |

Create a tokenized and indexed field that is not stored, optionally with storing term vectors. This is useful for pre-analyzed fields. The TokenStream is read only when the Document is added to the index, ie. you may not close the TokenStream until IndexWriter#addDocument(Document) has been called.

Parameters

  name | The name of the field
  tokenStream | The TokenStream with the content
  termVector | Whether term vector should be stored

## ◆ Field() [7/8]

Lucene::Field::Field | ( | const String & | name,
|  | ByteArray | value,
|  | Store | store
| ) |  |

Create a stored field with binary value. Optionally the value may be compressed.

Parameters

  name | The name of the field
  value | The binary value
  store | How value should be stored (compressed or not)

## ◆ Field() [8/8]

Lucene::Field::Field | ( | const String & | name,
|  | ByteArray | value,
|  | int32_t | offset,
|  | int32_t | length,
|  | Store | store
| ) |  |

Create a stored field with binary value. Optionally the value may be compressed.

Parameters

  name | The name of the field
  value | The binary value
  offset | Starting offset in value where this Field's bytes are
  length | Number of bytes to use for this Field, starting at offset
  store | How value should be stored (compressed or not)

## ◆ ~Field()

virtual Lucene::Field::~Field | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::Field::_getClassName | ( |  | ) |

inline static

## ◆ ConstructField() [1/4]

void Lucene::Field::ConstructField | ( | const String & | name,
|  | ByteArray | value,
|  | int32_t | offset,
|  | int32_t | length,
|  | Store | store
| ) |  |

protected

## ◆ ConstructField() [2/4]

void Lucene::Field::ConstructField | ( | const String & | name,
|  | const ReaderPtr & | reader,
|  | TermVector | termVector
| ) |  |

protected

## ◆ ConstructField() [3/4]

void Lucene::Field::ConstructField | ( | const String & | name,
|  | const String & | value,
|  | Store | store,
|  | Index | index,
|  | TermVector | termVector
| ) |  |

protected

## ◆ ConstructField() [4/4]

void Lucene::Field::ConstructField | ( | const String & | name,
|  | const TokenStreamPtr & | tokenStream,
|  | TermVector | termVector
| ) |  |

protected

## ◆ getClassName()

virtual String Lucene::Field::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::AbstractField.

## ◆ isAnalyzed()

static bool Lucene::Field::isAnalyzed | ( | Index | index | ) |

static

## ◆ isIndexed() [1/2]

virtual bool Lucene::AbstractField::isIndexed

True if the value of the field is to be indexed, so that it may be searched on.

## ◆ isIndexed() [2/2]

static bool Lucene::Field::isIndexed | ( | Index | index | ) |

static

Specifies whether and how a field should be indexed.

## ◆ isStored() [1/3]

virtual bool Lucene::AbstractField::isStored

True if the value of the field is to be stored in the index for return with search hits. It is an error for this to be true if a field is Reader-valued.

## ◆ isStored() [2/3]

static bool Lucene::Field::isStored | ( | Store | store | ) |

static

Specifies whether and how a field should be stored.

## ◆ isStored() [3/3]

static bool Lucene::Field::isStored | ( | TermVector | termVector | ) |

static

Specifies whether and how a field should have term vectors.

## ◆ omitNorms()

static bool Lucene::Field::omitNorms | ( | Index | index | ) |

static

## ◆ readerValue()

virtual ReaderPtr Lucene::Field::readerValue | ( |  | ) |

virtual

The value of the field as a Reader, or null. If null, the String value or binary value is used. Exactly one of stringValue(), readerValue(), and getBinaryValue() must be set.

Implements Lucene::Fieldable.

## ◆ setTokenStream()

virtual void Lucene::Field::setTokenStream | ( | const TokenStreamPtr & | tokenStream | ) |

virtual

Sets the token stream to be used for indexing and causes isIndexed() and isTokenized() to return true. May be combined with stored values from stringValue() or getBinaryValue()

## ◆ setValue() [1/4]

virtual void Lucene::Field::setValue | ( | ByteArray | value | ) |

virtual

Change the value of this field.

## ◆ setValue() [2/4]

virtual void Lucene::Field::setValue | ( | ByteArray | value,
|  | int32_t | offset,
|  | int32_t | length
| ) |  |

virtual

Change the value of this field.

## ◆ setValue() [3/4]

virtual void Lucene::Field::setValue | ( | const ReaderPtr & | value | ) |

virtual

Change the value of this field.

## ◆ setValue() [4/4]

virtual void Lucene::Field::setValue | ( | const String & | value | ) |

virtual

Change the value of this field. This can be used during indexing to re-use a single Field instance to improve indexing speed. 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.

## ◆ shared_from_this()

boost::shared_ptr< Field > Lucene::Field::shared_from_this | ( |  | ) |

inline

## ◆ stringValue()

virtual String Lucene::Field::stringValue | ( |  | ) |

virtual

The value of the field as a String, or null. If null, the Reader value or binary value is used. Exactly one of stringValue(), readerValue(), and getBinaryValue() must be set.

Implements Lucene::Fieldable.

## ◆ toIndex() [1/2]

static Field::Index Lucene::Field::toIndex | ( | bool | indexed,
|  | bool | analyzed
| ) |  |

static

Get the best representation of the index given the flags.

## ◆ toIndex() [2/2]

static Field::Index Lucene::Field::toIndex | ( | bool | indexed,
|  | bool | analyzed,
|  | bool | omitNorms
| ) |  |

static

Get the best representation of the index given the flags.

## ◆ tokenStreamValue()

virtual TokenStreamPtr Lucene::Field::tokenStreamValue | ( |  | ) |

virtual

The value of the field as a TokesStream, or null. If null, the Reader value or String value is analyzed to produce the indexed tokens.

Implements Lucene::Fieldable.

## ◆ toTermVector()

static Field::TermVector Lucene::Field::toTermVector | ( | bool | stored,
|  | bool | withOffsets,
|  | bool | withPositions
| ) |  |

static

Get the best representation of the index given the flags.

## ◆ withOffsets()

static bool Lucene::Field::withOffsets | ( | TermVector | termVector | ) |

static

## ◆ withPositions()

static bool Lucene::Field::withPositions | ( | TermVector | termVector | ) |

static

The documentation for this class was generated from the following file:

- Field.h

clucene.sourceforge.net