A newer version of this documentation is available.

View Latest

Creating a Query: Rectangle-Based

    March 16, 2025
    + 12

    In the following query-body, the top_left of a rectangle is expressed by means of an array of two floating-point numbers, specifying a longitude of -2.235143 and a latitude of 53.482358. The bottom_right is expressed by means of key-value pairs, specifying a longitude of 28.955043 and a latitude of 40.991862. The results are specified to be sorted on name alone.

    json
    { "from": 0, "size": 10, "query": { "top_left": [-2.235143, 53.482358], "bottom_right": { "lon": 28.955043, "lat": 40.991862 }, "field": "geo" }, "sort": [ "name" ] }

    A subset of formatted output might appear as follows:

    json
    . . . "hits": [ { "index": "geoIndex_61d8c796ef7f4360_acbbef99", "id": "landmark_17411", "score": 1.4045076008239446e-06, "sort": [ " \u0001?E#9>N\f\"e" ] }, { "index": "geoIndex_61d8c796ef7f4360_acbbef99", "id": "landmark_17409", "score": 1.4045076008239446e-06, "sort": [ " \u0001?O~i*(kD," ] }, { "index": "geoIndex_61d8c796ef7f4360_acbbef99", "id": "landmark_17403", "score": 1.4045076008239446e-06, "sort": [ " \u0001?Sg*|/t\u001f\u0002" ] }, { "index": "geoIndex_61d8c796ef7f4360_acbbef99", "id": "hotel_17413", "score": 1.4045076008239446e-06, "sort": [ " \u0001?U]S\\.e\u0002_" ] }, . . .