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.
Inheritance
Inherited Members
Namespace: Lucene.Net.QueryParsers.Ext
Assembly: Lucene.Net.QueryParser.dll
Syntax
public class Extensions
Constructors
| Improve this Doc View SourceExtensions()
Creates a new Extensions instance with the DEFAULT_EXTENSION_FIELD_DELIMITER as a delimiter character.
Declaration
public Extensions()
Extensions(Char)
Creates a new Extensions instance
Declaration
public Extensions(char extensionFieldDelimiter)
Parameters
Type | Name | Description |
---|---|---|
System.Char | extensionFieldDelimiter | the extensions field delimiter character |
Fields
| Improve this Doc View SourceDEFAULT_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 |
---|---|
System.Char |
Properties
| Improve this Doc View SourceExtensionFieldDelimiter
Returns the extension field delimiter
Declaration
public virtual char ExtensionFieldDelimiter { get; }
Property Value
Type | Description |
---|---|
System.Char |
Methods
| Improve this Doc View SourceAdd(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 |
---|---|---|
System.String | key | the parser extension key |
ParserExtension | extension | the parser extension |
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 |
---|---|---|
System.String | extensionKey | the extension key |
Returns
Type | Description |
---|---|
System.String | escaped extension field identifier |
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 |
---|---|---|
System.String | extensionKey | the extension key |
System.String | field | the field to apply the extension on. |
Returns
Type | Description |
---|---|
System.String | escaped extension field identifier |
Remarks
See BuildExtensionField(String) to use the default query field
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 |
---|---|---|
System.String | extfield | the extension field identifier |
Returns
Type | Description |
---|---|
System.String | the extension field identifier with all special chars escaped with a backslash character. |
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 |
---|---|---|
System.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. |
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 |
---|---|---|
System.String | defaultField | the default query field |
System.String | field | the extension field string |
Returns
Type | Description |
---|---|
System.Tuple<System.String, System.String> | a {System.Tuple<T1, T2> with the field name as the System.Tuple`2.Item1 and the extension key as the System.Tuple`2.Item2 |