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

Multiplicative boost of isn't applied when one of the summed or multiplied queries doesn't match



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 7.3, 7.4, 7.5, 7.6, 7.7, 7.7.1
    • 7.7.2, 8.0
    • search
    • None
    • Reproduced with macOS 10.14.1, a quick test with Windows 10 showed the same result.


      Under certain circumstances search results from queries with multiple multiplicative boosts using the Solr functions product() and query() result in a score that is inconsistent with the one from the debugQuery information. Also only the debug score is correct while the actual search results show a wrong score.

      This seems somewhat similar to the behaviour described in https://issues.apache.org/jira/browse/LUCENE-7132, though this issue has been resolved a while ago.

      A little background: we are using Solr as a search platform for the e-commerce framework SAP Hybris. There the shop administrator can create multiplicative boost rules (see below for an example) where a value like 2.0 means that an item gets boosted to 200%. This works fine in the demo shop distributed by SAP but breaks in our shop. We encountered the issue when Upgrading from Solr 7.2.1 / Hybris 6.7 to Solr 7.5 / Hybris 18.8.3 (which would have been named Hybris 6.8 but the version naming schema changed).

      We reduced the Solr query generated by Hybris to the relevant parts and could reproduce the issue in the Solr admin without any Hybris connection.

      I attached the JSON result of a test query but here's a description of the parts that seemed most relevant to me.

      The responseHeader.params reads (slightly rearranged):

      "q":"{!boost b=$ymb}(+{!lucene v=$yq})",
      "sort":"score desc",
      // Added to keep the output small but probably unrelated to the actual issue

      This example boosts the German product name (field name_text_de) in case in contains certain terms:

      • "Netzteil" (power supply) is boosted to 200%
      • "Sony" is boosted to 300%

      Consequently a product containing both terms should be boosted to 600%.

      Also the query function has the value 1 specified as default in case the name does not contain the respective term resulting in a pseudo boost that preserves the score.

      According to the debug information the parser used is the LuceneQParser, which translates this to the following parsed query:

      FunctionScoreQuery(FunctionScoreQuery(+:, scored by boost(product(query((ConstantScore(name_text_de:netzteil))^2.0,def=1.0),query((ConstantScore(name_text_de:sony))^3.0,def=1.0)))))

      And the translated boost is:


      When taking a look at the search result, among other the following products are included (see the JSON comments for an analysis of each result):

              "name_text_de":"Original Sony Vaio Netzteil",
              // CORRECT, both "Netzteil" and "Sony" are included in the name
              "name_text_de":"Steuertestprodukt Zwei",
              // CORRECT, neither "Netzteil" nor "Sony" are included in the name
              "name_text_de":"GS-Netzteil 20W schwarz",
              // WRONG, "Netzteil" is part of the name; 
              // note that we do split words on hyphen because 
              // WordDelimiterGraphFilterFactory.generateWordParts="1"

      So apparently the multiplicative boost works for product names where all the boosted terms are included but fails if only one of the terms matches.

      There are also other products in the result that contain either "Netzteil" or "Sony" but still get a score of 1.0 instead of 2.0 resp. 3.0.

      Surprisingly in the explain segment the score for the product with "Netzteil" but without "Sony" correctly is 2.0:

      2.0 = product of:
        1.0 = boost
        2.0 = product of:
          1.0 = *:*
          2.0 = product(query((ConstantScore(name_text_de:netzteil))^2.0,def=1.0)=2.0,query((ConstantScore(name_text_de:sony))^3.0,def=1.0)=1.0)

      The type definition of text_de in the schema.xml (which is used for "name_text_de") includes the following filters:

      <fieldType name="text_de" class="solr.TextField" positionIncrementGap="100">
              <tokenizer class="solr.WhitespaceTokenizerFactory" />
              <filter class="solr.WordDelimiterGraphFilterFactory"  preserveOriginal="1"
                      generateWordParts="1" generateNumberParts="1" catenateWords="1"
                      catenateNumbers="1" catenateAll="0" splitOnCaseChange="1" />
              <filter class="solr.LowerCaseFilterFactory" />

      The solrconfig.xml mostly is taken form the Hybris defaults and AFAIK does not do anything kinky. The following lines might be of interest:

      <queryParser name="multiMaxScore" class="de.hybris.platform.solr.search.MultiMaxScoreQParserPlugin"/>

      To sum it up, my expectation would have been:

      • The score in the result and explain section are identical.
      • Names matching only one of the two multiplied boost terms are receive the respective single boost instead of the default score 1.0.


        1. 0001-use-deprecated-classes-to-fix-regression-introduced-.patch
          43 kB
          Thomas Aglassinger
        2. 0002-SOLR-13126-Added-test-case.patch
          2 kB
          Thomas Aglassinger
        3. 2019-02-14_1715.png
          13 kB
          Aliaksandr Asiptsou
        4. debugQuery.json
          7 kB
          Thomas Aglassinger
        5. image-2019-02-13-16-17-56-272.png
          77 kB
          Tom Burgmans
        6. screenshot-1.png
          106 kB
          Tom Burgmans
        7. solr_match_neither_nextteil_nor_sony.json
          0.7 kB
          Thomas Aglassinger
        8. solr_match_neither_nextteil_nor_sony.txt
          23 kB
          Thomas Aglassinger
        9. solr_match_netzteil_and_sony.json
          0.7 kB
          Thomas Aglassinger
        10. solr_match_netzteil_and_sony.txt
          30 kB
          Thomas Aglassinger
        11. solr_match_netzteil_only.json
          0.7 kB
          Thomas Aglassinger
        12. solr_match_netzteil_only.txt
          23 kB
          Thomas Aglassinger
        13. SOLR-13126.patch
          2 kB
          Alan Woodward
        14. SOLR-13126.patch
          3 kB
          Mikhail Khludnev

        Issue Links



              romseygeek Alan Woodward
              roskakori Thomas Aglassinger
              2 Vote for this issue
              15 Start watching this issue