Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9
    • Component/s: modules/analysis
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      add ReverseStringFilter and ReverseStringAnalyzer that can be used for backword much. For Example, "*ry", "*ing", "*ber".

      1. LUCENE-1398.patch
        5 kB
        Koji Sekiguchi
      2. LUCENE-1398.patch
        10 kB
        Koji Sekiguchi
      3. LUCENE-1398.patch
        7 kB
        Koji Sekiguchi

        Activity

        Hide
        Koji Sekiguchi added a comment -

        Patch attached. The patch includes a new constructor of PrefixQuery:

        public PrefixQuery(Term prefix, boolean reverse) {
          if(reverse){
            String s = prefix.text();
            int len = s.length();
            if( len <= 1 ){
              this.prefix = prefix;
              return;
            }
            StringBuffer sb = new StringBuffer(len);
            for( int i = 0; i < len; i++ ){
              sb.append( s.charAt( len - i - 1 ) );
            }
            this.prefix = new Term(prefix.field(),sb.toString());
          }
          else
            this.prefix = prefix;
          }
        

        so that you can extend PrefixQuery to have SuffixQuery:

        class SuffixQuery extends PrefixQuery {
          public SuffixQuery( Term term ){
            super( term, true );
          }
        }
        
        Show
        Koji Sekiguchi added a comment - Patch attached. The patch includes a new constructor of PrefixQuery: public PrefixQuery(Term prefix, boolean reverse) { if (reverse){ String s = prefix.text(); int len = s.length(); if ( len <= 1 ){ this .prefix = prefix; return ; } StringBuffer sb = new StringBuffer (len); for ( int i = 0; i < len; i++ ){ sb.append( s.charAt( len - i - 1 ) ); } this .prefix = new Term(prefix.field(),sb.toString()); } else this .prefix = prefix; } so that you can extend PrefixQuery to have SuffixQuery: class SuffixQuery extends PrefixQuery { public SuffixQuery( Term term ){ super ( term, true ); } }
        Hide
        Mark Miller added a comment -

        I like the idea of adding this, but I almost think it might best live in contrib. Thats slightly at odds with the prefix query addition - but I'm not sure that really helps you to integrate the solution generally into the query language anyway - it just reverses the term. I think it might be better to leave that to the user, as its likely to remain a special case anyway. I'd rather even do something like a util reverse method.

        So I'll hold out for a wiser opinion, but my initial thought would be to not add to prefixquery, and put the the analyzer in contrib

        Show
        Mark Miller added a comment - I like the idea of adding this, but I almost think it might best live in contrib. Thats slightly at odds with the prefix query addition - but I'm not sure that really helps you to integrate the solution generally into the query language anyway - it just reverses the term. I think it might be better to leave that to the user, as its likely to remain a special case anyway. I'd rather even do something like a util reverse method. So I'll hold out for a wiser opinion, but my initial thought would be to not add to prefixquery, and put the the analyzer in contrib
        Hide
        Koji Sekiguchi added a comment -

        Thanks Mark for the comment and sorry for late reply. Move it to contrib.

        Show
        Koji Sekiguchi added a comment - Thanks Mark for the comment and sorry for late reply. Move it to contrib.
        Hide
        Yonik Seeley added a comment -

        I don't know how others feel, but I'd personally like to stop the practice of making more Analyzer classes whenever a new TokenFilter is added.

        This patch looks like it could/should be a single class (other than test of course): ReverseTokenFilter. The static reverse() methods could be put directly on that filter.

        Show
        Yonik Seeley added a comment - I don't know how others feel, but I'd personally like to stop the practice of making more Analyzer classes whenever a new TokenFilter is added. This patch looks like it could/should be a single class (other than test of course): ReverseTokenFilter. The static reverse() methods could be put directly on that filter.
        Hide
        Koji Sekiguchi added a comment -

        I don't know how others feel, but I'd personally like to stop the practice of making more Analyzer classes whenever a new TokenFilter is added.

        This patch looks like it could/should be a single class (other than test of course): ReverseTokenFilter. The static reverse() methods could be put directly on that filter.

        No problem for me. Done.

        Show
        Koji Sekiguchi added a comment - I don't know how others feel, but I'd personally like to stop the practice of making more Analyzer classes whenever a new TokenFilter is added. This patch looks like it could/should be a single class (other than test of course): ReverseTokenFilter. The static reverse() methods could be put directly on that filter. No problem for me. Done.
        Hide
        Yonik Seeley added a comment -

        Thanks, I just committed this.

        Show
        Yonik Seeley added a comment - Thanks, I just committed this.

          People

          • Assignee:
            Unassigned
            Reporter:
            Koji Sekiguchi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development