API version: 0.3.0

---

# Query string

This example uses Elasticsearch's [`query string` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-query-string-query)
to perform a full text similar search across all elements accessible to the user, with in-query logic.\
Results are then [hydrated](/reference/search/element-hydration.md), i.e. transformed into a collection response.

**Note**: The query string must be properly formatted, as otherwise Elasticsearch itself will throw an error.

```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": {
              "query_string": {
                "query": "+blue -red",
                "default_field": "description"
              }
            }
          },
          {
            "type": "element-hydration"
          }
        ]
      }' \
  https://api.example.com/search
```

##### Response Body

```json
{
  "type": "_SearchResultResponse",
  "results": [
    {
      "type": "Taxon",
      "id": "02IiNr0GOoKiPMLXgFqnMTXgXmR8NpLZT5nRm",
      "data": {
        "name": "Dahlia",
        "path": "/Plantae/Tracheophytes/Angiosperms/Eudicots/Asterids/Asterales/Asteraceae/Dahlia",
        "scenario": "general.botanicExample",
        "link": "https://en.wikipedia.org/wiki/Dahlia",
        "description": "Dahlia (UK: /ˈdeɪliə/ DAY-lee-ə, US: /ˈdæljə, ˈdɑːljə, ˈdeɪljə/ DA(H)L-yə, DAYL-yə) is a genus of bu...",
        "createdAt": "2026-12-05T12:16:01+00:00",
        "updatedAt": "2026-12-05T12:16:01+00:00"
      },
      "metadata": {
        "score": 3.3130677
      }
    },
    {
      "type": "Plant",
      "id": "02IiNr0GOoKiPMM95MrKH8ljX349BOQ3hyMlZ",
      "data": {
        "images": [
          {
            "description": "Mertensia virginica Virginia Bluebell seen in Brooklyn Botanic Garden",
            "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/3/31/Mertensia_virginica.bbg.jpg",
            "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Mertensia_virginica.bbg.jpg/960px-Mertensi...",
            "link": "https://en.wikipedia.org/wiki/File:Mertensia_virginica.bbg.jpg"
          },
          {
            "description": "Virginia Bluebells along the Rocky River in Berea, OH. Photo by Geoffrey A. Landis",
            "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/6/6f/Virginia_Bluebells_at_Rocky_River.jpg",
            "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Virginia_Bluebells_at_Rocky_River.jpg/960p...",
            "link": "https://en.wikipedia.org/wiki/File:Virginia_Bluebells_at_Rocky_River.jpg"
          }
        ],
        "hasFile": true,
        "name": "Bluebell",
        "scenario": "general.botanicExample",
        "scientificName": "M. virginica",
        "link": "https://en.wikipedia.org/wiki/Mertensia_virginica",
        "description": "Mertensia virginica (common names Virginia bluebells, Virginia cowslip, lungwort oysterleaf, Roanoke...",
        "createdAt": "2026-12-05T12:16:05+00:00",
        "updatedAt": "2026-12-05T12:16:05+00:00"
      },
      "file": {
        "contentLength": 82651,
        "extension": "jpg",
        "mimeType": "image/jpeg",
        "hash": {
          "sha256": "527fa0ca5006ae3c888c06c3e208db64aa0214b31ce9f26a1ccd5fa7cdf91c3b"
        }
      },
      "metadata": {
        "score": 3.2613833
      }
    },
    {
      "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:16:01+00:00",
        "updatedAt": "2026-12-05T12:16:01+00:00"
      },
      "metadata": {
        "score": 1.5140402
      }
    },
    "... 7 more items omitted (shapes seen: type:Taxon, type:Plant, type:Tag) ..."
  ],
  "debug": [
    {
      "input": {
        "type": "elasticsearch-query-dsl-mixin",
        "query": {
          "query_string": {
            "query": "+blue -red",
            "default_field": "description"
          }
        },
        "parameters": {
          "stepResults": []
        }
      },
      "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSe...",
      "start": 1796473117.786517,
      "indices": "*",
      "combinedQuery": {
        "_source": [
          "_id"
        ],
        "from": 0,
        "size": 25,
        "query": {
          "bool": {
            "must": [
              {
                "query_string": {
                  "query": "+blue -red",
                  "default_field": "description"
                }
              }
            ],
            "filter": [
              {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "_groupsWithSearchAccess.keyword": []
                      }
                    },
                    {
                      "term": {
                        "_usersWithSearchAccess.keyword": {
                          "value": "02IiNr0GOoKiPMM5A0eq9jHk2upaJezsVtWjL"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      },
      "end": 1796473117.797549,
      "duration": 0.011032
    },
    {
      "input": {
        "type": "element-hydration",
        "query": null,
        "parameters": {
          "stepResults": [
            {
              "elements": [
                {
                  "id": "02IiNr0GOoKiPMLXgFqnMTXgXmR8NpLZT5nRm",
                  "type": "Taxon",
                  "metadata": {
                    "score": 3.3130677
                  }
                },
                {
                  "id": "02IiNr0GOoKiPMM95MrKH8ljX349BOQ3hyMlZ",
                  "type": "Plant",
                  "metadata": {
                    "score": 3.2613833
                  }
                },
                {
                  "id": "02IiNr0GOoKiPMM4FOCWJ7N93GB5Ih1r74WAy",
                  "type": "Tag",
                  "metadata": {
                    "score": 1.5140402
                  }
                },
                "... 7 more items omitted (shapes seen: type:Taxon, type:Plant, type:Tag) ..."
              ],
              "totalHits": 10,
              "maxScore": 3.3130677
            }
          ]
        }
      },
      "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)",
      "start": 1796473117.797883,
      "accessibleElementIds": [
        "02IiNr0GOoKiPMLXgFqnMTXgXmR8NpLZT5nRm",
        "02IiNr0GOoKiPMM95MrKH8ljX349BOQ3hyMlZ",
        "02IiNr0GOoKiPMMTRjVFHTxeRcXTS8U2uHHvD",
        "... 7 more items omitted (shapes seen: string) ..."
      ],
      "end": 1796473117.827855,
      "duration": 0.029972
    }
  ]
}
```

##### Response Headers

```http
Access-Control-Allow-Headers: Authorization, Content-Type, Prefer
Access-Control-Allow-Methods: OPTIONS, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Preference-Applied
Allow: OPTIONS, POST
Cache-Control: no-cache, private
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Dec 2026 12:24:50 GMT
Transfer-Encoding: chunked
Vary: Prefer, Accept-Encoding
X-Powered-By: Ember Nexus API
```

The results include only elements whose description properties include the word "blue" and exclude the word "red".

---

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

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

Previous: [Restricting results with minScore](/reference/search/elasticsearch-query-dsl-mixin/restricting-results-with-min-score.md)

Next: [Text prefix search](/reference/search/elasticsearch-query-dsl-mixin/text-prefix-search.md)
