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 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "CLucene/analysis/AnalysisHeader.h" 00015 #include "CLucene/search/SearchHeader.h" 00016 #include "QueryParser.h" 00017 00018 00019 CL_NS_DEF(queryParser) 00020 00021 typedef CL_NS(util)::CLHashMap<const TCHAR*, 00022 float_t, 00023 CL_NS(util)::Compare::TChar, 00024 CL_NS(util)::Equals::TChar, 00025 CL_NS(util)::Deletor::tcArray, 00026 CL_NS(util)::Deletor::DummyFloat 00027 > BoostMap; 00028 00033 class MultiFieldQueryParser: public QueryParser 00034 { 00035 protected: 00036 const TCHAR** fields; 00037 BoostMap* boosts; 00038 public: 00039 LUCENE_STATIC_CONSTANT(uint8_t, NORMAL_FIELD=0); 00040 LUCENE_STATIC_CONSTANT(uint8_t, REQUIRED_FIELD=1); 00041 LUCENE_STATIC_CONSTANT(uint8_t, PROHIBITED_FIELD=2); 00042 00063 MultiFieldQueryParser(const TCHAR** fields, CL_NS(analysis)::Analyzer* a, BoostMap* boosts = NULL); 00064 virtual ~MultiFieldQueryParser(); 00065 00083 static CL_NS(search)::Query* parse(const TCHAR* query, const TCHAR** fields, CL_NS(analysis)::Analyzer* analyzer); 00084 00115 static CL_NS(search)::Query* parse(const TCHAR* query, const TCHAR** fields, const uint8_t* flags, CL_NS(analysis)::Analyzer* analyzer); 00116 00117 00118 00119 protected: 00120 CL_NS(search)::Query* GetFieldQuery(const TCHAR* field, TCHAR* queryText); 00121 CL_NS(search)::Query* GetFieldQuery(const TCHAR* field, TCHAR* queryText, int32_t slop); 00122 CL_NS(search)::Query* GetFuzzyQuery(const TCHAR* field, TCHAR* termStr); 00123 CL_NS(search)::Query* GetRangeQuery(const TCHAR* field, TCHAR* part1, TCHAR* part2, bool inclusive); 00124 CL_NS(search)::Query* GetPrefixQuery(const TCHAR* field, TCHAR* termStr); 00125 CL_NS(search)::Query* GetWildcardQuery(const TCHAR* field, TCHAR* termStr); 00126 00133 virtual CL_NS(search)::Query* QueryAddedCallback(const TCHAR* field, CL_NS(search)::Query* query){ return query; } 00134 }; 00135 CL_NS_END 00136 #endif