title: Elastic Search "should" clause not working as expected when "should", "must" and "must_not" clause are present
body: <p>I've loaded the data provided <a href="https://raw.githubusercontent.com/elastic/elasticsearch/master/docs/src/test/resources/accounts.json" rel="nofollow noreferrer">here</a> into elastic search.</p>
  
  <p>Now I'm trying to query for Accounts.</p>
  
  <ol>
  <li>Age Must be 38.</li>
  <li>State Should not be "ID".</li>
  <li><strong>Address Should Contain Either</strong>: (This is not Working)
  
  <ul>
  <li>The text "lane" OR</li>
  <li>The a complete text "mill avenue"</li>
  </ul></li>
  </ol>
  
  <p><strong>Request</strong> : POST - <a href="http://localhost:9200/bank/account/_search?pretty" rel="nofollow noreferrer">http://localhost:9200/bank/account/_search?pretty</a></p>
  
  <pre><code>{
    "query": {
      "bool": {
        "should": [
          { "match": { "address": "lane" } },
          { "match_phrase": { "address": "mill avenue" } }
        ],
        "must": [
          { "match": { "age": "38" } }
        ],
        "must_not": [
          { "match": { "state": "ID" } }
        ]
      }
    },
    "from": 0,
    "size": 1,
    "_source": ["account_number", "balance", "firstname", "lastname", "age", "email", "address", "state"],
    "sort": [
      { "account_number": "asc" },
      { "balance": "desc"}
    ]
  }
  </code></pre>
  
  <p><strong>Response</strong> : </p>
  
  <pre><code>{
    "took": 8,
    "timed_out": false,
    "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
    },
    "hits": {
      "total": 36,
      "max_score": null,
      "hits": [
        {
          "_index": "bank",
          "_type": "account",
          "_id": "21",
          "_score": null,
          "_source": {
            "account_number": 21,
            "firstname": "Estella",
            "address": "859 Portal Street",
            "balance": 7004,
            "state": "WV",
            "age": 38,
            "email": "estellapaul@zillatide.com",
            "lastname": "Paul"
          },
          "sort": [
            21,
            7004
          ]
        }
      ]
    }
  }
  </code></pre>
  
  <p>You can check the response. The record with address <strong>"859 Portal Street"</strong> was received and <strong>it doesn't contain "lane" or "mill avenue"</strong>.</p>
  
  <p>Elastic Search Version : 5.1.1</p>
  
  <p><strong>----Edit----</strong>
  Solution (Thanks to @Lax and @mattweber as posted <a href="https://discuss.elastic.co/t/elastic-search-should-clause-not-working-as-expected-when-should-must-and-must-not-clause-are-present/70231/2?u=bandikishores" rel="nofollow noreferrer">here</a>): <br/><code>minimum_should_match</code> is needed if must/must_not is present.</p>
  
  <pre><code>{
    "query": {
      "bool": {
        "minimum_should_match": 1,
        "should": [
          { "match": { "address": "avenue" } },
          { "match_phrase": { "address": "Williams Place" } }
        ],
        "must": [
          { "match": { "age": "38" } }
        ],
        "must_not": [
          { "match": { "state": "ID" } }
        ],
        "filter": {
          "range": {
            "balance": {
              "gte": 20000,
              "lte": 30000
            }
          }
        }
      }
    },
    "from": 0,
    "size": 1000,
    "_source": ["account_number", "balance", "firstname", "lastname", "age", "email", "address", "state"],
    "sort": [
      { "account_number": "asc" },
      { "balance": "desc"}
    ],
    "aggs": {
      "group_by_state": {
        "terms": {
          "field": "state.keyword"
        },
        "aggs": {
          "average_balance": {
            "avg": {
              "field": "balance"
            }
          }
        }
      }
    }
  }
  </code></pre>