# Exclude complete path from indexing and \_source

**URL:** https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854
**Category:** Elasticsearch
**Created:** [December 23, 2015, 12:14pm UTC](https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854 "2015-12-23T12:14:23Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [December 23, 2015, 2:19pm UTC](https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854/2 "2015-12-23T14:19:53Z")

</div>

Here is some more info on further stuff I have tried in the meantime (sorry if my examples use the Python API and not the classic CURL way). Which is just excluding a single field from the \_source:

```
from elasticsearch import Elasticsearch

es = Elasticsearch([{'host': '127.0.0.1', 'port': 9200}])

body = {"settings": 
        {"index.mapping.ignore_malformed": "true"}, 
        "mappings":
        {"reports":{"_all":{"enabled": "false"}, 
                    "_source":{"excludes":["data"]}, ... (other mappings)

es.indices.create(index='test', body=body)

```

Then I index a document to "reports"

report = open("somepath/report.json",'rb').read()  
print es.index(index='test', doc\_type="reports", body=report)

which gives me some ID which I use to check the index and source:

```
import json
print json.dumps(es.get('test',id="ID"),indent=4, sort_keys=True)
print json.dumps(es.get_source('test',doc_type="reports",id="ID"),indent=4, sort_keys=True)

```

Now if I look at the output of the get\_source, the "data" part is still there.

---

_[View the full topic](https://discuss.elastic.co/t/exclude-complete-path-from-indexing-and--source/37854)._
