Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-513

GetFieldQuery in MultiFieldQueryParser not handle properly Boosts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Lucene.Net 3.0.3
    • None
    • Lucene.Net Core
    • None

    Description

      Regression between Lucene 2.9.4g and Lucene 3.0.3 in the method GetFieldQuery of MultiFieldQueryParser with the boosts factor.

      public class MultiFieldQueryParser : QueryParser {
      
         protected internal override Query GetFieldQuery(string field, string queryText, int slop)
              {
       ...
                              //If the user passes a map of boosts
                              if (boosts != null)
                              {
                                  //Get the boost from the map and apply them
                                  Single boost = boosts[fields[i]];
                                  q.Boost = boost;
                              }
      ...
      

      If all fields don't have a boost factor an exception is throw by "Single boost = boosts[fields[i]];"
      In version 2.9.4g, a check was performed, and no boost were apply if the field is not boosted.

      I added a patch with the following modification:

      //Get the boost and apply them if exists
      float boost;
      if (boosts.TryGetValue(fields[i], out boost))
         q.Boost = boost;
      

      Attachments

        1. LUCENENET-513-Fix.patch
          2 kB
          Hadrien HUGOT

        Activity

          People

            Unassigned Unassigned
            hadrien.hugot Hadrien HUGOT
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: