Indexed Shape with multiple circles in one document


#1

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.


(Mark Walkom) #2

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

What sort of document has 100 circles though?


#3

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.


(Mark Walkom) #4

Why not have 100 documents, one per ATM?


#5

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:

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


(Mark Walkom) #6

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.


#7

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.


#8

bumping the topic, need to solve a similar issue.


(system) #9

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