Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-6271

ConjunctionSolrSpellChecker wrong check for same string distance

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

        Issue Links

          Activity

          Hide
          asingh2411 Abhishek Kumar Singh added a comment -

          As of Solr 6.5, this has been changed to stringDistance.equals(checker.getStringDistance()) .

          However, LuceneLevenshteinDistance does not even override equals method.
          This does not solve the problem yet, because this default equals method anyway compares references.

          Show
          asingh2411 Abhishek Kumar Singh added a comment - As of Solr 6.5, this has been changed to stringDistance.equals(checker.getStringDistance()) . However, LuceneLevenshteinDistance does not even override equals method. This does not solve the problem yet, because this default equals method anyway compares references.
          Hide
          asingh2411 Abhishek Kumar Singh added a comment -

          This issue is still occuring in my case, wherein I'm using DirectSolrSpellChecker and FileBasedSpellChecker . The problem is that DirectSolrSpellChecker is using LuceneLavensteinDistance while FileBasedSpellChecker is using LavensteinDistance as the StringDistance.
          This is throwing the IllegalArgumentException( "All checkers need to use the same StringDistance."); .

          What can be the fix to this?

          Show
          asingh2411 Abhishek Kumar Singh added a comment - This issue is still occuring in my case, wherein I'm using DirectSolrSpellChecker and FileBasedSpellChecker . The problem is that DirectSolrSpellChecker is using LuceneLavensteinDistance while FileBasedSpellChecker is using LavensteinDistance as the StringDistance. This is throwing the IllegalArgumentException( "All checkers need to use the same StringDistance."); . What can be the fix to this?
          Hide
          jdyer James Dyer added a comment -

          Thanks Igor & Fabiano for reporting this one.

          Show
          jdyer James Dyer added a comment - Thanks Igor & Fabiano for reporting this one.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

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

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/lucene-solr/pull/135
          Hide
          jira-bot 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
          jira-bot 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
          jira-bot 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
          jira-bot 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
          jdyer 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
          jdyer 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
          gm_coringa 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
          gm_coringa 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
          githubbot 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
          githubbot 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
          mikolajkania 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
          mikolajkania 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 }

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development