Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1152

SpellChecker does not work properly on calling indexDictionary after clearIndex

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: modules/spellchecker
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      We have to call clearIndex and indexDictionary to rebuild dictionary from fresh. The call to SpellChecker clearIndex() function does not reset the searcher. Hence, when we call indexDictionary after that, many entries that are already in the stale searcher will not be indexed.

      Also, I see that IndexReader reader is used for the sole purpose of obtaining the docFreq of a given term in exist() function. This functionality can also be obtained by using just the searcher by calling searcher.docFreq. Thus, can we get away completely with reader and code associated with it like
      if (IndexReader.isLocked(spellIndex))

      { IndexReader.unlock(spellIndex); }

      and the reader related code in finalize?

      1. spellchecker.diff
        2 kB
        Naveen Belkale
      2. spellchecker.diff
        3 kB
        Naveen Belkale

        Activity

        Hide
        belkale Naveen Belkale added a comment -

        Suggested patch.

        Show
        belkale Naveen Belkale added a comment - Suggested patch.
        Hide
        belkale Naveen Belkale added a comment - - edited

        One more small query. We have requirement where we have to add new words to our dictionary quite frequently. So multiple threads may concurrently call indexDictionary. This will cause problems as each call to indexDictionary will create a new IndexWriter. So is it possible to make indexDictionary function synchronized? Like this
        public synchronized void indexDictionary(Dictionary dict) throws IOException {
        ........

        Show
        belkale Naveen Belkale added a comment - - edited One more small query. We have requirement where we have to add new words to our dictionary quite frequently. So multiple threads may concurrently call indexDictionary. This will cause problems as each call to indexDictionary will create a new IndexWriter. So is it possible to make indexDictionary function synchronized? Like this public synchronized void indexDictionary(Dictionary dict) throws IOException { ........
        Hide
        otis Otis Gospodnetic added a comment -

        This patch no longer applies. Could you provide a new patch (against trunk)? Also, please use 2-spaces for indentation. Thanks.

        As for synchronizing indexDictionary method, why not add synchronization logic to your application?

        Show
        otis Otis Gospodnetic added a comment - This patch no longer applies. Could you provide a new patch (against trunk)? Also, please use 2-spaces for indentation. Thanks. As for synchronizing indexDictionary method, why not add synchronization logic to your application?
        Hide
        belkale Naveen Belkale added a comment -

        Suggested patch against trunk

        Show
        belkale Naveen Belkale added a comment - Suggested patch against trunk
        Hide
        otis Otis Gospodnetic added a comment -

        Thank you for the patch!

        Committed revision 659013.

        Show
        otis Otis Gospodnetic added a comment - Thank you for the patch! Committed revision 659013.

          People

          • Assignee:
            otis Otis Gospodnetic
            Reporter:
            belkale Naveen Belkale
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development