CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_document_Field_ 00008 #define _lucene_document_Field_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "CLucene/util/Reader.h" 00015 #include "CLucene/util/streambase.h" 00016 00017 CL_NS_DEF(document) 00032 class Field :LUCENE_BASE{ 00033 private: 00034 const TCHAR* _name; 00035 TCHAR* _stringValue; 00036 CL_NS(util)::Reader* _readerValue; 00037 jstreams::StreamBase<char>* _streamValue; 00038 00039 int config; 00040 float_t boost; 00041 bool omitNorms; 00042 public: 00043 enum Store{ 00049 STORE_YES=1, 00051 STORE_NO=2, 00052 00060 STORE_COMPRESS=4 00061 }; 00062 00063 enum Index{ 00067 INDEX_NO=16, 00072 INDEX_TOKENIZED=32, 00077 INDEX_UNTOKENIZED=64, 00084 INDEX_NONORMS=128 00085 }; 00086 00087 enum TermVector{ 00089 TERMVECTOR_NO=256, 00092 TERMVECTOR_YES=512, 00098 TERMVECTOR_WITH_POSITIONS=1024, 00104 TERMVECTOR_WITH_OFFSETS=2048 00105 }; 00106 00107 _CL_DEPRECATED( another overload ) Field(const TCHAR* name, const TCHAR* value, bool store, bool index, bool token, const bool storeTermVector=false); 00108 _CL_DEPRECATED( another overload ) Field(const TCHAR* name, CL_NS(util)::Reader* reader, bool store, bool index, bool token, const bool storeTermVector=false); 00109 00110 Field(const TCHAR* name, const TCHAR* value, int configs); 00111 Field(const TCHAR* name, CL_NS(util)::Reader* reader, int configs); 00112 Field(const TCHAR* name, jstreams::StreamBase<char>* stream, int configs); 00113 ~Field(); 00114 00119 _CL_DEPRECATED( new Field(*) ) static Field* Keyword(const TCHAR* name, const TCHAR* value); 00120 00125 _CL_DEPRECATED( new Field(*) ) static Field* UnIndexed(const TCHAR* name, const TCHAR* value); 00126 00132 _CL_DEPRECATED( new Field(*) ) static Field* Text(const TCHAR* name, const TCHAR* value, const bool storeTermVector=false); 00133 00138 _CL_DEPRECATED( new Field(*) ) static Field* UnStored(const TCHAR* name, const TCHAR* value, const bool storeTermVector=false); 00139 00145 _CL_DEPRECATED( new Field(*) ) static Field* Text(const TCHAR* name, CL_NS(util)::Reader* value, const bool storeTermVector=false); 00146 00149 const TCHAR* name(); 00150 00154 TCHAR* stringValue(); 00155 00159 CL_NS(util)::Reader* readerValue(); 00160 00164 jstreams::StreamBase<char>* streamValue(); 00165 00166 // True iff the value of the field is to be stored in the index for return 00167 // with search hits. It is an error for this to be true if a field is 00168 // Reader-valued. 00169 bool isStored(); 00170 00171 // True iff the value of the field is to be indexed, so that it may be 00172 // searched on. 00173 bool isIndexed(); 00174 00175 // True iff the value of the field should be tokenized as text prior to 00176 // indexing. Un-tokenized fields are indexed as a single word and may not be 00177 // Reader-valued. 00178 bool isTokenized(); 00179 00186 bool isCompressed(); 00187 00188 //Set configs using XOR. This resets all the settings 00189 //For example, to use term vectors with positions and offsets do: 00190 //object->setConfig(TERMVECTOR_WITH_POSITIONS | TERMVECTOR_WITH_OFFSETS); 00191 void setConfig(int termVector); 00192 00201 bool isTermVectorStored(); 00202 00207 bool isStoreOffsetWithTermVector(); 00208 00212 bool isStorePositionWithTermVector(); 00213 00225 float_t getBoost(); 00226 00243 void setBoost(float_t value); 00244 00246 bool isBinary(); 00247 00249 bool getOmitNorms(); 00250 00256 void setOmitNorms(bool omitNorms); 00257 00258 // Prints a Field for human consumption. 00259 TCHAR* toString(); 00260 }; 00261 CL_NS_END 00262 #endif