# Is this a correct query? i need to confirm, can i use multiple must in a single query

**URL:** https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524
**Category:** Elasticsearch
**Created:** [May 11, 2018, 5:45pm UTC](https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524 "2018-05-11T17:45:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![addanuj](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@addanuj](https://discuss.elastic.co/u/addanuj)
#### Post date: [May 11, 2018, 5:45pm UTC](https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524/1 "2018-05-11T17:45:45Z")

</div>

I am getting "multiple must" syntex error in DevTools in below query, i want to use multiple must statement  
GET logstash-security-\*/\_search  
{  
"query": {  
"bool": {  
"must": {  
"bool" : { "should": [  
{ "match": { "title": "Elasticsearch" }},  
{ "match": { "title": "Solr" }} ] }  
},  
"must": { "match": { "authors": "clinton gormely" }},  
"must\_not": { "match": {"authors": "radu gheorge" }}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [May 14, 2018, 2:54pm UTC](https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524/2 "2018-05-14T14:54:40Z")

</div>

the `must` key is duplicated. Indenting the JSON in this case would help a lot to make the issue more visible. Take a look at this one (not sure I understood your intent a hundred percent, so handle with care)

```auto
GET logstash-security-*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              { "match": { "title": "Elasticsearch" } },
              { "match": { "title": "Solr" } }
            ]
          }
        },
        { "match": { "authors": "clinton gormely" } }
      ],
      "must_not": {
        "match": { "authors": "radu gheorge" } }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![addanuj](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@addanuj](https://discuss.elastic.co/u/addanuj)
#### Post date: [May 14, 2018, 3:46pm UTC](https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524/3 "2018-05-14T15:46:39Z")

</div>

Thanks Alex,

i got this query from a blog where 2 must in same query was described, now i came to know that was wrongly mentioned.

I used Nested bool query and it worked.

---

<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: [June 11, 2018, 3:46pm UTC](https://discuss.elastic.co/t/is-this-a-correct-query-i-need-to-confirm-can-i-use-multiple-must-in-a-single-query/131524/4 "2018-06-11T15:46:43Z")

</div>

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