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
        7 kB
        Koji Sekiguchi
      2. LUCENE-1398.patch
        10 kB
        Koji Sekiguchi
      3. LUCENE-1398.patch
        5 kB
        Koji Sekiguchi

        Activity

        Koji Sekiguchi created issue -
        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 ); } }
        Koji Sekiguchi made changes -
        Field Original Value New Value
        Attachment LUCENE-1398.patch [ 12390607 ]
        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.
        Koji Sekiguchi made changes -
        Attachment LUCENE-1398.patch [ 12400470 ]
        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.
        Koji Sekiguchi made changes -
        Attachment LUCENE-1398.patch [ 12400940 ]
        Hide
        Yonik Seeley added a comment -

        Thanks, I just committed this.

        Show
        Yonik Seeley added a comment - Thanks, I just committed this.
        Yonik Seeley made changes -
        Fix Version/s 2.9 [ 12312682 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mark Miller made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12442547 ] Default workflow, editable Closed status [ 12562999 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12562999 ] jira [ 12583871 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        156d 14h 16m 1 Yonik Seeley 25/Feb/09 20:44
        Resolved Resolved Closed Closed
        211d 19h 38m 1 Mark Miller 25/Sep/09 17:23

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development