CLucene - a full-featured, c++ search engine
API Documentation
A field is a section of a Document. More...
#include <Field.h>
Public Types | |
| enum | Store { STORE_YES = 1, STORE_NO = 2, STORE_COMPRESS = 4 } |
| enum | Index { INDEX_NO = 16, INDEX_TOKENIZED = 32, INDEX_UNTOKENIZED = 64, INDEX_NONORMS = 128 } |
| enum | TermVector { TERMVECTOR_NO = 256, TERMVECTOR_YES = 512, TERMVECTOR_WITH_POSITIONS = 1024, TERMVECTOR_WITH_OFFSETS = 2048 } |
Public Member Functions | |
| Field (const TCHAR *name, const TCHAR *value, bool store, bool index, bool token, const bool storeTermVector=false) | |
| Field (const TCHAR *name, lucene::util::Reader *reader, bool store, bool index, bool token, const bool storeTermVector=false) | |
| Field (const TCHAR *name, const TCHAR *value, int configs) | |
| Field (const TCHAR *name, lucene::util::Reader *reader, int configs) | |
| Field (const TCHAR *name, jstreams::StreamBase< char > *stream, int configs) | |
| ~Field () | |
| const TCHAR * | name () |
| The name of the field (e.g., "date", "subject", "title", "body", etc. | |
| TCHAR * | stringValue () |
| The value of the field as a String, or null. | |
| lucene::util::Reader * | readerValue () |
| The value of the field as a reader, or null. | |
| jstreams::StreamBase< char > * | streamValue () |
| The value of the field as a String, or null. | |
| bool | isStored () |
| bool | isIndexed () |
| bool | isTokenized () |
| bool | isCompressed () |
| True if the value of the field is stored and compressed within the index NOTE: CLucene does not actually support compressed fields, Instead, a reader will be returned with a pointer to a SubIndexInputStream. | |
| void | setConfig (int termVector) |
| bool | isTermVectorStored () |
| True iff the term or terms used to index this field are stored as a term vector, available from IndexReader#getTermFreqVector(int32_t,TCHAR*). | |
| bool | isStoreOffsetWithTermVector () |
| True iff terms are stored as term vector together with their offsets (start and end positon in source text). | |
| bool | isStorePositionWithTermVector () |
| True iff terms are stored as term vector together with their token positions. | |
| float_t | getBoost () |
| Returns the boost factor for hits for this field. | |
| void | setBoost (float_t value) |
| Sets the boost factor hits on this field. | |
| bool | isBinary () |
| True iff the value of the filed is stored as binary. | |
| bool | getOmitNorms () |
| True if norms are omitted for this indexed field. | |
| void | setOmitNorms (bool omitNorms) |
| Expert:. | |
| TCHAR * | toString () |
Static Public Member Functions | |
| static Field * | Keyword (const TCHAR *name, const TCHAR *value) |
| Constructs a String-valued Field that is not tokenized, but is indexed and stored. | |
| static Field * | UnIndexed (const TCHAR *name, const TCHAR *value) |
| Constructs a String-valued Field that is not tokenized nor indexed, but is stored in the index, for return with hits. | |
| static Field * | Text (const TCHAR *name, const TCHAR *value, const bool storeTermVector=false) |
| Constructs a String-valued Field that is tokenized and indexed, and is stored in the index, for return with hits. | |
| static Field * | UnStored (const TCHAR *name, const TCHAR *value, const bool storeTermVector=false) |
| Constructs a String-valued Field that is tokenized and indexed, but that is not stored in the index. | |
| static Field * | Text (const TCHAR *name, lucene::util::Reader *value, const bool storeTermVector=false) |
| Constructs a Reader-valued Field that is tokenized and indexed, but is *not* stored in the index verbatim. | |
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.
PORTING: CLucene doesn't directly support compressed fields. However, it is easy to reproduce this functionality by using the GZip streams in the contrib package. Also note that binary fields are not read immediately in CLucene, a substream is pointed directly to the field's data, in affect creating a lazy load ability. This means that large fields are best saved in binary format (even if they are text), so that they can be loaded lazily.
| INDEX_NO |
Do not index the field value. This field can thus not be searched, but one can still access its contents provided it is stored. |
| INDEX_TOKENIZED |
Index the field's value so it can be searched. An Analyzer will be used to tokenize and possibly further normalize the text before its terms will be stored in the index. This is useful for common text. |
| INDEX_UNTOKENIZED |
Index the field's value without using an Analyzer, so it can be searched. As no analyzer is used the value will be stored as a single term. This is useful for unique Ids like product numbers. |
| INDEX_NONORMS |
Index the field's value without an Analyzer, and disable the storing of norms. No norms means that index-time boosting and field length normalization will be disabled. The benefit is less memory usage as norms take up one byte per indexed field for every document in the index. |
| STORE_YES |
Store the original field value in the index. This is useful for short texts like a document's title which should be displayed with the results. The value is stored in its original form, i.e. no analyzer is used before it is stored. |
| STORE_NO | |
| STORE_COMPRESS |
Store the original field value in the index in a compressed form. This is useful for long documents and for binary valued fields. NOTE: CLucene does not directly support compressed fields, to store a compressed field. //TODO: need better documentation on how to add a compressed field //because actually we still need to write a GZipOutputStream... |
| TERMVECTOR_NO |
Do not store term vectors. |
| TERMVECTOR_YES |
Store the term vectors of each document. A term vector is a list of the document's terms and their number of occurences in that document. |
| TERMVECTOR_WITH_POSITIONS |
Store the term vector + token position information.
|
| TERMVECTOR_WITH_OFFSETS |
Store the term vector + Token offset information.
|
| lucene::document::Field::Field | ( | const TCHAR * | name, | |
| const TCHAR * | value, | |||
| bool | store, | |||
| bool | index, | |||
| bool | token, | |||
| const bool | storeTermVector = false | |||
| ) |
| lucene::document::Field::Field | ( | const TCHAR * | name, | |
| lucene::util::Reader * | reader, | |||
| bool | store, | |||
| bool | index, | |||
| bool | token, | |||
| const bool | storeTermVector = false | |||
| ) |
| lucene::document::Field::Field | ( | const TCHAR * | name, | |
| const TCHAR * | value, | |||
| int | configs | |||
| ) |
| lucene::document::Field::Field | ( | const TCHAR * | name, | |
| lucene::util::Reader * | reader, | |||
| int | configs | |||
| ) |
| lucene::document::Field::Field | ( | const TCHAR * | name, | |
| jstreams::StreamBase< char > * | stream, | |||
| int | configs | |||
| ) |
| lucene::document::Field::~Field | ( | ) |
| float_t lucene::document::Field::getBoost | ( | ) |
Returns the boost factor for hits for this field.
The default value is 1.0.
Note: this value is not stored directly with the document in the index. Documents returned from IndexReader#document(int) and Hits#doc(int) may thus not have the same value present as when this field was indexed.
| bool lucene::document::Field::getOmitNorms | ( | ) |
True if norms are omitted for this indexed field.
| bool lucene::document::Field::isBinary | ( | ) |
True iff the value of the filed is stored as binary.
| bool lucene::document::Field::isCompressed | ( | ) |
True if the value of the field is stored and compressed within the index NOTE: CLucene does not actually support compressed fields, Instead, a reader will be returned with a pointer to a SubIndexInputStream.
A GZipInputStream and a UTF8 reader must be used to actually read the content. This flag will only be set if the index was created by another lucene implementation.
| bool lucene::document::Field::isIndexed | ( | ) |
| bool lucene::document::Field::isStored | ( | ) |
| bool lucene::document::Field::isStoreOffsetWithTermVector | ( | ) |
True iff terms are stored as term vector together with their offsets (start and end positon in source text).
| bool lucene::document::Field::isStorePositionWithTermVector | ( | ) |
True iff terms are stored as term vector together with their token positions.
| bool lucene::document::Field::isTermVectorStored | ( | ) |
True iff the term or terms used to index this field are stored as a term vector, available from IndexReader#getTermFreqVector(int32_t,TCHAR*).
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.
| bool lucene::document::Field::isTokenized | ( | ) |
| static Field* lucene::document::Field::Keyword | ( | const TCHAR * | name, | |
| const TCHAR * | value | |||
| ) | [static] |
Constructs a String-valued Field that is not tokenized, but is indexed and stored.
Useful for non-text fields, e.g. date or url.
| const TCHAR* lucene::document::Field::name | ( | ) |
The name of the field (e.g., "date", "subject", "title", "body", etc.
) as an interned string. returns reference
| lucene:: util ::Reader* lucene::document::Field::readerValue | ( | ) |
The value of the field as a reader, or null.
If null, the String value or stream value is used. Exactly one of stringValue(), readerValue() and streamValue() must be set.
| void lucene::document::Field::setBoost | ( | float_t | value | ) |
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.
The boost is multiplied by Document#getBoost() of the document containing this field. If a document has multiple fields with the same name, all such values are multiplied together. This product is then multipled by the value Similarity#lengthNorm(String,int), and rounded by Similarity#encodeNorm(float) before it is stored in the index. One should attempt to ensure that this product does not overflow the range of that encoding.
| void lucene::document::Field::setConfig | ( | int | termVector | ) |
| void lucene::document::Field::setOmitNorms | ( | bool | omitNorms | ) |
Expert:.
If set, omit normalization factors associated with this indexed field. This effectively disables indexing boosts and length normalization for this field.
| jstreams::StreamBase<char>* lucene::document::Field::streamValue | ( | ) |
The value of the field as a String, or null.
If null, the String value or Reader value is used. Exactly one of stringValue(), readerValue() and streamValue() must be set.
| TCHAR* lucene::document::Field::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 streamValue() must be set. returns reference
| static Field* lucene::document::Field::Text | ( | const TCHAR * | name, | |
| lucene::util::Reader * | value, | |||
| const bool | storeTermVector = false | |||
| ) | [static] |
Constructs a Reader-valued Field that is tokenized and indexed, but is *not* stored in the index verbatim.
Useful for longer text fields, like "body".
| static Field* lucene::document::Field::Text | ( | const TCHAR * | name, | |
| const TCHAR * | value, | |||
| const bool | storeTermVector = false | |||
| ) | [static] |
Constructs a String-valued Field that is tokenized and indexed, and is stored in the index, for return with hits.
Useful for short text fields, like "title" or "subject".
| TCHAR* lucene::document::Field::toString | ( | ) |
| static Field* lucene::document::Field::UnIndexed | ( | const TCHAR * | name, | |
| const TCHAR * | value | |||
| ) | [static] |
Constructs a String-valued Field that is not tokenized nor indexed, but is stored in the index, for return with hits.
| static Field* lucene::document::Field::UnStored | ( | const TCHAR * | name, | |
| const TCHAR * | value, | |||
| const bool | storeTermVector = false | |||
| ) | [static] |
Constructs a String-valued Field that is tokenized and indexed, but that is not stored in the index.