8

I have 'shapes' index that stores a lot of huge geoshapes (original shapefile for one geoshape was 6MB in size).

I'm using this mapping:

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

I also have 'photos' index. Each photo have latitude and longitude presented as geoshape with type Point. e.g.

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

Mapping for it:

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

I'm trying to find all photos that located inside selected shape by using 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": {}
      }
    }
  }
}

Issues:

1) On a huge shapes this query executes several minutes or forever.

2) Just searching shapes by some parameters takes a lot of time if "shape" included into source, but if I exclude it - geo_shape filter will throw an exception - "Shape found but missing field"

In mapping:

_source: {
  excludes : ['shape']
}

Is there some way to solve this issues?

User Created Image
  • 1,182
  • 2
  • 17
  • 33

0 Answers0