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 Version compatibility when creating ReverseStringFilter, or when using any of its static methods:

  • As of 3.1, supplementary characters are handled correctly

Inheritance: TokenFilter
        public virtual void TestFilterWithMark()
        {
            TokenStream         stream = new MockTokenizer(new StringReader("Do have a nice day"), MockTokenizer.WHITESPACE, false); // 1-4 length string
            ReverseStringFilter filter = new ReverseStringFilter(TEST_VERSION_CURRENT, stream, '\u0001');

            AssertTokenStreamContents(filter, new string[] { "\u0001oD", "\u0001evah", "\u0001a", "\u0001ecin", "\u0001yad" });
        }
 public virtual void TestReverseSupplementary()
 {
     // supplementary at end
     assertEquals("𩬅艱鍟䇹愯瀛", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "瀛愯䇹鍟艱𩬅"));
     // supplementary at end - 1
     assertEquals("a𩬅艱鍟䇹愯瀛", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "瀛愯䇹鍟艱𩬅a"));
     // supplementary at start
     assertEquals("fedcba𩬅", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "𩬅abcdef"));
     // supplementary at start + 1
     assertEquals("fedcba𩬅z", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "z𩬅abcdef"));
     // supplementary medial
     assertEquals("gfe𩬅dcba", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "abcd𩬅efg"));
 }
 public virtual void TestReverseSupplementaryChar()
 {
     // supplementary at end
     char[] buffer = "abc瀛愯䇹鍟艱𩬅".ToCharArray();
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 3, 7);
     assertEquals("abc𩬅艱鍟䇹愯瀛", new string(buffer));
     // supplementary at end - 1
     buffer = "abc瀛愯䇹鍟艱𩬅d".ToCharArray();
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 3, 8);
     assertEquals("abcd𩬅艱鍟䇹愯瀛", new string(buffer));
     // supplementary at start
     buffer = "abc𩬅瀛愯䇹鍟艱".ToCharArray();
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 3, 7);
     assertEquals("abc艱鍟䇹愯瀛𩬅", new string(buffer));
     // supplementary at start + 1
     buffer = "abcd𩬅瀛愯䇹鍟艱".ToCharArray();
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 3, 8);
     assertEquals("abc艱鍟䇹愯瀛𩬅d", new string(buffer));
     // supplementary medial
     buffer = "abc瀛愯𩬅def".ToCharArray();
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 3, 7);
     assertEquals("abcfed𩬅愯瀛", new string(buffer));
 }
 public virtual void TestBackCompat()
 {
     assertEquals("\uDF05\uD866\uDF05\uD866", ReverseStringFilter.Reverse(LuceneVersion.LUCENE_30, "𩬅𩬅"));
 }
 public virtual void TestReverseChar()
 {
     char[] buffer = new char[] { 'A', 'B', 'C', 'D', 'E', 'F' };
     ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, buffer, 2, 3);
     assertEquals("ABEDCF", new string(buffer));
 }
 public virtual void TestReverseString()
 {
     assertEquals("A", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "A"));
     assertEquals("BA", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "AB"));
     assertEquals("CBA", ReverseStringFilter.Reverse(TEST_VERSION_CURRENT, "ABC"));
 }