# Minimum\_should\_match appears to default to 0 when not explicitly set

**URL:** <https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255>\
**Category:** Elasticsearch\
**Created:** [May 2, 2018, 1:24pm UTC](https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255 "2018-05-02T13:24:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elavigne](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@elavigne](https://discuss.elastic.co/u/elavigne)\
**Post date:** [May 2, 2018, 1:24pm UTC](https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255/1 "2018-05-02T13:24:02Z")

</div>

I'm confused about the behaviour of a query with shoulds.

I have the following query on a 6.2.3 cluster:

```
GET reporting_tags/_search
{
  "query": {
    "bool": {
      "must": [
        {"term": {"source": "analytics"}}
      ],
      "should": [
        {"range": {"created": {"lt": 1525206239677}}},
        {
          "bool": {
            "must_not": [
              {"exists": {"field": "created"}}
            ]
          }
        }
      ]
    }
  }
}

```

Unless I add an explicit `"minimum_should_match": 1`, only the must part of the query limits the results. I get results that match none of the should clauses (tags with a `created` property with a larger long than the one specified in the query). When I add minimum\_should\_match, then all is as it should be. Did the default change?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 2, 2018, 1:36pm UTC](https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255/2 "2018-05-02T13:36:27Z")

</div>

It's always been that way being based on the Lucene behaviour that predates elasticsearch. Going back as far as [0.9 docs](https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-bool-query.html) the distinction between default behaviour when `must` is present and not is noted.

---

<div class="post-metadata">

**Author:** ![elavigne](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@elavigne](https://discuss.elastic.co/u/elavigne)\
**Post date:** [May 2, 2018, 2:08pm UTC](https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255/3 "2018-05-02T14:08:29Z")

</div>

Thanks for the quick reply! Can't believe I never noticed that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 30, 2018, 2:08pm UTC](https://discuss.elastic.co/t/minimum-should-match-appears-to-default-to-0-when-not-explicitly-set/130255/4 "2018-05-30T14:08:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
