# \_source excludes not working

**URL:** https://discuss.elastic.co/t/-source-excludes-not-working/38582
**Category:** Elasticsearch
**Created:** [January 7, 2016, 9:15am UTC](https://discuss.elastic.co/t/-source-excludes-not-working/38582 "2016-01-07T09:15:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 7, 2016, 9:15am UTC](https://discuss.elastic.co/t/-source-excludes-not-working/38582/1 "2016-01-07T09:15:11Z")

</div>

This is related to my previous post

> [@Exclude complete path from indexing and \_source](https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854):
>
> Hi there, I use Elasticsearch 2.1.1 and have to handle large files which usually contain Base64 coded images. I want to completely skip this part of the documents when indexing them to Elasticsearch. I.e. NEITHER index them NOR add their \_source. The part of my JSONs that I want to omit looks like this: screenshotdata": {"interesting": {"data": "iVBORwfdrdfd........ (very long string) } , more elements} I have been battling with "\_source":{"excludes":["screenshotdata"]} …

I would simply like to be able to exclude fields from being included in my index.

Here is my first approach which does not work. It follows this page from the manual: [\_source field | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html)  
I know that this only excludes the field from the \_source, and not from being indexed, but still I would like to know how to use it.  
I am using Elasticsearch 2.1

Here comes my code example:

```
curl -XPOST 'http://192.168.56.102:9200/test' -d '{"mappings":{"my_type":{"_source":{"excludes":["ignoreme"]}}}}'

curl -XGET http://192.168.56.102:9200/test?pretty
{
  "test" : {
    "aliases" : { },
    "mappings" : {
      "my_type" : {
        "_source" : {
          "excludes" : ["ignoreme"]
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1452157634005",
        "uuid" : "QBa6kp71SQm-AZOfORzy-w",
        "number_of_replicas" : "1",
        "number_of_shards" : "5",
        "version" : {
          "created" : "2010099"
        }
      }
    },
    "warmers" : { }
  }
}

curl -XPOST 'http://192.168.56.102:9200/test/documents/1' -d '{"title":"Something","ignoreme":"I should not be here"}'

curl -XGET http://192.168.56.102:9200/test/documents/1
{
  "_index" : "test",
  "_type" : "documents",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"title":"Something","ignoreme":"I should not be here"}
}

```

Why does "ignoreme" show up in the \_source of the GET call?

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [January 7, 2016, 9:37am UTC](https://discuss.elastic.co/t/-source-excludes-not-working/38582/2 "2016-01-07T09:37:53Z")

</div>

The problem is that you configured a mapping for the "my\_type" type but then you post documents into "documents".

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 7, 2016, 9:40am UTC](https://discuss.elastic.co/t/-source-excludes-not-working/38582/3 "2016-01-07T09:40:50Z")

</div>

Thanks! I messed that up when writing the example for this question.  
Now it works, so I can try again on my original data. Thanks again!

---

<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:26pm UTC](https://discuss.elastic.co/t/-source-excludes-not-working/38582/4 "2017-07-05T23:26:28Z")

</div>


