API version: 0.3.0

---

# 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": "02IiNr0GOoKiPMM4FOCWJ7N93GB5Ih1r74WAy",
      "data": {
        "description": "Blue is one of the three primary colours in the RGB (additive) colour model, as well as in the RYB c...",
        "name": "blue",
        "color": "#4363d8",
        "scenario": "general.botanicExample",
        "link": "https://en.wikipedia.org/wiki/Blue",
        "createdAt": "2026-12-05T12:21:37+00:00",
        "updatedAt": "2026-12-05T12:21:37+00:00"
      },
      "metadata": {
        "score": 27.950357
      }
    },
    {
      "type": "Plant",
      "id": "02IiNr0GOoKiPMMnmHcecC7H3P3IOipWs3wbB",
      "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"
          }
        ],
        "hasFile": true,
        "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...",
        "createdAt": "2026-12-05T12:21:40+00:00",
        "updatedAt": "2026-12-05T12:21:40+00:00"
      },
      "file": {
        "contentLength": 75801,
        "extension": "jpg",
        "mimeType": "image/jpeg",
        "hash": {
          "sha256": "853580a14affe615f6fecbd2c16e8f6805ba53867669b3a220209a7b8d002cf1"
        }
      },
      "metadata": {
        "score": 4.17328
      }
    },
    {
      "type": "Taxon",
      "id": "02IiNr0GOoKiPMMIWLRrq9HALNIuvmm0LisJk",
      "data": {
        "description": "Boraginaceae, the borage or forget-me-not family, includes about 2,000 species of shrubs, trees, and...",
        "name": "Boraginaceae",
        "path": "/Plantae/Tracheophytes/Angiosperms/Eudicots/Asterids/Boraginales/Boraginaceae",
        "scenario": "general.botanicExample",
        "link": "https://en.wikipedia.org/wiki/Boraginaceae",
        "createdAt": "2026-12-05T12:21:40+00:00",
        "updatedAt": "2026-12-05T12:21:40+00:00"
      },
      "metadata": {
        "score": 3.3463202
      }
    },
    "... 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": 1796473376.333182,
      "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
                }
              }
            ],
            "filter": [
              {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "_groupsWithSearchAccess.keyword": []
                      }
                    },
                    {
                      "term": {
                        "_usersWithSearchAccess.keyword": {
                          "value": "02IiNr0GOoKiPMM5A0eq9jHk2upaJezsVtWjL"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      },
      "end": 1796473376.44829,
      "duration": 0.115108
    },
    {
      "input": {
        "type": "element-hydration",
        "query": null,
        "parameters": {
          "stepResults": [
            {
              "elements": [
                {
                  "id": "02IiNr0GOoKiPMM4FOCWJ7N93GB5Ih1r74WAy",
                  "type": "Tag",
                  "metadata": {
                    "score": 27.950357
                  }
                },
                {
                  "id": "02IiNr0GOoKiPMMnmHcecC7H3P3IOipWs3wbB",
                  "type": "Plant",
                  "metadata": {
                    "score": 4.17328
                  }
                },
                {
                  "id": "02IiNr0GOoKiPMMIWLRrq9HALNIuvmm0LisJk",
                  "type": "Taxon",
                  "metadata": {
                    "score": 3.3463202
                  }
                },
                "... 17 more items omitted (shapes seen: type:Tag, type:Plant, type:Taxon) ..."
              ],
              "totalHits": 20,
              "maxScore": 27.950357
            }
          ]
        }
      },
      "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)",
      "start": 1796473376.448809,
      "accessibleElementIds": [
        "02IiNr0GOoKiPMM4FOCWJ7N93GB5Ih1r74WAy",
        "02IiNr0GOoKiPMMnmHcecC7H3P3IOipWs3wbB",
        "02IiNr0GOoKiPMMIWLRrq9HALNIuvmm0LisJk",
        "... 17 more items omitted (shapes seen: string) ..."
      ],
      "end": 1796473376.695765,
      "duration": 0.246956
    }
  ]
}
```

##### Response Headers

```http
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: OPTIONS, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Location
Allow: OPTIONS, POST
Cache-Control: no-cache, private
Content-Type: application/json; charset=utf-8
Date: Sat, 21 Nov 2026 10:43:13 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: [Geospatial search](/reference/search/elasticsearch-query-dsl-mixin/geospatial-search.md)

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