C# Class Lucene.Net.QueryParsers.Ext.ExtendableQueryParser

The ExtendableQueryParser enables arbitrary query parser extension based on a customizable field naming scheme. The lucene query syntax allows implicit and explicit field definitions as query prefix followed by a colon (':') character. The ExtendableQueryParser allows to encode extension keys into the field symbol associated with a registered instance of ParserExtension. A customizable separation character separates the extension key from the actual field symbol. The ExtendableQueryParser splits (Extensions.SplitExtensionField(string, string)) the extension key from the field symbol and tries to resolve the associated ParserExtension. If the parser can't resolve the key or the field token does not contain a separation character, ExtendableQueryParser yields the same behavior as its super class QueryParser. Otherwise, if the key is associated with a ParserExtension instance, the parser builds an instance of ExtensionQuery to be processed by ParserExtension.Parse(ExtensionQuery).If a extension field does not contain a field part the default field for the query will be used.

To guarantee that an extension field is processed with its associated extension, the extension query part must escape any special characters like '*' or '['. If the extension query contains any whitespace characters, the extension query part must be enclosed in quotes. Example ('_' used as separation character):

 title_customExt:"Apache Lucene\?" OR content_customExt:prefix\* 
Search on the default field:
 _customExt:"Apache Lucene\?" OR _customExt:prefix\* 

The ExtendableQueryParser itself does not implement the logic how field and extension key are separated or ordered. All logic regarding the extension key and field symbol parsing is located in Extensions. Customized extension schemes should be implemented by sub-classing Extensions.

For details about the default encoding scheme see Extensions.

Extensions ParserExtension ExtensionQuery
Inheritance: Classic.QueryParser
显示文件 Open project: apache/lucenenet Class Usage Examples

Public Methods

Method Description
ExtendableQueryParser ( LuceneVersion matchVersion, string f, Analyzer a ) : Lucene.Net.Analysis

Creates a new ExtendableQueryParser instance

ExtendableQueryParser ( LuceneVersion matchVersion, string f, Analyzer a, Extensions ext ) : Lucene.Net.Analysis

Creates a new ExtendableQueryParser instance

Protected Methods

Method Description
GetFieldQuery ( string field, string queryText, bool quoted ) : Query

Method Details

ExtendableQueryParser() public method

Creates a new ExtendableQueryParser instance
public ExtendableQueryParser ( LuceneVersion matchVersion, string f, Analyzer a ) : Lucene.Net.Analysis
matchVersion LuceneVersion the lucene version to use.
f string the default query field
a Lucene.Net.Analysis.Analyzer the analyzer used to find terms in a query string
return Lucene.Net.Analysis

ExtendableQueryParser() public method

Creates a new ExtendableQueryParser instance
public ExtendableQueryParser ( LuceneVersion matchVersion, string f, Analyzer a, Extensions ext ) : Lucene.Net.Analysis
matchVersion LuceneVersion the lucene version to use.
f string the default query field
a Lucene.Net.Analysis.Analyzer the analyzer used to find terms in a query string
ext Extensions the query parser extensions
return Lucene.Net.Analysis

GetFieldQuery() protected method

protected GetFieldQuery ( string field, string queryText, bool quoted ) : Query
field string
queryText string
quoted bool
return Lucene.Net.Search.Query