Lucene++ - a full-featured, c++ search engine
API Documentation
The most important method is parse(const String&).
More...
#include <QueryParser.h>
Data Structures | |
| struct | JJCalls |
Public Types | |
| enum | Operator { OR_OPERATOR , AND_OPERATOR } |
The default operator for parsing queries. Use QueryParser#setDefaultOperator to change it. More... | |
| Public Types inherited from Lucene::QueryParserConstants | |
| enum | RegularExpressionId { _EOF = 0 , _NUM_CHAR = 1 , _ESCAPED_CHAR = 2 , _TERM_START_CHAR = 3 , _TERM_CHAR = 4 , _WHITESPACE = 5 , _QUOTED_CHAR = 6 , AND = 8 , OR = 9 , NOT = 10 , PLUS = 11 , MINUS = 12 , LPAREN = 13 , RPAREN = 14 , COLON = 15 , STAR = 16 , CARAT = 17 , QUOTED = 18 , TERM = 19 , FUZZY_SLOP = 20 , PREFIXTERM = 21 , WILDTERM = 22 , RANGEIN_START = 23 , RANGEEX_START = 24 , NUMBER = 25 , RANGEIN_TO = 26 , RANGEIN_END = 27 , RANGEIN_QUOTED = 28 , RANGEIN_GOOP = 29 , RANGEEX_TO = 30 , RANGEEX_END = 31 , RANGEEX_QUOTED = 32 , RANGEEX_GOOP = 33 } |
| enum | LexicalState { Boost = 0 , RangeEx = 1 , RangeIn = 2 , DEFAULT = 3 } |
Public Member Functions | |
| QueryParser (LuceneVersion::Version matchVersion, const String &field, const AnalyzerPtr &analyzer) | |
| Constructs a query parser. | |
| QueryParser (const QueryParserCharStreamPtr &stream) | |
| Constructor with user supplied QueryParserCharStream. | |
| QueryParser (const QueryParserTokenManagerPtr &tokenMgr) | |
| Constructor with generated Token Manager. | |
| virtual | ~QueryParser () |
| virtual String | getClassName () |
| boost::shared_ptr< QueryParser > | shared_from_this () |
| QueryPtr | parse (const String &query) |
Parses a query string, returning a Query. | |
| AnalyzerPtr | getAnalyzer () |
| String | getField () |
| double | getFuzzyMinSim () |
| Get the minimal similarity for fuzzy queries. | |
| void | setFuzzyMinSim (double fuzzyMinSim) |
| Set the minimum similarity for fuzzy queries. Default is 0.5. | |
| int32_t | getFuzzyPrefixLength () |
| Get the prefix length for fuzzy queries. | |
| void | setFuzzyPrefixLength (int32_t fuzzyPrefixLength) |
| Set the prefix length for fuzzy queries. Default is 0. | |
| void | setPhraseSlop (int32_t phraseSlop) |
| Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero. | |
| int32_t | getPhraseSlop () |
| Gets the default slop for phrases. | |
| void | setAllowLeadingWildcard (bool allowLeadingWildcard) |
| Set to true to allow leading wildcard characters. | |
| bool | getAllowLeadingWildcard () |
| void | setEnablePositionIncrements (bool enable) |
| Set to true to enable position increments in result query. | |
| bool | getEnablePositionIncrements () |
| void | setDefaultOperator (Operator op) |
| 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 conjunction: the above mentioned query is parsed as capital AND of AND Hungary. | |
| Operator | getDefaultOperator () |
| Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR. | |
| void | setLowercaseExpandedTerms (bool lowercaseExpandedTerms) |
| Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true. | |
| bool | getLowercaseExpandedTerms () |
| void | setMultiTermRewriteMethod (const RewriteMethodPtr &method) |
By default QueryParser uses MultiTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any "TooManyClauses" exception. However, if your application really needs to use the old- fashioned BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method. | |
| RewriteMethodPtr | getMultiTermRewriteMethod () |
| void | setLocale (std::locale locale) |
| Set locale used by date range parsing. | |
| std::locale | getLocale () |
| Returns current locale, allowing access by subclasses. | |
| void | setDateResolution (DateTools::Resolution dateResolution) |
Sets the default date resolution used by RangeQueries for fields for which no specific date resolutions has been set. Field specific resolutions can be set with setDateResolution(const String&, DateTools::Resolution). | |
| void | setDateResolution (const String &fieldName, DateTools::Resolution dateResolution) |
| Sets the date resolution used by RangeQueries for a specific field. | |
| DateTools::Resolution | getDateResolution (const String &fieldName) |
| Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date resolution has been set for the given field. | |
| void | setRangeCollator (const CollatorPtr &rc) |
| Sets the collator used to determine index term inclusion in ranges for RangeQuerys. | |
| CollatorPtr | getRangeCollator () |
| int32_t | Conjunction () |
| Query ::= ( Clause )* Clause ::= ["+", "-"] [ ":"] ( | "(" Query ")" ). | |
| int32_t | Modifiers () |
| virtual QueryPtr | TopLevelQuery (const String &field) |
| This makes sure that there is no garbage after the query string. | |
| virtual QueryPtr | ParseQuery (const String &field) |
| virtual QueryPtr | ParseClause (const String &field) |
| virtual QueryPtr | ParseTerm (const String &field) |
| virtual void | ReInit (const QueryParserCharStreamPtr &stream) |
| Reinitialise. | |
| virtual void | ReInit (const QueryParserTokenManagerPtr &tokenMgr) |
| Reinitialise. | |
| virtual QueryParserTokenPtr | getNextToken () |
| Get the next Token. | |
| virtual QueryParserTokenPtr | getToken (int32_t index) |
| Get the specific Token. | |
| virtual void | generateParseException () |
| Generate QueryParserError exception. | |
| virtual void | enable_tracing () |
| Enable tracing. | |
| virtual void | disable_tracing () |
| Disable tracing. | |
| Public Member Functions inherited from Lucene::QueryParserConstants | |
| virtual | ~QueryParserConstants () |
| Public Member Functions inherited from Lucene::LuceneObject | |
| virtual | ~LuceneObject () |
| virtual void | initialize () |
| Called directly after instantiation to create objects that depend on this object being fully constructed. | |
| virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr()) |
| Return clone of this object. | |
| virtual int32_t | hashCode () |
| Return hash code for this object. | |
| virtual bool | equals (const LuceneObjectPtr &other) |
| Return whether two objects are equal. | |
| virtual int32_t | compareTo (const LuceneObjectPtr &other) |
| Compare two objects. | |
| virtual String | toString () |
| Returns a string representation of the object. | |
| Public Member Functions inherited from Lucene::LuceneSync | |
| virtual | ~LuceneSync () |
| virtual SynchronizePtr | getSync () |
| Return this object synchronize lock. | |
| virtual LuceneSignalPtr | getSignal () |
| Return this object signal. | |
| virtual void | lock (int32_t timeout=0) |
| Lock this object using an optional timeout. | |
| virtual void | unlock () |
| Unlock this object. | |
| virtual bool | holdsLock () |
| Returns true if this object is currently locked by current thread. | |
| virtual void | wait (int32_t timeout=0) |
| Wait for signal using an optional timeout. | |
| virtual void | notifyAll () |
| Notify all threads waiting for signal. | |
Static Public Member Functions | |
| static String | _getClassName () |
| static int | main (Collection< String > args) |
Command line tool to test QueryParser, using SimpleAnalyzer. | |
| Static Public Member Functions inherited from Lucene::QueryParserConstants | |
| static String | _getClassName () |
Data Fields | |
| bool | lowercaseExpandedTerms |
| RewriteMethodPtr | multiTermRewriteMethod |
| bool | allowLeadingWildcard |
| bool | enablePositionIncrements |
| AnalyzerPtr | analyzer |
| String | field |
| int32_t | phraseSlop |
| double | fuzzyMinSim |
| int32_t | fuzzyPrefixLength |
| std::locale | locale |
| DateTools::Resolution | dateResolution |
| MapStringResolution | fieldToDateResolution |
| CollatorPtr | rangeCollator |
| QueryParserTokenManagerPtr | token_source |
| Generated Token Manager. | |
| QueryParserTokenPtr | token |
| Current token. | |
| QueryParserTokenPtr | jj_nt |
| Next token. | |
Protected Types | |
| typedef boost::shared_ptr< JJCalls > | JJCallsPtr |
Protected Member Functions | |
| void | ConstructParser (const QueryParserCharStreamPtr &stream, const QueryParserTokenManagerPtr &tokenMgr) |
| Construct query parser with supplied QueryParserCharStream or TokenManager. | |
| virtual void | addClause (Collection< BooleanClausePtr > clauses, int32_t conj, int32_t mods, const QueryPtr &q) |
| virtual QueryPtr | getFieldQuery (const String &field, const String &queryText) |
| Use the analyzer to get all the tokens, and then build a TermQuery, PhraseQuery, or nothing based on the term count. | |
| virtual QueryPtr | getFieldQuery (const String &field, const String &queryText, int32_t slop) |
Base implementation delegates to getFieldQuery(const String&, const String&). This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery. | |
| virtual QueryPtr | getRangeQuery (const String &field, const String &part1, const String &part2, bool inclusive) |
| Builds a new TermRangeQuery instance for given min/max parts. | |
| BooleanQueryPtr | newBooleanQuery (bool disableCoord) |
| Builds a new BooleanQuery instance. | |
| BooleanClausePtr | newBooleanClause (const QueryPtr &q, BooleanClause::Occur occur) |
| Builds a new BooleanClause instance. | |
| QueryPtr | newTermQuery (const TermPtr &term) |
| Builds a new TermQuery instance. | |
| PhraseQueryPtr | newPhraseQuery () |
| Builds a new PhraseQuery instance. | |
| MultiPhraseQueryPtr | newMultiPhraseQuery () |
| Builds a new MultiPhraseQuery instance. | |
| QueryPtr | newPrefixQuery (const TermPtr &prefix) |
| Builds a new PrefixQuery instance. | |
| QueryPtr | newFuzzyQuery (const TermPtr &term, double minimumSimilarity, int32_t prefixLength) |
| Builds a new FuzzyQuery instance. | |
| QueryPtr | newRangeQuery (const String &field, const String &part1, const String &part2, bool inclusive) |
| Builds a new TermRangeQuery instance. | |
| QueryPtr | newMatchAllDocsQuery () |
| Builds a new MatchAllDocsQuery instance. | |
| QueryPtr | newWildcardQuery (const TermPtr &term) |
| Builds a new WildcardQuery instance. | |
| virtual QueryPtr | getBooleanQuery (Collection< BooleanClausePtr > clauses) |
| Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. | |
| virtual QueryPtr | getBooleanQuery (Collection< BooleanClausePtr > clauses, bool disableCoord) |
| Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. | |
| virtual QueryPtr | getWildcardQuery (const String &field, const String &termStr) |
| 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). | |
| virtual QueryPtr | getPrefixQuery (const String &field, const String &termStr) |
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. | |
| virtual QueryPtr | getFuzzyQuery (const String &field, const String &termStr, double minSimilarity) |
Factory method for generating a query (similar to getWildcardQuery). Called when parser parses an input term token that has the fuzzy suffix (~) appended. | |
| String | discardEscapeChar (const String &input) |
| Returns a String where the escape char has been removed, or kept only once if there was a double escape. Supports escaped unicode characters, eg. translates \u0041 to A. | |
| bool | jj_2_1 (int32_t xla) |
| bool | jj_3R_2 () |
| bool | jj_3_1 () |
| bool | jj_3R_3 () |
| QueryParserTokenPtr | jj_consume_token (int32_t kind) |
| bool | jj_scan_token (int32_t kind) |
| int32_t | jj_ntk () |
| void | jj_add_error_token (int32_t kind, int32_t pos) |
| void | jj_rescan_token () |
| void | jj_save (int32_t index, int32_t xla) |
| Protected Member Functions inherited from Lucene::QueryParserConstants | |
| QueryParserConstants () | |
| Protected Member Functions inherited from Lucene::LuceneObject | |
| LuceneObject () | |
Static Protected Member Functions | |
| static int32_t | hexToInt (wchar_t c) |
| Returns the numeric value of the hexadecimal character. | |
| static String | escape (const String &s) |
| Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding . | |
Protected Attributes | |
| Operator | _operator |
| The actual operator that parser uses to combine query terms. | |
| int32_t | _jj_ntk |
| Next token. | |
| QueryParserTokenPtr | jj_scanpos |
| QueryParserTokenPtr | jj_lastpos |
| int32_t | jj_la |
| int32_t | jj_gen |
| Collection< int32_t > | jj_la1 |
| Collection< JJCallsPtr > | jj_2_rtns |
| bool | jj_rescan |
| int32_t | jj_gc |
| Collection< Collection< int32_t > > | jj_expentries |
| Collection< int32_t > | jj_expentry |
| int32_t | jj_kind |
| Collection< int32_t > | jj_lasttokens |
| int32_t | jj_endpos |
| Protected Attributes inherited from Lucene::LuceneSync | |
| SynchronizePtr | objectLock |
| LuceneSignalPtr | objectSignal |
Static Protected Attributes | |
| static const int32_t | CONJ_NONE |
| static const int32_t | CONJ_AND |
| static const int32_t | CONJ_OR |
| static const int32_t | MOD_NONE |
| static const int32_t | MOD_NOT |
| static const int32_t | MOD_REQ |
| static const int32_t | jj_la1_0 [] |
| static const int32_t | jj_la1_1 [] |
| Static Protected Attributes inherited from Lucene::QueryParserConstants | |
| static const wchar_t * | _tokenImage [] |
| Literal token values. | |
Additional Inherited Members | |
| Static Public Attributes inherited from Lucene::QueryParserConstants | |
| static Collection< String > | tokenImage |
| Literal token values. | |
The most important method is parse(const String&).
The syntax for query strings is as follows: A Query is a series of clauses. A clause may be prefixed by:
A clause may be either:
Thus, in BNF, the query grammar is:
Query ::= ( Clause )* Clause ::= ["+", "-"] [ ":"] ( | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In TermRangeQuerys, QueryParser tries to detect date values, eg. date:[6/1/2005 TO 6/4/2005] produces a range query that searches for "date" fields between 2005-06-01 and 2005-06-04. Note that the format of the accepted input depends on the locale.
By default a date is converted into a search term using the deprecated DateField for compatibility reasons. To use the new DateTools to convert dates, a Resolution has to be set.
The date resolution that shall be used for RangeQueries can be set using setDateResolution(Resolution) or setDateResolution(const String&, Resolution). The former sets the default date resolution for all fields, whereas the latter can be used to set field specific date resolutions. Field specific date resolutions take, if set, precedence over the default date resolution.
If you use neither DateField nor DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites getRangeQuery(const String&, const String&,
const String&, bool) to use a different method for date conversion.
Note that QueryParser is not thread-safe.
NOTE: there is a new QueryParser in contrib, which matches the same syntax as this class, but is more modular, enabling substantial customization to how a query is created.
NOTE: You must specify the required Version compatibility when creating QueryParser:
setEnablePositionIncrements is true by default.
|
protected |
The default operator for parsing queries. Use QueryParser#setDefaultOperator to change it.
| Enumerator | |
|---|---|
| OR_OPERATOR | |
| AND_OPERATOR | |
| Lucene::QueryParser::QueryParser | ( | LuceneVersion::Version | matchVersion, |
| const String & | field, | ||
| const AnalyzerPtr & | analyzer ) |
Constructs a query parser.
| matchVersion | Lucene version to match. |
| field | The default field for query terms. |
| analyzer | Used to find terms in the query text. |
References analyzer, and field.
Referenced by _getClassName().
| Lucene::QueryParser::QueryParser | ( | const QueryParserCharStreamPtr & | stream | ) |
Constructor with user supplied QueryParserCharStream.
| Lucene::QueryParser::QueryParser | ( | const QueryParserTokenManagerPtr & | tokenMgr | ) |
Constructor with generated Token Manager.
|
virtual |
|
inlinestatic |
References QueryParser().
|
protectedvirtual |
| int32_t Lucene::QueryParser::Conjunction | ( | ) |
|
protected |
Construct query parser with supplied QueryParserCharStream or TokenManager.
|
virtual |
Disable tracing.
|
protected |
Returns a String where the escape char has been removed, or kept only once if there was a double escape. Supports escaped unicode characters, eg. translates \u0041 to A.
|
virtual |
Enable tracing.
|
staticprotected |
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding .
|
virtual |
Generate QueryParserError exception.
| bool Lucene::QueryParser::getAllowLeadingWildcard | ( | ) |
| AnalyzerPtr Lucene::QueryParser::getAnalyzer | ( | ) |
|
protectedvirtual |
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 | List that contains BooleanClause instances to join. |
Query object.
|
protectedvirtual |
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 | List that contains BooleanClause instances to join. |
| disableCoord | true if coord scoring should be disabled. |
Query object.
|
inlinevirtual |
Reimplemented from Lucene::QueryParserConstants.
Reimplemented in Lucene::MultiFieldQueryParser.
| DateTools::Resolution Lucene::QueryParser::getDateResolution | ( | const String & | fieldName | ) |
Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date resolution has been set for the given field.
| Operator Lucene::QueryParser::getDefaultOperator | ( | ) |
Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR.
| bool Lucene::QueryParser::getEnablePositionIncrements | ( | ) |
| String Lucene::QueryParser::getField | ( | ) |
|
protectedvirtual |
Use the analyzer to get all the tokens, and then build a TermQuery, PhraseQuery, or nothing based on the term count.
Reimplemented in Lucene::MultiFieldQueryParser.
References field.
|
protectedvirtual |
Base implementation delegates to getFieldQuery(const String&, const String&). This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery.
Reimplemented in Lucene::MultiFieldQueryParser.
References field.
| double Lucene::QueryParser::getFuzzyMinSim | ( | ) |
Get the minimal similarity for fuzzy queries.
| int32_t Lucene::QueryParser::getFuzzyPrefixLength | ( | ) |
Get the prefix length for fuzzy queries.
|
protectedvirtual |
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 |
Query built for the term Reimplemented in Lucene::MultiFieldQueryParser.
References field.
| std::locale Lucene::QueryParser::getLocale | ( | ) |
Returns current locale, allowing access by subclasses.
| bool Lucene::QueryParser::getLowercaseExpandedTerms | ( | ) |
| RewriteMethodPtr Lucene::QueryParser::getMultiTermRewriteMethod | ( | ) |
|
virtual |
Get the next Token.
| int32_t Lucene::QueryParser::getPhraseSlop | ( | ) |
Gets the default slop for phrases.
|
protectedvirtual |
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) |
Query built for the term Reimplemented in Lucene::MultiFieldQueryParser.
References field.
| CollatorPtr Lucene::QueryParser::getRangeCollator | ( | ) |
|
protectedvirtual |
Builds a new TermRangeQuery instance for given min/max parts.
Reimplemented in Lucene::MultiFieldQueryParser.
References field.
|
virtual |
Get the specific Token.
|
protectedvirtual |
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 |
Query built for the term Reimplemented in Lucene::MultiFieldQueryParser.
References field.
|
staticprotected |
Returns the numeric value of the hexadecimal character.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
Command line tool to test QueryParser, using SimpleAnalyzer.
| int32_t Lucene::QueryParser::Modifiers | ( | ) |
|
protected |
Builds a new BooleanClause instance.
| q | sub query |
| occur | how this clause should occur when matching documents |
|
protected |
Builds a new BooleanQuery instance.
| disableCoord | disable coord |
|
protected |
Builds a new FuzzyQuery instance.
| term | Term |
| minimumSimilarity | minimum similarity |
| prefixLength | prefix length |
|
protected |
Builds a new MatchAllDocsQuery instance.
|
protected |
Builds a new MultiPhraseQuery instance.
|
protected |
Builds a new PhraseQuery instance.
|
protected |
Builds a new TermRangeQuery instance.
| field | Field |
| part1 | min |
| part2 | max |
| inclusive | true if range is inclusive |
References field.
| QueryPtr Lucene::QueryParser::parse | ( | const String & | query | ) |
Parses a query string, returning a Query.
| query | The query string to be parsed. |
|
virtual |
Reinitialise.
|
virtual |
Reinitialise.
| void Lucene::QueryParser::setAllowLeadingWildcard | ( | bool | allowLeadingWildcard | ) |
Set to true to allow leading wildcard characters.
When set, * or ? are allowed as the first character of a PrefixQuery and WildcardQuery. Note that this can produce very slow queries on big indexes. Default: false.
References allowLeadingWildcard.
| void Lucene::QueryParser::setDateResolution | ( | const String & | fieldName, |
| DateTools::Resolution | dateResolution ) |
Sets the date resolution used by RangeQueries for a specific field.
| fieldName | Field for which the date resolution is to be set |
| dateResolution | Date resolution to set |
References dateResolution.
| void Lucene::QueryParser::setDateResolution | ( | DateTools::Resolution | dateResolution | ) |
Sets the default date resolution used by RangeQueries for fields for which no specific date resolutions has been set. Field specific resolutions can be set with setDateResolution(const String&, DateTools::Resolution).
| dateResolution | The default date resolution to set |
References dateResolution.
| void Lucene::QueryParser::setDefaultOperator | ( | Operator | op | ) |
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 conjunction: the above mentioned query is parsed as capital AND of AND Hungary.
| void Lucene::QueryParser::setEnablePositionIncrements | ( | bool | enable | ) |
Set to true to enable position increments in result query.
When set, result phrase and multi-phrase queries will be aware of position increments. Useful when eg. a StopFilter increases the position increment of the token that follows an omitted token. Default: false.
| void Lucene::QueryParser::setFuzzyMinSim | ( | double | fuzzyMinSim | ) |
Set the minimum similarity for fuzzy queries. Default is 0.5.
References fuzzyMinSim.
| void Lucene::QueryParser::setFuzzyPrefixLength | ( | int32_t | fuzzyPrefixLength | ) |
Set the prefix length for fuzzy queries. Default is 0.
| fuzzyPrefixLength | The fuzzyPrefixLength to set. |
References fuzzyPrefixLength.
| void Lucene::QueryParser::setLocale | ( | std::locale | locale | ) |
| void Lucene::QueryParser::setLowercaseExpandedTerms | ( | bool | lowercaseExpandedTerms | ) |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true.
References lowercaseExpandedTerms.
| void Lucene::QueryParser::setMultiTermRewriteMethod | ( | const RewriteMethodPtr & | method | ) |
By default QueryParser uses MultiTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any "TooManyClauses" exception. However, if your application really needs to use the old- fashioned BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method.
| void Lucene::QueryParser::setPhraseSlop | ( | int32_t | phraseSlop | ) |
Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.
References phraseSlop.
| void Lucene::QueryParser::setRangeCollator | ( | const CollatorPtr & | rc | ) |
Sets the collator used to determine index term inclusion in ranges for RangeQuerys.
WARNING: Setting the rangeCollator to a non-null collator using this method will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined. Depending on the number of index Terms in this Field, the operation could be very slow.
| rc | The collator to use when constructing RangeQuerys |
|
inline |
|
virtual |
This makes sure that there is no garbage after the query string.
References field.
|
protected |
Next token.
|
protected |
The actual operator that parser uses to combine query terms.
| bool Lucene::QueryParser::allowLeadingWildcard |
Referenced by setAllowLeadingWildcard().
| AnalyzerPtr Lucene::QueryParser::analyzer |
|
staticprotected |
|
staticprotected |
|
staticprotected |
| DateTools::Resolution Lucene::QueryParser::dateResolution |
Referenced by setDateResolution(), and setDateResolution().
| bool Lucene::QueryParser::enablePositionIncrements |
| String Lucene::QueryParser::field |
Referenced by Lucene::MultiFieldQueryParser::getFieldQuery(), Lucene::MultiFieldQueryParser::getFieldQuery(), getFieldQuery(), getFieldQuery(), Lucene::MultiFieldQueryParser::getFuzzyQuery(), getFuzzyQuery(), Lucene::MultiFieldQueryParser::getPrefixQuery(), getPrefixQuery(), Lucene::MultiFieldQueryParser::getRangeQuery(), getRangeQuery(), Lucene::MultiFieldQueryParser::getWildcardQuery(), getWildcardQuery(), newRangeQuery(), ParseClause(), ParseQuery(), ParseTerm(), QueryParser(), and TopLevelQuery().
| MapStringResolution Lucene::QueryParser::fieldToDateResolution |
| double Lucene::QueryParser::fuzzyMinSim |
Referenced by setFuzzyMinSim().
| int32_t Lucene::QueryParser::fuzzyPrefixLength |
Referenced by setFuzzyPrefixLength().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
| QueryParserTokenPtr Lucene::QueryParser::jj_nt |
Next token.
|
protected |
|
protected |
| std::locale Lucene::QueryParser::locale |
Referenced by setLocale().
| bool Lucene::QueryParser::lowercaseExpandedTerms |
Referenced by setLowercaseExpandedTerms().
|
staticprotected |
|
staticprotected |
|
staticprotected |
| RewriteMethodPtr Lucene::QueryParser::multiTermRewriteMethod |
| int32_t Lucene::QueryParser::phraseSlop |
Referenced by setPhraseSlop().
| CollatorPtr Lucene::QueryParser::rangeCollator |
| QueryParserTokenPtr Lucene::QueryParser::token |
Current token.
| QueryParserTokenManagerPtr Lucene::QueryParser::token_source |
Generated Token Manager.