API version: dev

---

# Range queries on numeric fields

This example uses Elasticsearch's [`range` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-range-query)
to find all elements created on or after a given point in time. Every element automatically has `created` and `updated`
properties, which Elasticsearch maps as dates internally - dates support the same `gte`/`gt`/`lte`/`lt` comparators as
numeric fields, so this pattern works identically for e.g. `price` or `age` properties on your own data.\
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": {
              "range": {
                "created": {
                  "gte": "2025-09-25T18:35:27+00:00"
                }
              }
            }
          },
          {
            "type": "element-hydration"
          }
        ]
      }' \
  https://api.example.com/search
```

##### Response Body

```json
{
  "type": "_SearchResultResponse",
  "results": [
    {
      "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_supe...",
            "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 fl..."
      }
    },
    {
      "type": "Plant",
      "id": "f8179dfc-5578-44de-adc0-d6b613eb7a32",
      "data": {
        "images": [
          {
            "description": "Red-hot poker plants (Kniphofia uvaria) on the shore of Lake Jindabyne, New South Wales, Australia.",
            "imageLinkFull": "https://upload.wikimedia.org/wikipedia/commons/c/c1/Kniphofia_uvaria_close.JPG",
            "imageLinkThumbnail": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Kniphofia_uvaria_close.JPG/960px-Kniphofia...",
            "link": "https://en.wikipedia.org/wiki/File:Kniphofia_uvaria_close.JPG"
          }
        ],
        "created": "2025-09-25T18:35:28+00:00",
        "updated": "2025-09-25T18:35:28+00:00",
        "name": "Red Hot Poker",
        "scenario": "general.botanicExample",
        "scientificName": "K. uvaria",
        "link": "https://en.wikipedia.org/wiki/Kniphofia_uvaria",
        "description": "Kniphofia uvaria is a species of flowering plant in the family Asphodelaceae, commonly known as trit..."
      }
    },
    {
      "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/500...",
            "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_candidu...",
            "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 ..."
      }
    },
    "... 4 more items omitted (shapes seen: type:Plant) ..."
  ],
  "debug": [
    {
      "input": {
        "type": "elasticsearch-query-dsl-mixin",
        "query": {
          "range": {
            "created": {
              "gte": "2025-09-25T18:35:27+00:00"
            }
          }
        },
        "parameters": {
          "stepResults": []
        }
      },
      "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSe...",
      "start": 1758825500,
      "indices": "*",
      "combinedQuery": {
        "_source": [
          "_id"
        ],
        "from": 0,
        "size": 25,
        "query": {
          "bool": {
            "must": [
              {
                "range": {
                  "created": {
                    "gte": "2025-09-25T18:35:27+00:00"
                  }
                }
              },
              {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "_groupsWithSearchAccess.keyword": []
                      }
                    },
                    {
                      "term": {
                        "_usersWithSearchAccess.keyword": {
                          "value": "7baba8b7-a6bb-4184-9a9a-925a4d2736b0"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      },
      "end": 1758825500.03,
      "duration": 0.03
    },
    {
      "input": {
        "type": "element-hydration",
        "query": null,
        "parameters": {
          "stepResults": [
            {
              "elements": [
                {
                  "id": "258c0dfe-b1d8-4839-beed-d00d1b544a96",
                  "type": "Plant",
                  "metadata": {
                    "score": 3.9976888
                  }
                },
                {
                  "id": "f8179dfc-5578-44de-adc0-d6b613eb7a32",
                  "type": "Plant",
                  "metadata": {
                    "score": 3.2730358
                  }
                },
                {
                  "id": "23508e6c-632a-496d-9bd6-8c62a03216af",
                  "type": "Plant",
                  "metadata": {
                    "score": 3.021591
                  }
                },
                "... 4 more items omitted (shapes seen: type:Plant) ..."
              ],
              "totalHits": 7,
              "maxScore": 3.9976888
            }
          ]
        }
      },
      "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)",
      "start": 1758825500.03,
      "accessibleElementIds": [
        "258c0dfe-b1d8-4839-beed-d00d1b544a96",
        "f8179dfc-5578-44de-adc0-d6b613eb7a32",
        "23508e6c-632a-496d-9bd6-8c62a03216af",
        "... 4 more items omitted (shapes seen: string) ..."
      ],
      "end": 1758825500.09,
      "duration": 0.06
    }
  ]
}
```

##### 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
```

Only elements created at or after `2025-09-25T18:35:27+00:00` are returned - in this dataset, that separates the
`Plant` elements (created slightly later during seeding) from the `Taxon` elements (created slightly earlier).

**Note**: no explicit index mapping is required for this to work - Elasticsearch's dynamic mapping already detects
well-formed numbers and ISO 8601 dates and maps them to comparable numeric/date field types automatically.

---

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

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

Previous: [Combining queries with bool](/reference/search/elasticsearch-query-dsl-mixin/combining-queries-with-bool.md)

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