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

Add min_score support #2917

Closed
romainruaud opened this issue Apr 21, 2023 · 2 comments
Closed

Add min_score support #2917

romainruaud opened this issue Apr 21, 2023 · 2 comments
Assignees
Labels

Comments

@romainruaud
Copy link
Collaborator

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-search.html#search-api-min-score

This would allow to prevent having too much results. This can be useful for some customers.

@romainruaud
Copy link
Collaborator Author

  1. Add a configuration for "min_score" in the Elasticsuite relevance config :

This should be displayed in the Menu "Elasticsuite > Relevance Configuration"

  1. Implement the logic to get this field as part of the Relevance Config.

You can check this commit, it's nearly the same, when I introduced the "span boost" : 58f22d9

In this interface you'll have to add a way to get the min_score, something like getMinScore() :

module-elasticsuite-core/Api/Search/Request/Container/RelevanceConfigurationInterface.php

Then implement it :

module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig.php

You'll have a getMinScore() method that will return either false or an integer.

Then implement the config factory :

module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig/Factory.php

If enabled, this returns the value. False otherwise.

  1. Inject it on query time

You'll need to add a getMinScore() method to this interface : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Search/RequestInterface.php

And then, add the minScore as a property here, with also the appropriate getMinScore : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Search/Request.php

You'll have then to plug nearly here to inject the minScore: https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Search/Request/Builder.php#L181

Probably something in the array like 'minScore' => $containerConfig->getRelevanceConfig()->getMinScore()

And then finally on the mapper, something similar to this :

https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Mapper.php#L76

        if ((int) $request->getMinScore() > 0) {
            $searchRequest['min_score'] = $request->getMinScore();
        }

Then to check, you'll have to enable/disable the min_score feature, change the value, and check that in the resulting Elasticsearch query, when you do a text search, you have a min_score with the proper value when it's enabled. When it's disabled or set to 0, you should have nothing.

vahonc added a commit to vahonc/elasticsuite that referenced this issue Jun 27, 2023
romainruaud added a commit that referenced this issue Jul 3, 2023
…ort-2.10-feature

Feature #2917, add min_score support for matching documents
@romainruaud
Copy link
Collaborator Author

Done in latests releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants