question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"minimum_should_match" disappears from query in some cases

See original GitHub issue
>>> import elasticsearch_dsl
>>> elasticsearch_dsl.VERSION
(2, 0, 0)
>>> from elasticsearch_dsl import Search, Q

When filter is after query method, ‘minimum_should_match’ exist in query:

>>> s = Search()
>>> s.query(q).filter('term', status=1).to_dict()
{'query': {'bool': {'filter': [{'term': {'status': 1}}],
   'minimum_should_match': 1,
   'should': [{'match': {'name': 'abc'}}]}}}

But if we change order of filter and query, than ‘minimum_should_match’ disappears:

>>> s = Search()
>>> s.filter('term', status=1).query(q).to_dict()
{'query': {'bool': {'filter': [{'term': {'status': 1}}],
   'should': [{'match': {'name': 'abc'}}]}}}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SamuelRamondcommented, Oct 18, 2016

Hi, we had the same problem and this solved our issue. Can you make a release of this version for pip install ?

Thanks for your work 👍

1reaction
honzakralcommented, Jun 30, 2016

Thank you @solarissmoke! This is very useful feedback and helped me discover a bug where doing Bool & NotBool the minimum_should_match was ignored. That’s why the order mattered.

I pushed a fix in 4b4487d0659ac8f2cf0e6499009ce696fca35684 for this particular case with a test.

I will close the issue now, feel free to reopen if the issue isn’t resolved.

Thanks again for all the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

minimum_should_match parameter | Elasticsearch Guide [8.5]
Indicates that this percent of the total number of optional clauses can be missing. The number computed from the percentage is rounded down,...
Read more >
What does actually minimum_should_match in percentage ...
The minimum_should_match parameter works for "should" clauses in the "bool" query. With this parameter you specify how many of the should ...
Read more >
The DisMax Query Parser | Apache Solr Reference Guide 8.3
A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that...
Read more >
Minimum Should Match
Indicates a fixed value regardless of the number of optional clauses. ... that this percent of the total number of optional clauses can...
Read more >
Strange behavior (bug?) in Atlas Search Scoring - MongoDB
Everything which matches the title should have a higher score - which should according to the query also be what's happening.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found