Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizers: attribute based logarithm scale function should be "log1p" instead of "log" #1635

Closed
rbayet opened this issue Dec 9, 2019 · 0 comments
Assignees

Comments

@rbayet
Copy link
Collaborator

rbayet commented Dec 9, 2019

With a scale factor of 1, using an attribute based search optimizer with "logarithmic" scale function reduces the fulltext score of products to 0.
That is because the "missing" value is "1 / $scaleFactor", the field_value_factor with the "log" function ends up being 1 * log(1) (scaleFactor * log(fieldValue)) :

    public function getFunction(ContainerConfigurationInterface $containerConfiguration, OptimizerInterface $optimizer)
    {
        $field       = $this->getField($containerConfiguration, $optimizer);
        $scaleFactor = (float) $optimizer->getConfig('scale_factor');

        $function = [
            'field_value_factor' => [
                'field'    => $field,
                'factor'   => $scaleFactor,
                'modifier' => $optimizer->getConfig('scale_function'),
                'missing'  => 1 / $scaleFactor,
            ],
            'filter' => $optimizer->getRuleCondition()->getSearchQuery(),
        ];

        return $function;
    }

Since log(1) = 0 and the boost function is applied in multiply mode, it multiplies the fulltext _score to 0 :

  • the products with an attribute value > 2 are correctly sorted / boosted
  • the products without a value of with a value of 1 all have a _score of 0 and so are no longer sorted according to their base fulltext relevancy

Preconditions

Magento Version : EE 2.3.x

ElasticSuite Version : 2.8.x

Environment : Developer/Production

Third party modules : N/A

Steps to reproduce

  1. Create a numeric attribute and add it to a type of products returned by a well-known search query generating more than 1 page of search results
  2. Observe the order of search results and pick 3 products on the first page, give them a value of respectively 300, 20 and 1 for the numeric attribute
  3. Create an attribute based search optimizer with a scale factor of 1 and the "logarithmic" scale function, enable it
  4. Perform again the fulltext search

Expected result

  1. The 3 products should move up in the search results page and the other products relative position should only impacted by that

Actual result

  1. The products with a value of 300 and 20 are indeed boosted and put in the first positions
  2. The product with a value of 1 does not seem to be boosted
  3. All the other search results are no longer those expected, seemingly displayed at random (actually: by their product id ascending)
@rbayet rbayet self-assigned this Dec 9, 2019
romainruaud added a commit that referenced this issue Dec 10, 2019
…ers_logarithmic_function

Fixes #1635 log1p instead of log for logarithmic fn
rbayet added a commit to rbayet/elasticsuite that referenced this issue Dec 20, 2019
romainruaud added a commit that referenced this issue Dec 20, 2019
…ers_logarithmic_function_2_2_backport

Fixes #1635 log1p instead of log for logarithmic fn (2.2.x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant