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 MultiFieldQueryParser_H 00008 #define MultiFieldQueryParser_H 00009 00010 00011 //#include "CLucene/analysis/AnalysisHeader.h" 00012 //#include "CLucene/search/SearchHeader.h" 00013 #include "QueryParser.h" 00014 #include "CLucene/util/VoidMapSetDefinitions.h" 00015 00016 00017 CL_NS_DEF(queryParser) 00018 00019 typedef CL_NS(util)::CLHashMap<const TCHAR*, 00020 float_t, 00021 CL_NS(util)::Compare::TChar, 00022 CL_NS(util)::Equals::TChar, 00023 CL_NS(util)::Deletor::tcArray, 00024 CL_NS(util)::Deletor::DummyFloat 00025 > BoostMap; 00026 00031 class CLUCENE_EXPORT MultiFieldQueryParser: public QueryParser 00032 { 00033 protected: 00034 const TCHAR** fields; 00035 BoostMap* boosts; 00036 public: 00037 LUCENE_STATIC_CONSTANT(uint8_t, NORMAL_FIELD=0); 00038 LUCENE_STATIC_CONSTANT(uint8_t, REQUIRED_FIELD=1); 00039 LUCENE_STATIC_CONSTANT(uint8_t, PROHIBITED_FIELD=2); 00040 00061 MultiFieldQueryParser(const TCHAR** fields, CL_NS(analysis)::Analyzer* a, BoostMap* boosts = NULL); 00062 virtual ~MultiFieldQueryParser(); 00063 00081 static CL_NS(search)::Query* parse(const TCHAR* query, const TCHAR** fields, CL_NS(analysis)::Analyzer* analyzer); 00082 00113 static CL_NS(search)::Query* parse(const TCHAR* query, const TCHAR** fields, const uint8_t* flags, CL_NS(analysis)::Analyzer* analyzer); 00114 00115 00116 00117 protected: 00118 CL_NS(search)::Query* GetFieldQuery(const TCHAR* field, TCHAR* queryText); 00119 CL_NS(search)::Query* GetFieldQuery(const TCHAR* field, TCHAR* queryText, int32_t slop); 00120 CL_NS(search)::Query* GetFuzzyQuery(const TCHAR* field, TCHAR* termStr); 00121 CL_NS(search)::Query* GetRangeQuery(const TCHAR* field, TCHAR* part1, TCHAR* part2, bool inclusive); 00122 CL_NS(search)::Query* GetPrefixQuery(const TCHAR* field, TCHAR* termStr); 00123 CL_NS(search)::Query* GetWildcardQuery(const TCHAR* field, TCHAR* termStr); 00124 00131 virtual CL_NS(search)::Query* QueryAddedCallback(const TCHAR* field, CL_NS(search)::Query* query){ return query; } 00132 }; 00133 CL_NS_END 00134 #endif