Filter out records from two indexes using Geo_Shape and Geo_Point

Hi there,

I'm pretty new to the community and Elasticsearch.
As it is my first post here, I will shortly present myself as an IT developper leaving in France, working with python language.

I've recently setup an Elasticsearch 2.4 in an effort to try Geo queries like Within, Distance and Contains.
I've two set of data in two separate indexes, one with cities boundary, and the other one with point of interests (POI), (a lon/lat couple).
I've managed to create the mapping as follow:

curl -XPUT 'http://localhost:9200/place-index' -d '{
    "mappings": {
      "venues": {
      "properties": {
        "name":{
          "type":"string"
        },
        "geom": {
          "type": "geo_shape"
        }
      }
    }
  }
}'

And for the POIs:

curl -XPUT 'http://localhost:9200/poi-index' -d '{
    "mappings": {
      "venues": {
      "properties": {
        "name":{
          "type":"string"
        },
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}'

Reading the documentation it seems that joining two indexes is not possible (like one would do using SQL).

How would you filter out poi's that are within a particular Polygon (or MultiPolygon) from place-index using Elasticsearch?

I've also heard of SIREn relation join plugin (see: http://siren.solutions/relational-joins-for-elasticsearch-the-siren-join-plugin/), but it seems like it works as a ForeignKey join which is not my scenario here.

Using SQL you would join the two "tables" filtering them out with a ST_Within(point, geom) for example.

I'm sure there must be a way to achieve what I want, even not using joins but from now, I would like to discuss it and learn the "good way" of doing it.

Welcome :slight_smile:

The only way is to get the polygon you want via one query, and then run another query against the POIs to find them. There is no way to run a single query for this.

You could use percolator though.