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

Custom similarity is ignored when using MultiSearcher

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      Patch Available

      Description

      Symptoms:
      I am using Searcher.setSimilarity() to provide a custom similarity that turns off tf() factor. However, somewhere along the way the custom similarity is ignored and the DefaultSimilarity is used. I am using MultiSearcher and BooleanQuery.

      Problem analysis:
      The problem seems to be in MultiSearcher.createWeight(Query) method. It creates an instance of CachedDfSource but does not set the similarity. As the result CachedDfSource provides DefaultSimilarity to queries that use it.

      Potential solution:
      Adding the following line:
      cacheSim.setSimilarity(getSimilarity());
      after creating an instance of CacheDfSource (line 312) seems to fix the problem. However, I don't understand enough of the inner workings of this class to be absolutely sure that this is the right thing to do.

        Attachments

        1. 789_patch.txt
          3 kB
          Doron Cohen
        2. TestMultiSearcherSimilarity.java
          3 kB
          Alexey Lef

          Activity

            People

            • Assignee:
              doronc Doron Cohen
              Reporter:
              alexeylef Alexey Lef
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: