# Struggling to Understand Creating Compound Queries Using Updated Query DSL

**URL:** <https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470>\
**Category:** Elasticsearch\
**Created:** [September 27, 2019, 9:35pm UTC](https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470 "2019-09-27T21:35:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticTrouble](https://avatars.discourse-cdn.com/v4/letter/e/a88e57/32.png) [@elasticTrouble](https://discuss.elastic.co/u/elasticTrouble)\
**Post date:** [September 27, 2019, 9:35pm UTC](https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470/1 "2019-09-27T21:35:33Z")

</div>

Hey Elastic Folks,

I'm really struggling to understand creating compound queries with the updated query DSL after migrating our cluster from 5.3 to 6.8. My current task is to re-write roughly 300 saved searches many of which contain compound queries. I've spent roughly a day trying to re-write one query to the updated query DSL without any luck so I'm turning to the forums for assistance now.

For example, I need to convert this 5.3 query to the updated 6.8 query DSL, how?

```auto
{
  "query_string": {
    "query": "((request:\"Transaction request\" AND decision:APPROVED) OR (request:Update AND decision:TRANS_APPROVED)) OR ((request:Lookup AND decision:APPROVED))"
  }
}

```

I've read the following articles on the query DSL but I'm still failing to come up with a query of my own that matches any data or doesn't throw an internal server error exception when run.

> <https://stackoverflow.com/questions/28538760/elasticsearch-bool-query-combine-must-with-or>

  

> **[Understanding the Elasticsearch Query DSL](https://medium.com/@User3141592/understanding-the-elasticsearch-query-dsl-ce1d67f1aa5b)**
>
> Not Just Copy-Pasting From Stack Overflow But Understanding What You’re Copy-Pasting.

  

> **[Elastic Search: Complex Queries](https://medium.com/zefo-tech/elastic-search-from-beginner-to-intermediate-e4177c4c769f)**
>
> When I started to explore Elasticsearch for search and filtering, I came across many blogs generally talking about how to get started…

  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<div class="post-metadata">

**Author:** ![elasticTrouble](https://avatars.discourse-cdn.com/v4/letter/e/a88e57/32.png) [@elasticTrouble](https://discuss.elastic.co/u/elasticTrouble)\
**Post date:** [September 27, 2019, 11:20pm UTC](https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470/2 "2019-09-27T23:20:53Z")

</div>

Figured it out. Thanks to this article: [https://www.elastic.co/blog/lost-in-translation-boolean-operations-and-filters-in-the-bool-query](https://www.elastic.co/blog/lost-in-translation-boolean-operations-and-filters-in-the-bool-query)

```auto
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "match": {
                  "request": "Transaction request"
                }
              },
              {
                "match": {
                  "decision": "APPROVED"
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                "match": {
                  "request": "Update"
                }
              },
              {
                "match": {
                  "decision": "TRANS_APPROVED"
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                "match": {
                  "request": "Lookup"
                }
              },
              {
                "match": {
                  "decision": "APPROVED"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

ridiculous.

---

<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:** [September 28, 2019, 8:31am UTC](https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470/3 "2019-09-28T08:31:38Z")

</div>

> [@elasticTrouble](#):
>
> , I need to convert this 5.3 query to the updated 6.8 query DSL

Why?  
Query string is still supported.

---

<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:** [October 26, 2019, 8:31am UTC](https://discuss.elastic.co/t/struggling-to-understand-creating-compound-queries-using-updated-query-dsl/201470/4 "2019-10-26T08:31:43Z")

</div>

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