# \[failed to parse search source. unknown search element \[mappings\]\]

**URL:** https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595
**Category:** Elasticsearch
**Created:** [June 12, 2018, 8:22pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595 "2018-06-12T20:22:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![silversun](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@silversun](https://discuss.elastic.co/u/silversun)
#### Post date: [June 12, 2018, 8:22pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/1 "2018-06-12T20:22:05Z")

</div>

Hi,

I am trying to exclude a field from \_source and I am trying to run this curl command -

```
curl -X POST "http://localhost:9200/appindex/appindex/_search" -d '{
  "mappings":{
     "appindex":{
        "_source":{
           "excludes":[
              "field_attachment_resource_name_base64"
           ]
        },
        "properties":{
           "field_attachment_resource_name_base64":{
              "type":"attachment",
              "fields":{
                 "content":{
                    "type":"string",
                    "store":true
                 }
              }
           },
           "name":{
              "type":"string"
           }
        }
     }
  }
}'

```

And this is the **error** I get -

> SearchParseException[failed to parse search source. unknown search element [mappings]]

> {"error":{"root\_cause":[{"type":"search\_parse\_exception","reason":"failed to parse search source. unknown search element [mappings]","line":2,"col":14}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"pbaindex","node":"PQBFXvM5XniVQ","reason":{"type":"search\_parse\_exception","reason":"failed to parse search source. unknown search element [mappings]","line":2,"col":14}}]},"status":400}

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [June 12, 2018, 8:23pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/2 "2018-06-12T20:23:05Z")

</div>

Your url looks like a search command. The request body looks like [put mapping](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/indices-put-mapping.html) command. Not sure if you want to exclude field during indexing or during searching.

---

<div class="post-metadata">

### Author: ![silversun](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@silversun](https://discuss.elastic.co/u/silversun)
#### Post date: [June 12, 2018, 8:27pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/3 "2018-06-12T20:27:12Z")

</div>

Thanks for your response! I added new type "attachment" using mapper attachment plugin (ES 2.4).

I have indexed two documents and the base64 "content" field is showing up under "\_source" which increases the size of the document.

I would like to exclude it from \_source. Please advise best approach.

I was following this url - [https://qbox.io/blog/index-attachments-files-elasticsearch-mapper](https://qbox.io/blog/index-attachments-files-elasticsearch-mapper)

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [June 12, 2018, 8:28pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/4 "2018-06-12T20:28:55Z")

</div>

it should be

```auto
curl -X POST "http://localhost:9200/appindex" -d '{
  "mappings":{
....

```

instead of

```auto
curl -X POST "http://localhost:9200/appindex/appindex/_search" -d '{
  "mappings":{
....

```

---

<div class="post-metadata">

### Author: ![silversun](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@silversun](https://discuss.elastic.co/u/silversun)
#### Post date: [June 12, 2018, 8:32pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/5 "2018-06-12T20:32:49Z")

</div>

Thank you! I get this new error now -

> {"error":{"root\_cause":[{"type":"index\_already\_exists\_exception","reason":"already exists","index":"appindex"}],"type":"index\_already\_exists\_exception","reason":"already exists","index":"appindex"},"status":400}

This is my new curl command -

```
curl -X POST "http://localhost:9200/appindex" -d '{
  "mappings":{
     "appindex":{
        "_source":{
           "excludes":[
              "field_attachment_resource_name_base64"
           ]
        },
        "properties":{
           "field_attachment_resource_name_base64":{
              "type":"attachment",
              "fields":{
                 "content":{
                    "type":"string",
                    "store":true
                 }
              }
           },
           "name":{
              "type":"string"
           }
        }
     }
  }
}'

```

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [June 12, 2018, 8:36pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/6 "2018-06-12T20:36:31Z")

</div>

Yes, you need to recreate your index.

Delete index first with

```auto
curl -X DELETE "http://localhost:9200/appindex"

```

Then execute the command that you posted.

Please, note that it will delete all data in this index. So, you will have to add all your data again.

---

<div class="post-metadata">

### Author: ![silversun](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@silversun](https://discuss.elastic.co/u/silversun)
#### Post date: [June 12, 2018, 8:38pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/7 "2018-06-12T20:38:21Z")

</div>

Okay. I will try that. Thanks!

---

<div class="post-metadata">

### Author: ![silversun](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@silversun](https://discuss.elastic.co/u/silversun)
#### Post date: [June 12, 2018, 8:46pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/8 "2018-06-12T20:46:34Z")

</div>

It worked!!! Thank you very much!!!!!

---

<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 10, 2018, 8:46pm UTC](https://discuss.elastic.co/t/failed-to-parse-search-source-unknown-search-element-mappings/135595/9 "2018-07-10T20:46:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
