Solr
  1. Solr
  2. SOLR-6271

ConjunctionSolrSpellChecker wrong check for same string distance

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.9
    • Fix Version/s: 5.5
    • Component/s: spellchecker
    • Labels:
      None

      Description

      See ConjunctionSolrSpellChecker.java

      try {
      if (stringDistance == null)

      { stringDistance = checker.getStringDistance(); }

      else if (stringDistance != checker.getStringDistance())

      { throw new IllegalArgumentException( "All checkers need to use the same StringDistance."); }

      } catch (UnsupportedOperationException uoe)

      { // ignore }

      In line stringDistance != checker.getStringDistance() there is comparing by references. So if you are using 2 or more spellcheckers with same distance algorithm, exception will be thrown anyway.

      1. SOLR-6271.patch
        4 kB
        James Dyer
      2. SOLR-6271.patch
        4 kB
        Fabiano V. Santos

        Activity

        Hide
        Mikołaj Kania added a comment - - edited

        This is especially a problem when you want to use DirectSolrSpellChecker with FileBasedSpellChecker. What make things interesting is that WordBreakSpellChecker works fine beacuse its getStringDistance() method throws UnsupportedOperationException, and in ConjunctionSolrSpellChecker there is that work-around for this:

        try {
              if (stringDistance == null) {
                stringDistance = checker.getStringDistance();
              } else if (stringDistance != checker.getStringDistance()) {
                throw new IllegalArgumentException(
                    "All checkers need to use the same StringDistance.");
              }
            } catch (UnsupportedOperationException uoe) {
              // ignore
            }
        
        Show
        Mikołaj Kania added a comment - - edited This is especially a problem when you want to use DirectSolrSpellChecker with FileBasedSpellChecker. What make things interesting is that WordBreakSpellChecker works fine beacuse its getStringDistance() method throws UnsupportedOperationException, and in ConjunctionSolrSpellChecker there is that work-around for this: try { if (stringDistance == null ) { stringDistance = checker.getStringDistance(); } else if (stringDistance != checker.getStringDistance()) { throw new IllegalArgumentException( "All checkers need to use the same StringDistance." ); } } catch (UnsupportedOperationException uoe) { // ignore }
        Hide
        ASF GitHub Bot added a comment -

        GitHub user gmcoringa opened a pull request:

        https://github.com/apache/lucene-solr/pull/135

        SOLR-6271: ConjunctionSolrSpellChecker wrong check for same string distance

        ConjunctionSolrSpellChecher now uses equals method to check for same string distance.

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/elo7/lucene-solr SOLR-6271

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/lucene-solr/pull/135.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #135


        commit 1856fc9bf18dd3d2528c1200e11b15ec122b9b2c
        Author: Fabiano V. Santos <tech+gmcoringa@elo7.com>
        Date: 2015-03-17T16:44:09Z

        ConjunctionSolrSpellChecher now uses equals method to check for same string distance


        Show
        ASF GitHub Bot added a comment - GitHub user gmcoringa opened a pull request: https://github.com/apache/lucene-solr/pull/135 SOLR-6271 : ConjunctionSolrSpellChecker wrong check for same string distance ConjunctionSolrSpellChecher now uses equals method to check for same string distance. You can merge this pull request into a Git repository by running: $ git pull https://github.com/elo7/lucene-solr SOLR-6271 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/lucene-solr/pull/135.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #135 commit 1856fc9bf18dd3d2528c1200e11b15ec122b9b2c Author: Fabiano V. Santos <tech+gmcoringa@elo7.com> Date: 2015-03-17T16:44:09Z ConjunctionSolrSpellChecher now uses equals method to check for same string distance
        Hide
        Fabiano V. Santos added a comment -

        Patch based on trunk version from git commit 1e79536e2371737a3732369a0db4022a257be1fe

        Also was created a pull request: https://github.com/apache/lucene-solr/pull/135

        Show
        Fabiano V. Santos added a comment - Patch based on trunk version from git commit 1e79536e2371737a3732369a0db4022a257be1fe Also was created a pull request: https://github.com/apache/lucene-solr/pull/135
        Hide
        James Dyer added a comment -

        Here is an updated patch with a slightly different unit test.

        This is a trivial fix, but important if we ever implement multiple dictionaries: SOLR-1074 / SOLR-2106 .

        Show
        James Dyer added a comment - Here is an updated patch with a slightly different unit test. This is a trivial fix, but important if we ever implement multiple dictionaries: SOLR-1074 / SOLR-2106 .
        Hide
        ASF subversion and git services added a comment -

        Commit 1717999 from jdyer@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1717999 ]

        SOLR-6271: fix StringDistance comparison in CSSC. ( This closes #135 )

        Show
        ASF subversion and git services added a comment - Commit 1717999 from jdyer@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1717999 ] SOLR-6271 : fix StringDistance comparison in CSSC. ( This closes #135 )
        Hide
        ASF subversion and git services added a comment -

        Commit 1718000 from jdyer@apache.org in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1718000 ]

        SOLR-6271: fix StringDistance comparison in CSSC. ( This closes #135 )

        Show
        ASF subversion and git services added a comment - Commit 1718000 from jdyer@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1718000 ] SOLR-6271 : fix StringDistance comparison in CSSC. ( This closes #135 )
        Hide
        ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/lucene-solr/pull/135

        Show
        ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/lucene-solr/pull/135
        Hide
        James Dyer added a comment -

        Thanks Igor & Fabiano for reporting this one.

        Show
        James Dyer added a comment - Thanks Igor & Fabiano for reporting this one.

          People

          • Assignee:
            James Dyer
            Reporter:
            Igor Kostromin
          • Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development