API version: dev

---

# Combining queries with bool

This example uses Elasticsearch's [`bool` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-bool-query)
to combine multiple smaller queries together, in this example using `OR` logic (`should` and `minimum_should_match`
value of `1`).\
Results are then [hydrated](/reference/search/element-hydration.md), i.e. transformed into a collection response.

```bash
curl -X POST \
  -H 'Authorization: Bearer secret-token:PIPeJGUt7c00ENn8a5uDlc' \
  -H 'Content-Type: application/json' \
  -d '{
        "debug": true,
        "steps": [
          {
            "type": "elasticsearch-query-dsl-mixin",
            "query": {
              "bool": {
                "should": [
                  {
                    "match": {
                      "name": {
                        "query": "blue",
                        "fuzziness": "AUTO",
                        "boost": 10.0
                      }
                    }
                  },
                  {
                    "match": {
                      "description": {
                        "query": "blue"
                      }
                    }
                  }
                ],
                "minimum_should_match": 1
              }
            }
          },
          {
            "type": "element-hydration"
          }
        ]
      }' \
  https://api.example.com/search
```

##### Response Body

```json
{
  "type": "_SearchResultResponse",
  "results": [
    {
      "type": "Tag",
      "id": "79ca27e5-93bb-43e6-a76b-096ea45e2e8e",
      "data": {
        "description": "Blue is one of the three primary colours in the RGB (additive) colour model, as well as in the RYB c...",
        "created": "2025-09-25T18:35:26+00:00",
        "updated": "2025-09-25T18:35:26+00:00",
        "name": "blue",
        "color": "#4363d8",
        "scenario": "general.botanicExample",
        "link": "https://en.wikipedia.org/wiki/Blue"
      }
    },
    {
      "type": "Plant",
      "id": "d747bfe6-0d52-4119-87c6-1fc37ed9395b",
      "data": {
        "images": [
          {
            "description": "Anchusa capensis in the San Francisco Botanical Garden",
            "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/a/a6/Anchusa_capensis_kz1.jpg",
            "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Anchusa_capensis_kz1.jpg/500px-Anchusa_cap...",
            "link": "https://en.wikipedia.org/wiki/File:Anchusa_capensis_kz1.jpg"
          }
        ],
        "created": "2025-09-25T18:35:28+00:00",
        "updated": "2025-09-25T18:35:28+00:00",
        "name": "Cape Forget-me-not",
        "scenario": "general.botanicExample",
        "scientificName": "A. capensis",
        "link": "https://en.wikipedia.org/wiki/Anchusa_capensis",
        "description": "Anchusa capensis, is a species of flowering plant in the family Boraginaceae, native to Namibia, Sou..."
      }
    },
    {
      "type": "Taxon",
      "id": "97157162-56eb-4374-8200-41b9b6004ca2",
      "data": {
        "description": "Boraginaceae, the borage or forget-me-not family, includes about 2,000 species of shrubs, trees, and...",
        "created": "2025-09-25T18:35:26+00:00",
        "updated": "2025-09-25T18:35:26+00:00",
        "name": "Boraginaceae",
        "path": "/Plantae/Tracheophytes/Angiosperms/Eudicots/Asterids/Boraginales/Boraginaceae",
        "scenario": "general.botanicExample",
        "link": "https://en.wikipedia.org/wiki/Boraginaceae"
      }
    },
    "... 17 more items omitted (shapes seen: type:Tag, type:Plant, type:Taxon) ..."
  ],
  "debug": [
    {
      "input": {
        "type": "elasticsearch-query-dsl-mixin",
        "query": {
          "bool": {
            "should": [
              {
                "match": {
                  "name": {
                    "query": "blue",
                    "fuzziness": "AUTO",
                    "boost": 10
                  }
                }
              },
              {
                "match": {
                  "description": {
                    "query": "blue"
                  }
                }
              }
            ],
            "minimum_should_match": 1
          }
        },
        "parameters": {
          "stepResults": []
        }
      },
      "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSe...",
      "start": 1758825390.227822,
      "indices": "*",
      "combinedQuery": {
        "_source": [
          "_id"
        ],
        "from": 0,
        "size": 25,
        "query": {
          "bool": {
            "must": [
              {
                "bool": {
                  "should": [
                    {
                      "match": {
                        "name": {
                          "query": "blue",
                          "fuzziness": "AUTO",
                          "boost": 10
                        }
                      }
                    },
                    {
                      "match": {
                        "description": {
                          "query": "blue"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              },
              {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "_groupsWithSearchAccess.keyword": []
                      }
                    },
                    {
                      "term": {
                        "_usersWithSearchAccess.keyword": {
                          "value": "7baba8b7-a6bb-4184-9a9a-925a4d2736b0"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      },
      "end": 1758825390.287255,
      "duration": 0.059433
    },
    {
      "input": {
        "type": "element-hydration",
        "query": null,
        "parameters": {
          "stepResults": [
            {
              "elements": [
                {
                  "id": "79ca27e5-93bb-43e6-a76b-096ea45e2e8e",
                  "type": "Tag",
                  "metadata": {
                    "score": 26.933556
                  }
                },
                {
                  "id": "d747bfe6-0d52-4119-87c6-1fc37ed9395b",
                  "type": "Plant",
                  "metadata": {
                    "score": 4.160383
                  }
                },
                {
                  "id": "97157162-56eb-4374-8200-41b9b6004ca2",
                  "type": "Taxon",
                  "metadata": {
                    "score": 3.3504083
                  }
                },
                "... 17 more items omitted (shapes seen: type:Tag, type:Plant, type:Taxon) ..."
              ],
              "totalHits": 20,
              "maxScore": 26.933556
            }
          ]
        }
      },
      "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)",
      "start": 1758825390.287426,
      "accessibleElementIds": [
        "79ca27e5-93bb-43e6-a76b-096ea45e2e8e",
        "d747bfe6-0d52-4119-87c6-1fc37ed9395b",
        "97157162-56eb-4374-8200-41b9b6004ca2",
        "... 17 more items omitted (shapes seen: string) ..."
      ],
      "end": 1758825390.359465,
      "duration": 0.072039
    }
  ]
}
```

##### Response Headers

```http
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Location
Allow: GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK
Cache-Control: no-cache, private
Content-Type: application/json; charset=utf-8
Date: Thu, 11 Sep 2025 20:23:41 GMT
Transfer-Encoding: chunked
X-Powered-By: Ember Nexus API
```

Any element which has the word "blue" in its name _or_ its description is returned.\
Elements which mention the word "blue" in _both_ their name _and_ description have a higher score, and are usually
sorted towards the beginning of the response collection.

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [Exact keyword matching](/reference/search/elasticsearch-query-dsl-mixin/exact-keyword-matching.md)

Next: [Range queries on numeric fields](/reference/search/elasticsearch-query-dsl-mixin/range-queries-on-numeric-fields.md)
