CLucene - a full-featured, c++ search engine
API Documentation
#include <QueryParser.h>
Public Member Functions | |
QueryParserBase (lucene::analysis::Analyzer *analyzer) | |
~QueryParserBase () | |
void | setLowercaseExpandedTerms (bool lowercaseExpandedTerms) |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. | |
bool | getLowercaseExpandedTerms () const |
LUCENE_STATIC_CONSTANT (int, OR_OPERATOR=0) | |
LUCENE_STATIC_CONSTANT (int, AND_OPERATOR=1) | |
void | setDefaultOperator (int oper) |
Sets the boolean operator of the QueryParser. | |
int | getDefaultOperator () const |
Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR. | |
virtual void | throwParserException (const TCHAR *message, TCHAR ch, int32_t col, int32_t line) |
void | setPhraseSlop (int phraseSlop) |
Sets the default slop for phrases. | |
int | getPhraseSlop () |
Gets the default slop for phrases. | |
Protected Member Functions | |
LUCENE_STATIC_CONSTANT (int, CONJ_NONE=0) | |
LUCENE_STATIC_CONSTANT (int, CONJ_AND=1) | |
LUCENE_STATIC_CONSTANT (int, CONJ_OR=2) | |
LUCENE_STATIC_CONSTANT (int, MOD_NONE=0) | |
LUCENE_STATIC_CONSTANT (int, MOD_NOT=10) | |
LUCENE_STATIC_CONSTANT (int, MOD_REQ=11) | |
void | discardEscapeChar (TCHAR *token) const |
Removes the escaped characters. | |
TCHAR * | AnalyzeExpandedTerm (const TCHAR *field, TCHAR *termStr) |
virtual void | AddClause (std::vector< lucene::search::BooleanClause * > &clauses, int32_t conj, int32_t mods, lucene::search::Query *q) |
virtual lucene::search::Query * | GetFieldQuery (const TCHAR *field, TCHAR *queryText) |
Returns a termquery, phrasequery for the specified field. | |
virtual lucene::search::Query * | GetFieldQuery (const TCHAR *field, TCHAR *queryText, int32_t slop) |
Delegates to GetFieldQuery(string, string), and adds slop onto phrasequery. | |
virtual lucene::search::Query * | GetPrefixQuery (const TCHAR *field, TCHAR *termStr) |
Factory method for generating a query (similar to GetWildcardQuery). | |
virtual lucene::search::Query * | GetWildcardQuery (const TCHAR *field, TCHAR *termStr) |
Factory method for generating a query. | |
virtual lucene::search::Query * | GetFuzzyQuery (const TCHAR *field, TCHAR *termStr) |
Factory method for generating a query (similar to GetWildcardQuery). | |
virtual lucene::search::Query * | GetBooleanQuery (std::vector< lucene::search::BooleanClause * > &clauses) |
Factory method for generating query, given a set of clauses. | |
virtual lucene::search::Query * | GetBooleanQuery (std::vector< lucene::search::BooleanClause * > &clauses, bool disableCoord) |
virtual lucene::search::Query * | GetRangeQuery (const TCHAR *field, TCHAR *part1, TCHAR *part2, bool inclusive) |
return NULL to disallow | |
virtual lucene::search::Query * | ParseRangeQuery (const TCHAR *field, TCHAR *str, bool inclusive) |
Protected Attributes | |
int | defaultOperator |
int32_t | phraseSlop |
bool | lowercaseExpandedTerms |
lucene::analysis::Analyzer * | analyzer |
You can override any of these to provide a customised QueryParser.
lucene::queryParser::QueryParserBase::QueryParserBase | ( | lucene::analysis::Analyzer * | analyzer | ) |
lucene::queryParser::QueryParserBase::~QueryParserBase | ( | ) |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
CONJ_NONE | = 0 | |||
) | [protected] |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
CONJ_AND | = 1 | |||
) | [protected] |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
CONJ_OR | = 2 | |||
) | [protected] |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
MOD_NONE | = 0 | |||
) | [protected] |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
MOD_NOT | = 10 | |||
) | [protected] |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
MOD_REQ | = 11 | |||
) | [protected] |
void lucene::queryParser::QueryParserBase::setLowercaseExpandedTerms | ( | bool | lowercaseExpandedTerms | ) |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not.
Default is true
.
bool lucene::queryParser::QueryParserBase::getLowercaseExpandedTerms | ( | ) | const |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
OR_OPERATOR | = 0 | |||
) |
lucene::queryParser::QueryParserBase::LUCENE_STATIC_CONSTANT | ( | int | , | |
AND_OPERATOR | = 1 | |||
) |
void lucene::queryParser::QueryParserBase::setDefaultOperator | ( | int | oper | ) |
Sets the boolean operator of the QueryParser.
In default mode (OR_OPERATOR
) terms without any modifiers are considered optional: for example capital of Hungary
is equal to capital OR of OR Hungary
.
In AND_OPERATOR
mode terms are considered to be in conjuction: the above mentioned query is parsed as capital AND of AND Hungary
int lucene::queryParser::QueryParserBase::getDefaultOperator | ( | ) | const |
Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR.
virtual void lucene::queryParser::QueryParserBase::throwParserException | ( | const TCHAR * | message, | |
TCHAR | ch, | |||
int32_t | col, | |||
int32_t | line | |||
) | [virtual] |
void lucene::queryParser::QueryParserBase::setPhraseSlop | ( | int | phraseSlop | ) | [inline] |
Sets the default slop for phrases.
If zero, then exact phrase matches are required. Default value is zero.
int lucene::queryParser::QueryParserBase::getPhraseSlop | ( | ) | [inline] |
Gets the default slop for phrases.
void lucene::queryParser::QueryParserBase::discardEscapeChar | ( | TCHAR * | token | ) | const [protected] |
Removes the escaped characters.
TCHAR* lucene::queryParser::QueryParserBase::AnalyzeExpandedTerm | ( | const TCHAR * | field, | |
TCHAR * | termStr | |||
) | [protected] |
virtual void lucene::queryParser::QueryParserBase::AddClause | ( | std::vector< lucene::search::BooleanClause * > & | clauses, | |
int32_t | conj, | |||
int32_t | mods, | |||
lucene::search::Query * | q | |||
) | [protected, virtual] |
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetFieldQuery | ( | const TCHAR * | field, | |
TCHAR * | queryText | |||
) | [protected, virtual] |
Returns a termquery, phrasequery for the specified field.
Note: this is only a partial implementation, since MultiPhraseQuery is not implemented yet return NULL to disallow
Reimplemented in lucene::queryParser::MultiFieldQueryParser.
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetFieldQuery | ( | const TCHAR * | field, | |
TCHAR * | queryText, | |||
int32_t | slop | |||
) | [protected, virtual] |
Delegates to GetFieldQuery(string, string), and adds slop onto phrasequery.
Can be used to remove slop functionality
Reimplemented in lucene::queryParser::MultiFieldQueryParser.
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetPrefixQuery | ( | const TCHAR * | field, | |
TCHAR * | termStr | |||
) | [protected, virtual] |
Factory method for generating a query (similar to GetWildcardQuery).
Called when parser parses an input term token that uses prefix notation; that is, contains a single '*' wildcard character as its last character. Since this is a special case of generic wildcard term, and such a query can be optimized easily, this usually results in a different query object.
Depending on settings, a prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.
Can be overridden by extending classes, to provide custom handling for wild card queries, which may be necessary due to missing analyzer calls.
field | Name of the field query will use. | |
termStr | Term token to use for building term for the query (without trailing '*' character!) |
Reimplemented in lucene::queryParser::MultiFieldQueryParser.
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetWildcardQuery | ( | const TCHAR * | field, | |
TCHAR * | termStr | |||
) | [protected, virtual] |
Factory method for generating a query.
Called when parser parses an input term token that contains one or more wildcard characters (? and *), but is not a prefix term token (one that has just a single * character at the end)
Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.
Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.
field | Name of the field query will use. | |
termStr | Term token that contains one or more wild card characters (? or *), but is not simple prefix term |
Reimplemented in lucene::queryParser::MultiFieldQueryParser.
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetFuzzyQuery | ( | const TCHAR * | field, | |
TCHAR * | termStr | |||
) | [protected, virtual] |
Factory method for generating a query (similar to GetWildcardQuery).
Called when parser parses an input term token that has the fuzzy suffix (~) appended.
field | Name of the field query will use. | |
termStr | Term token to use for building term for the query |
Reimplemented in lucene::queryParser::MultiFieldQueryParser.
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetBooleanQuery | ( | std::vector< lucene::search::BooleanClause * > & | clauses | ) | [protected, virtual] |
Factory method for generating query, given a set of clauses.
By default creates a boolean query composed of clauses passed in.
Can be overridden by extending classes, to modify query being returned.
clauses | Vector that contains BooleanClause instances to join. |
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetBooleanQuery | ( | std::vector< lucene::search::BooleanClause * > & | clauses, | |
bool | disableCoord | |||
) | [protected, virtual] |
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::GetRangeQuery | ( | const TCHAR * | field, | |
TCHAR * | part1, | |||
TCHAR * | part2, | |||
bool | inclusive | |||
) | [protected, virtual] |
virtual lucene:: search ::Query* lucene::queryParser::QueryParserBase::ParseRangeQuery | ( | const TCHAR * | field, | |
TCHAR * | str, | |||
bool | inclusive | |||
) | [protected, virtual] |
int lucene::queryParser::QueryParserBase::defaultOperator [protected] |
int32_t lucene::queryParser::QueryParserBase::phraseSlop [protected] |
bool lucene::queryParser::QueryParserBase::lowercaseExpandedTerms [protected] |
lucene:: analysis ::Analyzer* lucene::queryParser::QueryParserBase::analyzer [protected] |