Class 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.Inherited Members
Namespace: Lucene.Net.QueryParsers.Ext
Assembly: Lucene.Net.QueryParser.dll
Syntax
public class Extensions
Constructors
Extensions()
Creates a new Extensions instance with the DEFAULT_EXTENSION_FIELD_DELIMITER as a delimiter character.
Declaration
public Extensions()
See Also
Extensions(char)
Creates a new Extensions instance
Declaration
public Extensions(char extensionFieldDelimiter)
Parameters
Type | Name | Description |
---|---|---|
char | extensionFieldDelimiter | the extensions field delimiter character |
See Also
Fields
DEFAULT_EXTENSION_FIELD_DELIMITER
The default extension field delimiter character. This constant is set to ':'
Declaration
public static readonly char DEFAULT_EXTENSION_FIELD_DELIMITER
Field Value
Type | Description |
---|---|
char |
See Also
Properties
ExtensionFieldDelimiter
Returns the extension field delimiter
Declaration
public virtual char ExtensionFieldDelimiter { get; }
Property Value
Type | Description |
---|---|
char |
See Also
Methods
Add(string, ParserExtension)
Adds a new ParserExtension instance associated with the given key.
Declaration
public virtual void Add(string key, ParserExtension extension)
Parameters
Type | Name | Description |
---|---|---|
string | key | the parser extension key |
ParserExtension | extension | the parser extension |
See Also
BuildExtensionField(string)
Builds an extension field string from a given extension key and the default query field. The default field and the key are delimited with the extension field delimiter character. This method makes no assumption about the order of the extension key and the field. By default the extension key is appended to the end of the returned string while the field is added to the beginning. Special Query characters are escaped in the result.
Note: Extensions subclasses must maintain the contract between BuildExtensionField(string) and BuildExtensionField(string, string) where the latter inverts the former.
Declaration
public virtual string BuildExtensionField(string extensionKey)
Parameters
Type | Name | Description |
---|---|---|
string | extensionKey | the extension key |
Returns
Type | Description |
---|---|
string | escaped extension field identifier |
See Also
BuildExtensionField(string, string)
Builds an extension field string from a given extension key and the default query field. The default field and the key are delimited with the extension field delimiter character. This method makes no assumption about the order of the extension key and the field. By default the extension key is appended to the end of the returned string while the field is added to the beginning. Special Query characters are escaped in the result.
Note: Extensions subclasses must maintain the contract between BuildExtensionField(string) and BuildExtensionField(string, string) where the latter inverts the former.
Declaration
public virtual string BuildExtensionField(string extensionKey, string field)
Parameters
Type | Name | Description |
---|---|---|
string | extensionKey | the extension key |
string | field | the field to apply the extension on. |
Returns
Type | Description |
---|---|
string | escaped extension field identifier |
Remarks
See BuildExtensionField(string) to use the default query field
See Also
EscapeExtensionField(string)
Escapes an extension field. The default implementation is equivalent to Escape(string).
Declaration
public virtual string EscapeExtensionField(string extfield)
Parameters
Type | Name | Description |
---|---|---|
string | extfield | the extension field identifier |
Returns
Type | Description |
---|---|
string | the extension field identifier with all special chars escaped with a backslash character. |
See Also
GetExtension(string)
Returns the ParserExtension instance for the given key or
null
if no extension can be found for the key.
Declaration
public ParserExtension GetExtension(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | the extension key |
Returns
Type | Description |
---|---|
ParserExtension | the ParserExtension instance for the given key or if no extension can be found for the key.
|
See Also
SplitExtensionField(string, string)
Splits a extension field and returns the field / extension part as a Tuple{string,string}. This method tries to split on the first occurrence of the extension field delimiter, if the delimiter is not present in the string the result will contain a
null
value for the extension key and
the given field string as the field value. If the given extension field
string contains no field identifier the result pair will carry the given
default field as the field value.
Declaration
public virtual Tuple<string, string> SplitExtensionField(string defaultField, string field)
Parameters
Type | Name | Description |
---|---|---|
string | defaultField | the default query field |
string | field | the extension field string |
Returns
Type | Description |
---|---|
Tuple<string, string> | a {Tuple<T1, T2> with the field name as the Item1 and the extension key as the Item2 |