Wired change of the amount of results by usage of min_score

Hi guys!

I am using a query like this:

Select all results for Keyword "X" with min_score = 0.25. Also I am doing aggregations for this results. But when I am clicking on an aggregation, the number of documents becomes different, because the min_score. When I remove the min_score, everything is fine.

Here an example:

For keyword "X" I have 10 results, all with _score >= 0,25 and for example one result with score 0,249999, which is not displayed in the results.

Now when I click on a filter the result with the score 0,249999 becomes the score 0,2512345 and is displayed in the result.

The problem is my aggregation has num elements (10), but I am displaying on the site all results (11) . This is wired for the user.
How can I solve my problem so the number elements are still 10 after clicking on the aggregation?

Many thanks
Nik

Hey,

the problem here is, that each search you execute hits different shards (primary or replicas of a specific one) and those may have slight differences in the scoring. A couple of solutions here

  • Change the preference to a custom value so that users hit the same shards with each query, for example use the session ID, see preference docs
  • Try dfs_query_then_fetch as search type
  • Have a single shard (might not work in production, but is good for testing)

See if one of these yields the expected results.

--Alex

Hey Alex,

thanks for the answer. I have trying both suggestions, but the problem comes not from the different shards, the problem comes from the min_scrore = 0.25 setting.

Here the example again: I am searching for a Shoe "Nike" for example. And I have 2 results

1 result with score 0,25123456 and color red
2 result with score 0,24999999 and color red

The aggregation on colors is counting 1 and the display result is 1 because the min_score setting is 0.25.

When I klick on the aggregation and search for "Nike" AND color "RED", then the score of the second result is increasing to 0,253232323 and will displayed in the resultset, BUT the aggregation for color tells me, there were only one result. And this is wired now, because for the user this is a BUG.

Any suggestions how to fix this?

Thanks
Nik

Hi!

I think I found the solution. I am testing now, but it is logically the best one.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html

I am using must for each filter to the main query and thats why the score has been recalculated. When I change it to filter, then the score is the same for each result in the resultset.

Thanks
Nik