Solr
  1. Solr
  2. SOLR-604

SpellCheckComponent builds the index in a path relative to CWD

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3
    • Component/s: spellchecker
    • Labels:
      None

      Description

      SpellCheckComponent builds the spell check index inside the current working directory instead of inside the dataDir specified in solrconfig.xml

      It should use the same behavior as the SpellCheckerRequestHandler which is to build the spellcheckIndexDir inside of dataDir.

      To reproduce this behavior use the following config:

       <lst name="spellchecker">
            <str name="classname">org.apache.solr.spelling.FileBasedSpellChecker</str>
            <str name="name">external</str>
            <str name="sourceLocation">spellings.txt</str>
            <str name="characterEncoding">UTF-8</str>
            <str name="spellcheckIndexDir">spellchecker2</str>
          </lst>
      

      The index is created in the CWD/spellchecker2 whereas it should build it inside $

      {solr.data.dir}

      /spellchecker2

      First reported at http://www.nabble.com/SpellCheckComponent%3A-No-file-based-suggestions-%2B-Location-issue-p18048785.html

      1. SOLR-604.patch
        8 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Shalin Shekhar Mangar added a comment - - edited

        The bug lies in AbstractLuceneSpellChecker#initIndex method which uses FSDirectory.getDirectory directly on the spellcheckIndexDir specified in the solrconfig.xml

        This patch adds a method SolrResourceLoader#getDataDir() which returns SolrCore.getDataDir(). The SolrResourceLoader keeps a reference to SolrCore.getDataDir() during inform phase before informing other core-aware classes. The AbstractLuceneSpellChecker class checks if the specified directory is non-null and is relative then it uses SolrResourceLoader#getDataDir() + File.separator + spellcheckIndexDir as the index directory for spellchecker. Also I've added a test in SpellCheckComponentTest for this.

        The other way would have been to modify the SolrSpellChecker#init method to pass in a SolrCore instead of a SolrResourceLoader object but I did not want to change the public signature.

        Show
        Shalin Shekhar Mangar added a comment - - edited The bug lies in AbstractLuceneSpellChecker#initIndex method which uses FSDirectory.getDirectory directly on the spellcheckIndexDir specified in the solrconfig.xml This patch adds a method SolrResourceLoader#getDataDir() which returns SolrCore.getDataDir(). The SolrResourceLoader keeps a reference to SolrCore.getDataDir() during inform phase before informing other core-aware classes. The AbstractLuceneSpellChecker class checks if the specified directory is non-null and is relative then it uses SolrResourceLoader#getDataDir() + File.separator + spellcheckIndexDir as the index directory for spellchecker. Also I've added a test in SpellCheckComponentTest for this. The other way would have been to modify the SolrSpellChecker#init method to pass in a SolrCore instead of a SolrResourceLoader object but I did not want to change the public signature.
        Hide
        Grant Ingersoll added a comment -

        Committed revision 670973.

        Show
        Grant Ingersoll added a comment - Committed revision 670973.

          People

          • Assignee:
            Grant Ingersoll
            Reporter:
            Shalin Shekhar Mangar
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development