Parameterized search
This example shows how to inject client-provided data into an Elasticsearch Query DSL query using an expression. The {{someElementIds}} placeholder is replaced with the someElementIds step parameter before the query is sent to Elasticsearch, resulting in a terms query that matches exactly the three given element ids.
Results are then hydrated, i.e. transformed into a collection response.
curl -X POST \ -H 'Authorization: Bearer secret-token:PIPeJGUt7c00ENn8a5uDlc' \ -H 'Content-Type: application/json' \ -d '{ "debug": true, "steps": [ { "type": "elasticsearch-query-dsl-mixin", "query": { "terms": { "_id": "{{someElementIds}}" } }, "parameters": { "someElementIds": [ "258c0dfe-b1d8-4839-beed-d00d1b544a96", "23508e6c-632a-496d-9bd6-8c62a03216af", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ] } }, { "type": "element-hydration" } ] }' \ https://api.example.com/search[ { "input": { "type": "elasticsearch-query-dsl-mixin", "query": { "terms": { "_id": "{{someElementIds}}" } }, "parameters": { "someElementIds": [ "258c0dfe-b1d8-4839-beed-d00d1b544a96", "23508e6c-632a-496d-9bd6-8c62a03216af", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ], "stepResults": [] } }, "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSearchStepEventListener)", "start": 1758825390.715234, "indices": "*", "combinedQuery": { "_source": [ "_id" ], "from": 0, "size": 25, "query": { "bool": { "must": [ { "terms": { "_id": [ "258c0dfe-b1d8-4839-beed-d00d1b544a96", "23508e6c-632a-496d-9bd6-8c62a03216af", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ] } }, { "bool": { "should": [ { "terms": { "_groupsWithSearchAccess.keyword": [] } }, { "term": { "_usersWithSearchAccess.keyword": { "value": "7baba8b7-a6bb-4184-9a9a-925a4d2736b0" } } } ], "minimum_should_match": 1 } } ] } } }, "end": 1758825390.823238, "duration": 0.108004 }, { "input": { "type": "element-hydration", "query": null, "parameters": { "stepResults": [ { "elements": [ { "id": "23508e6c-632a-496d-9bd6-8c62a03216af", "type": "Plant", "metadata": { "score": 1.0101794 } }, { "id": "258c0dfe-b1d8-4839-beed-d00d1b544a96", "type": "Plant", "metadata": { "score": 1.0101794 } }, { "id": "8940d70b-5b6f-43b7-bee4-41d073396ff8", "type": "Plant", "metadata": { "score": 1.0101794 } } ], "totalHits": 3, "maxScore": 1.0101794 } ] } }, "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)", "start": 1758825390.823414, "accessibleElementIds": [ "23508e6c-632a-496d-9bd6-8c62a03216af", "258c0dfe-b1d8-4839-beed-d00d1b544a96", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ], "end": 1758825390.844799, "duration": 0.021385 }]{ "type": "_SearchResultResponse", "results": [ { "type": "Plant", "id": "23508e6c-632a-496d-9bd6-8c62a03216af", "data": { "images": [ { "description": "Lilium candidum, Israel", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/c/cc/ShoshanTzachor-2-wiki-Zachi-Evenor.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/ShoshanTzachor-2-wiki-Zachi-Evenor.jpg/500px-ShoshanTzachor-2-wiki-Zachi-Evenor.jpg", "link": "https://en.wikipedia.org/wiki/File:ShoshanTzachor-2-wiki-Zachi-Evenor.jpg" }, { "description": "Photo of Lilium candidum at VanDusen Botanical Garden", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/3/30/Lilium_candidum_1.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Lilium_candidum_1.jpg/960px-Lilium_candidum_1.jpg", "link": "https://en.wikipedia.org/wiki/File:Lilium_candidum_1.jpg" } ], "created": "2025-09-25T18:35:28+00:00", "updated": "2025-09-25T18:35:28+00:00", "name": "Lily", "scenario": "general.botanicExample", "scientificName": "L. candidum", "link": "https://en.wikipedia.org/wiki/Lilium_candidum", "description": "Lilium candidum, the Madonna lily[2][3] or white lily,[4] is a plant in the true lily family. It is native to the Balkans and Middle East, and naturalized in other parts of Europe, including France, Italy, and Ukraine, and in North Africa, the Canary Islands, Mexico, and other regions.[1][5] It has been cultivated since antiquity, for at least 3,000 years,[6] and has great symbolic value since then for many cultures. It is susceptible to several virus diseases common to lilies, and especially to Botrytis fungus. One technique to avoid problems with viruses is to grow plants from seed instead of bulblets." } }, { "type": "Plant", "id": "258c0dfe-b1d8-4839-beed-d00d1b544a96", "data": { "images": [ { "description": "", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/f/fe/Flame_lily.png", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Flame_lily.png/500px-Flame_lily.png", "link": "https://en.wikipedia.org/wiki/File:Flame_lily.png" }, { "description": "Gloriosa superba at Mabvuku, Harare, Zimbabwe", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/b/bc/Gloriosa_superba_1.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Gloriosa_superba_1.jpg/960px-Gloriosa_superba_1.jpg", "link": "https://en.wikipedia.org/wiki/File:Gloriosa_superba_1.jpg" } ], "created": "2025-09-25T18:35:28+00:00", "updated": "2025-09-25T18:35:28+00:00", "name": "Flame Lily", "scenario": "general.botanicExample", "scientificName": "G. superba", "link": "https://en.wikipedia.org/wiki/Gloriosa_superba", "description": "Gloriosa superba is a species of flowering plant in the family Colchicaceae. Common names include flame lily, climbing lily, creeping lily, glory lily,[3] gloriosa lily, tiger claw,[4] and fire lily.[5]" } }, { "type": "Plant", "id": "8940d70b-5b6f-43b7-bee4-41d073396ff8", "data": { "images": [ { "description": "in Seoul Forest, South Korea", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/7/7b/Tulips_in_Seoul_Forest%2C_South_Korea1.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Tulips_in_Seoul_Forest%2C_South_Korea1.jpg/500px-Tulips_in_Seoul_Forest%2C_South_Korea1.jpg", "link": "https://en.wikipedia.org/wiki/File:Tulips_in_Seoul_Forest,_South_Korea1.jpg" }, { "description": "A Yonina cultivar (Division 6) tulip at the Tulip Fest in Albany, New York, United States.", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/7/7b/Yonina_Tulip.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Yonina_Tulip.jpg/960px-Yonina_Tulip.jpg", "link": "https://en.wikipedia.org/wiki/File:Yonina_Tulip.jpg" }, { "description": "Tulipa orphanidea, garden plant", "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/c/c4/Tulipa_orphanidea_060506.jpg", "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Tulipa_orphanidea_060506.jpg/500px-Tulipa_orphanidea_060506.jpg", "link": "https://en.wikipedia.org/wiki/File:Tulipa_orphanidea_060506.jpg" } ], "created": "2025-09-25T18:35:26+00:00", "updated": "2025-09-25T18:35:26+00:00", "name": "Tulip", "scenario": "general.botanicExample", "scientificName": "Tulipa", "link": "https://en.wikipedia.org/wiki/Tulip", "description": "Tulips are spring-blooming perennial herbaceous bulbiferous geophytes in the Tulipa genus. Their flowers are usually large, showy, and brightly coloured, generally red, orange, pink, yellow, or white. They often have a different coloured blotch at the base of the tepals, internally. Because of a degree of variability within the populations and a long history of cultivation, classification has been complex and controversial. The tulip is a member of the lily family, Liliaceae,[2] along with 14 other genera, where it is most closely related to Amana, Erythronium, and Gagea in the tribe Lilieae." } } ], "debug": [ { "input": { "type": "elasticsearch-query-dsl-mixin", "query": { "terms": { "_id": "{{someElementIds}}" } }, "parameters": { "someElementIds": [ "258c0dfe-b1d8-4839-beed-d00d1b544a96", "23508e6c-632a-496d-9bd6-8c62a03216af", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ], "stepResults": [] } }, "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSearchStepEventListener)", "start": 1758825390.715234, "indices": "*", "combinedQuery": { "_source": [ "_id" ], "from": 0, "size": 25, "query": { "bool": { "must": [ { "terms": { "_id": [ "258c0dfe-b1d8-4839-beed-d00d1b544a96", "23508e6c-632a-496d-9bd6-8c62a03216af", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ] } }, { "bool": { "should": [ { "terms": { "_groupsWithSearchAccess.keyword": [] } }, { "term": { "_usersWithSearchAccess.keyword": { "value": "7baba8b7-a6bb-4184-9a9a-925a4d2736b0" } } } ], "minimum_should_match": 1 } } ] } } }, "end": 1758825390.823238, "duration": 0.108004 }, { "input": { "type": "element-hydration", "query": null, "parameters": { "stepResults": [ { "elements": [ { "id": "23508e6c-632a-496d-9bd6-8c62a03216af", "type": "Plant", "metadata": { "score": 1.0101794 } }, { "id": "258c0dfe-b1d8-4839-beed-d00d1b544a96", "type": "Plant", "metadata": { "score": 1.0101794 } }, { "id": "8940d70b-5b6f-43b7-bee4-41d073396ff8", "type": "Plant", "metadata": { "score": 1.0101794 } } ], "totalHits": 3, "maxScore": 1.0101794 } ] } }, "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)", "start": 1758825390.823414, "accessibleElementIds": [ "23508e6c-632a-496d-9bd6-8c62a03216af", "258c0dfe-b1d8-4839-beed-d00d1b544a96", "8940d70b-5b6f-43b7-bee4-41d073396ff8" ], "end": 1758825390.844799, "duration": 0.021385 } ]}Access-Control-Allow-Headers: *Access-Control-Allow-Methods: GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCKAccess-Control-Allow-Origin: *Access-Control-Expose-Headers: ETag, LocationAllow: GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCKCache-Control: no-cache, privateContent-Type: application/json; charset=utf-8Date: Sat, 06 Sep 2025 14:57:35 GMTTransfer-Encoding: chunkedX-Powered-By: Ember Nexus APIAll three elements referenced by someElementIds are returned, in the order Elasticsearch ranks them - not necessarily the order they were listed in the parameter.