Elasticsearch - find points inside a huge geo-shape

I have an “shapes” index, which stores a lot of huge geoshaps (the source shapefile for one geoshap was 6 MB in size).

I use this mapping:

"shape": {
    "type": "geo_shape",
    "tree": "quadtree",
    "tree_levels": "20"
},
"_all": {
   "enabled": false
},
"dynamic": "true"

I also have a photo index. Each photo has latitude and longitude, presented as a geo-cap with the type Point. eg.

"location": {
  "type": "Point",
  "coordinates": [
    -103.262600,
    43.685315
  ]
}

Display for him:

"location": {
 "type": "geo_shape",
 "tree": "quadtree",
 "tree_levels": 20
}

I am trying to find all the photos that are inside the selected shape using the following query:

GET photos/_search
{
  "query": {
    "filtered": {
      "filter": {
        "geo_shape": {
          "location": { 
            "relation": "intersects",
            "indexed_shape": {
              "id": "huge_region_shape_id",
              "type": "country",
              "index": "shapes",
              "path": "shape"
            }
          }
        }
      },
      "query": {
        "match_all": {}
      }
    }
  }
}

Questions:

1) On huge figures, this request is executed for several minutes or forever.

2) It just takes a long time to search for shapes by some parameters if the "form" is included in the source code, but if I exclude it, the geo_shape filter will throw an exception - "Shape found, but there is no field

When displaying:

_source: {
  excludes : ['shape']
}

?

+4

All Articles