Namespace Lucene.Net.QueryParsers.Ext
Classes
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 (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 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.
ExtensionQuery
ExtensionQuery holds all query components extracted from the original query string like the query field and the extension query string.
Extensions
The Extensions class represents an extension mapping to associate ParserExtension instances with extension keys. An extension key is a string encoded into a Lucene standard query parser field symbol recognized by ExtendableQueryParser. The query parser passes each extension field token to SplitExtensionField(String, String) to separate the extension key from the field identifier.
In addition to the key to extension mapping this class also defines the field name overloading scheme. ExtendableQueryParser uses the given extension to split the actual field name and extension key by calling SplitExtensionField(String, String). To change the order or the key / field name encoding scheme users can subclass Extensions to implement their own.
ParserExtension
This class represents an extension base class to the Lucene standard QueryParser. The QueryParser is generated by the JavaCC parser generator. Changing or adding functionality or syntax in the standard query parser requires changes to the JavaCC source file. To enable extending the standard query parser without changing the JavaCC sources and re-generate the parser the ParserExtension can be customized and plugged into an instance of ExtendableQueryParser, a direct subclass of QueryParser.