Is it possible to run an aggregation on shapefiles?

Viewed 8

Say for example I have 2 indexes, one with polygons and the other with points:

POST /shapefiles/USA
{
  "location" : "POLYGON ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0))"
}
POST /shapefiles/MEX
{
  "location" : "POLYGON ((100.0 0.0, 102.0 0.0, 102.0 1.0, 100.0 1.0, 100.0 0.0))"
}
POST /points/1
{
  "text": "White house",
  "location": "41.12,-71.34" 
}
POST /points/2
{
  "text": "Empire state building",
  "location": "42.12,-71.34" 
}
POST /points/3
{
  "text": "Palacio de Correos de Mexico",
  "location": "43.12,-71.34" 
}

I now want to aggregate the points by the polygons that they fall inside. i.e:

Shapefile COUNT(points)
USA 2
MEX 1

Is this possible to achieve in Elasticsearch?

0 Answers
Related