# Must and should query together

**URL:** <https://discuss.elastic.co/t/must-and-should-query-together/58330>\
**Category:** Elasticsearch\
**Created:** [August 18, 2016, 8:54am UTC](https://discuss.elastic.co/t/must-and-should-query-together/58330 "2016-08-18T08:54:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaacpm](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@isaacpm](https://discuss.elastic.co/u/isaacpm)\
**Post date:** [August 18, 2016, 8:54am UTC](https://discuss.elastic.co/t/must-and-should-query-together/58330/1 "2016-08-18T08:54:30Z")

</div>

Hi,

I'm trying to get a query to do a must on some fields and then a should on two more fields, but the should matches even if none of the conditions really match.  
What I'd like to have is something like:  
field: text AND field1:text AND field2: text AND (field3: text OR field4: text)  
So at least one of the ORs should be present in the document for the query to match.

The query is:

```
{"fields": 
  ["logical_name.raw","serial_number.raw","dco_config_admin_group.raw","status.raw","warranty_vendor.raw","warranty_startdate.raw","warranty_enddate.raw","warranty_type.raw","warranty_uplift","maint_vendor.raw","maint_startdate.raw","maint_enddate.raw","maint_type.raw","datacenter_label.raw","manufacturer.raw","hardware_model.raw","environment.raw","sbu.raw","bu.raw","bu2.raw","product_name.raw"],
  "query": {
    "bool":{
      "must":[ 
        {
          "match": {"timestamp": "2016-08-15"}
          
        }, 
        {
          "match": {"sbu.raw": "F&R"}
        }
      ], 
      "should": [
        { 
          "exists": { "field": "warranty_vendor.raw" }
          
        },
        { 
          "exists": { "field": "maint_vendor.raw" }
        }
      ]
      
    }
    
  }
  
}

```

How can I change that should to make it act as I want it to?

Thanks,  
Isaac

---

<div class="post-metadata">

**Author:** ![isaacpm](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@isaacpm](https://discuss.elastic.co/u/isaacpm)\
**Post date:** [August 18, 2016, 9:25am UTC](https://discuss.elastic.co/t/must-and-should-query-together/58330/2 "2016-08-18T09:25:37Z")

</div>

I got it.  
Had to it this to the query:  
"minimum\_should\_match" : 1

So it would match at least one of the should queries.

---

<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:** [July 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/must-and-should-query-together/58330/3 "2017-07-05T22:26:58Z")

</div>


