Class ReverseStringFilter
Reverse token string, for example "country" => "yrtnuoc".
If marker is supplied, then tokens will be also prepended by that character. For example, with a marker of \u0001, "country" => "\u0001yrtnuoc". This is useful when implementing efficient leading wildcards search.
You must specify the required Lucene.Net.Util.LuceneVersion compatibility when creating ReverseStringFilter, or when using any of its static methods:
- As of 3.1, supplementary characters are handled correctly
Implements
Inherited Members
Namespace: Lucene.Net.Analysis.Reverse
Assembly: Lucene.Net.Analysis.Common.dll
Syntax
public sealed class ReverseStringFilter : TokenFilter, IDisposable
Constructors
ReverseStringFilter(LuceneVersion, TokenStream)
Create a new ReverseStringFilter that reverses all tokens in the supplied Lucene.Net.Analysis.TokenStream.
The reversed tokens will not be marked.
Declaration
public ReverseStringFilter(LuceneVersion matchVersion, TokenStream @in)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
TokenStream | in | Lucene.Net.Analysis.TokenStream to filter |
ReverseStringFilter(LuceneVersion, TokenStream, char)
Create a new ReverseStringFilter that reverses and marks all tokens in the supplied Lucene.Net.Analysis.TokenStream.
The reversed tokens will be prepended (marked) by the marker
character.
Declaration
public ReverseStringFilter(LuceneVersion matchVersion, TokenStream @in, char marker)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
TokenStream | in | Lucene.Net.Analysis.TokenStream to filter |
char | marker | A character used to mark reversed tokens |
Fields
INFORMATION_SEPARATOR_MARKER
Example marker character: U+001F (INFORMATION SEPARATOR ONE)
Declaration
public const char INFORMATION_SEPARATOR_MARKER = '\u001f'
Field Value
Type | Description |
---|---|
char |
PUA_EC00_MARKER
Example marker character: U+EC00 (PRIVATE USE AREA: EC00)
Declaration
public const char PUA_EC00_MARKER = ''
Field Value
Type | Description |
---|---|
char |
RTL_DIRECTION_MARKER
Example marker character: U+200F (RIGHT-TO-LEFT MARK)
Declaration
public const char RTL_DIRECTION_MARKER = ''
Field Value
Type | Description |
---|---|
char |
START_OF_HEADING_MARKER
Example marker character: U+0001 (START OF HEADING)
Declaration
public const char START_OF_HEADING_MARKER = '\u0001'
Field Value
Type | Description |
---|---|
char |
Methods
IncrementToken()
Consumers (i.e., Lucene.Net.Index.IndexWriter) use this method to advance the stream to the next token. Implementing classes must implement this method and update the appropriate Lucene.Net.Util.IAttributes with the attributes of the next token.
The producer must make no assumptions about the attributes after the method has been returned: the caller may arbitrarily change it. If the producer needs to preserve the state for subsequent calls, it can use Lucene.Net.Util.AttributeSource.CaptureState() to create a copy of the current attribute state. this method is called for every token of a document, so an efficient implementation is crucial for good performance. To avoid calls to Lucene.Net.Util.AttributeSource.AddAttribute<T>() and Lucene.Net.Util.AttributeSource.GetAttribute<T>(), references to all Lucene.Net.Util.IAttributes that this stream uses should be retrieved during instantiation. To ensure that filters and consumers know which attributes are available, the attributes must be added during instantiation. Filters and consumers are not required to check for availability of attributes in Lucene.Net.Analysis.TokenStream.IncrementToken().Declaration
public override bool IncrementToken()
Returns
Type | Description |
---|---|
bool | false for end of stream; true otherwise |
Overrides
Reverse(LuceneVersion, char[])
Reverses the given input buffer in-place
Declaration
public static void Reverse(LuceneVersion matchVersion, char[] buffer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
char[] | buffer | the input char array to reverse |
Reverse(LuceneVersion, char[], int)
Partially reverses the given input buffer in-place from offset 0 up to the given length.
Declaration
public static void Reverse(LuceneVersion matchVersion, char[] buffer, int len)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
char[] | buffer | the input char array to reverse |
int | len | the length in the buffer up to where the buffer should be reversed |
Reverse(LuceneVersion, char[], int, int)
Partially reverses the given input buffer in-place from the given offset up to the given length.
Declaration
public static void Reverse(LuceneVersion matchVersion, char[] buffer, int start, int len)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
char[] | buffer | the input char array to reverse |
int | start | the offset from where to reverse the buffer |
int | len | the length in the buffer up to where the buffer should be reversed |
Reverse(LuceneVersion, string)
Reverses the given input string
Declaration
public static string Reverse(LuceneVersion matchVersion, string input)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | lucene compatibility version |
string | input | the string to reverse |
Returns
Type | Description |
---|---|
string | the given input string in reversed order |