# Indexed Shape with multiple circles in one document

**URL:** <https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168>\
**Category:** Elasticsearch\
**Created:** [May 1, 2017, 6:03pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168 "2017-05-01T18:03:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 1, 2017, 6:03pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/1 "2017-05-01T18:03:36Z")

</div>

Hi,

I am trying to store multiple circles as part of one document to be used inside an Indexed Shape query. Can someone point me to the right documentation for how to create as many as 100 circle as part of one document. The documentation shows how to do this for one polygon:

```
PUT /attractions/neighborhood/central_amsterdam
{
  "name" : "Central Amsterdam",
  "location" : {
      "type" : "polygon",
      "coordinates" : [[
        [4.88330,52.38617],
        [4.87463,52.37254],
        [4.87875,52.36369],
        [4.88939,52.35850],
        [4.89840,52.35755],
        [4.91909,52.36217],
        [4.92656,52.36594],
        [4.93368,52.36615],
        [4.93342,52.37275],
        [4.92690,52.37632],
        [4.88330,52.38617]
      ]]
  }
}

```

What I want is to be able to store 100 circles as part of 1 document. Is that possible?

Thanks.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 2, 2017, 8:16am UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/2 "2017-05-02T08:16:13Z")

</div>

Just create something with multiple location polygons, ie `location`, `location1`, `locationN`.

What sort of document has 100 circles though?

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 2, 2017, 5:15pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/3 "2017-05-02T17:15:35Z")

</div>

The use-case involves checking whether a lat,long co-ordinate is with-in 10 meters of any 100 service locations of a type. For example a bank has 100 ATM's in a city and given a lat,long co-ordinate I want to find out whether that co-ordinate is near any of the 100 ATMs.

Am I headed in the right direction, can this problem be solved by creating one document with 100 circles, and then using this document as part of an indexed shape query?

Thanks.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 2, 2017, 8:30pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/4 "2017-05-02T20:30:56Z")

</div>

Why not have 100 documents, one per ATM?

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 3, 2017, 9:10pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/5 "2017-05-03T21:10:25Z")

</div>

Would I be able to use Indexed Shape Query if all locations are stored as their own document? I was under the impression that for Indexed Shape queries to work, the shape has to be stored in one document...

I was using this example as reference provided here [https://www.elastic.co/guide/en/elasticsearch/guide/current/indexed-geo-shapes.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/indexed-geo-shapes.html):

This is the example provided in the link above:

```
GET /attractions/landmark/_search
{
  "query": {
    "geo_shape": {
      "location": {
        "relation": "within",
        "indexed_shape": { 
          "index": "attractions",
          "type": "neighborhood",
          "id": "central_amsterdam",
          "path": "location"
        }
      }
    }
  }
}

```

Would it be possible to alter the query to check multiple documents which store each ATM location?

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 3, 2017, 9:46pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/6 "2017-05-03T21:46:56Z")

</div>

You can run the query over multiple docs, it's no different to other queries, just that the example shows you what a single-doc query would look like.

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 4, 2017, 6:33pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/7 "2017-05-04T18:33:39Z")

</div>

I have been trying to change my query to allow specifying multiple id inside the indexed shape query. It looks something like:

```
GET /locations/entry/_search
{
  "query": {
    "geo_shape": {
      "locationlatlong": {
        "relation": "within",
        "indexed_shape": { 
          "index": "atms",
          "type": "doc",
          "id": ["1","2","3"],
          "path": "atmlatlong"
        }
      }
    }
  }
}

```

But the above query throws the follow error: unknown token [START\_ARRAY] after [id]

How should the indexed\_shape query be updated to allow it to search all documents in the atms index?

Thanks.

---

<div class="post-metadata">

**Author:** ![esuser1](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@esuser1](https://discuss.elastic.co/u/esuser1)\
**Post date:** [May 8, 2017, 7:50pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/8 "2017-05-08T19:50:07Z")

</div>

bumping the topic, need to solve a similar issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 5, 2017, 7:51pm UTC](https://discuss.elastic.co/t/indexed-shape-with-multiple-circles-in-one-document/84168/9 "2017-06-05T19:51:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
