# Unable to search indexed-shape if excluding source

**URL:** https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521
**Category:** Elasticsearch
**Created:** [December 7, 2015, 11:15am UTC](https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521 "2015-12-07T11:15:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Peter\_Neubauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter_neubauer/32/6456_2.png) [@Peter\_Neubauer](https://discuss.elastic.co/u/Peter_Neubauer)
#### Post date: [December 7, 2015, 11:15am UTC](https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521/1 "2015-12-07T11:15:59Z")

</div>

Hi there,  
I indexed shapes in an ELS 1.7.3 index that have the mapping

```
{"wof":
  {"_source":
    {"excludes":["shape"]},
    "properties":{ 
       "shape":{
          "type":"geo_shape",
          "tree":"quadtree",
         "tree_levels":20}...

```

Because the shape-fields are quite big in certain cases and slow down source retrieval (they come from [https://github.com/whosonfirst/whosonfirst-data](https://github.com/whosonfirst/whosonfirst-data))  
Now, normal searches like this are working correctly:

```
{
  "query": {
    "filtered": {
  "query": {
    "match_all": {}
  },
  "filter": {
    "geo_shape": {
      "shape": {
        "shape": {
          "type": "Point",
          "coordinates": [
            12.96,
            55.59
          ]
        }
      }
    }
  }
}
}
}

```

But something like an indexed shape in another index (mapimages/mapimage) query fails:

```
{
"query": {
"filtered": {
  "query": {
    "match_all": {}
  },
  "filter": {
    "geo_shape": {
      "l_shape": {
        "indexed_shape": {
          "id": "101752283",
          "index": "wofs",
          "type": "wof",
          "path": "shape"
        }
      }
    }
  }
}
} 
}

```

with an exception:

```
ElasticsearchIllegalStateException[Shape with name [101752283] found but missing shape field];

```

That field is there but only indexed, and it should not be needed, since the query is going against the `mapimages/mapimage` documents and never needing the `wof.shape` field?

Why is the first query working but no the second?

Thanks for any help!

/peter

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [December 7, 2015, 11:39am UTC](https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521/2 "2015-12-07T11:39:29Z")

</div>

The indexed shapes feature in the `geo_shape` query works by retrieving (by using the GET document API) the specified shape document from the index (in this case `/wofs/wof/101752283`) and reading the field in the source of the document specified in the `path` (in this case the `shape` field). If you exclude the `shape` field from the source ES wont be able to access the shape definition and therefore won't be able to execute the query.

---

<div class="post-metadata">

### Author: ![Peter\_Neubauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter_neubauer/32/6456_2.png) [@Peter\_Neubauer](https://discuss.elastic.co/u/Peter_Neubauer)
#### Post date: [December 7, 2015, 12:30pm UTC](https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521/3 "2015-12-07T12:30:15Z")

</div>

Ahh,  
ok - I thought there would be some reuse of the already indexed shape more than just getting the source.

Thanks a lot for the fast answer @colings86 !

/peter

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:33pm UTC](https://discuss.elastic.co/t/unable-to-search-indexed-shape-if-excluding-source/36521/4 "2017-07-05T23:33:02Z")

</div>


