"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:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 👍
Thank you @solarissmoke! This is very useful feedback and helped me discover a bug where doing
Bool & NotBool
theminimum_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!