---
title: "Creating a Query: Polygon-Based"
pubDate: 2026-08-17T09:53:44.266Z
antora:
  editUrl: https://github.com/couchbase/docs-server/edit/release/7.2/modules/fts/pages/fts-supported-queries-geo-bounded-polygon.adoc
  xref: xref:7.2@server:fts:fts-supported-queries-geo-bounded-polygon.adoc[]
---

[Consult the llms.txt file for a full list of contents](/llms.txt)
[View original HTML](/server/7.2/fts/fts-supported-queries-geo-bounded-polygon.html)

# Creating a Query: Polygon-Based

Note that a detailed example for Geopoint index creation and also executing queries can be found at [Geopoint Index Creation](fts-supported-queries-geopoint-spatial.md#creating%5Fa%5Fgeospatial%5Fgeopoint%5Findex) and running queries [Geopoint Radius Queries](fts-supported-queries-geopoint-spatial.md#creating%5Fgeopoint%5Frest%5Fquery%5Fradius%5Fbased).

In addition detailed information on performing queries with the Search REST API can be found in [Searching with the REST API](fts-searching-with-curl-http-requests.md); which shows how to use the full `curl` command and how to incorporate query-bodies into your cURL requests.

The following query-body uses an array, each of whose elements is a string, containing two floating-point numbers; to specify the latitude and longitude of each of the corners of a polygon --; known as _polygon points_. In each string, the `lat` floating-point value precedes the `lon.`

Here, the last-specified string in the array is identical to the initial string, thus explicitly closing the box. However, specifying an explicit closure in this way is optional: the closure will be inferred by the Couchbase Server if not explicitly specified.

If a target data-location falls within the box, its document is returned. The results are specified to be sorted on `name` alone.

```json
{
  "query": {
    "field": "geo",
    "polygon_points": [
      "37.79393211306212,-122.44234633404847",
      "37.77995881733997,-122.43977141339417",
      "37.788031092020155,-122.42925715405579",
      "37.79026946582319,-122.41149020154114",
      "37.79571192027403,-122.40735054016113",
      "37.79393211306212,-122.44234633404847"
    ]
  },
  "sort": [
    "name"
  ]
}
```

A subset of formatted output might appear as follows:

```json
    .
    .
    .
"hits": [
  {
    "index": "test_geopoint_610cbb5808dfd319_4c1c5584",
    "id": "landmark_25944",
    "score": 0.23634379439298683,
    "sort": [
      "4"
    ]
  },
  {
    "index": "test_geopoint_610cbb5808dfd319_4c1c5584",
    "id": "landmark_25681",
    "score": 0.31367419004657393,
    "sort": [
      "alta"
    ]
  },
  {
    "index": "test_geopoint_610cbb5808dfd319_4c1c5584",
    "id": "landmark_25686",
    "score": 0.31367419004657393,
    "sort": [
      "atherton"
    ]
  },
        .
        .
        .
```