# Setting a mapping for mapper-attachments

**URL:** <https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620>\
**Category:** Elasticsearch\
**Created:** [February 1, 2016, 9:23am UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620 "2016-02-01T09:23:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francois\_GUERIN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francois_guerin/32/5950_2.png) [@Francois\_GUERIN](https://discuss.elastic.co/u/Francois_GUERIN)\
**Post date:** [February 1, 2016, 9:23am UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/1 "2016-02-01T09:23:26Z")

</div>

Hi,

I'm using elasticsearch through django haystack, and I'm trying to set a mapping for an attachment.  
This mapping is PUT to the es engine when creating the new index. This operation is done when rebuilding index.

My mapping looks like this (python dict encoded, json is produced later):

[https://gist.github.com/frague59/eddc0c9446809ba0c917](https://gist.github.com/frague59/eddc0c9446809ba0c917)

When I re-create the index, I've an error in the es logs :  
[https://gist.github.com/frague59/843dbaea1981b4232a49](https://gist.github.com/frague59/843dbaea1981b4232a49)

I've tryed many settings conbinations, but I'm still stuck : the mapping is not created.  
I've watched sour-code for mapper attachment, but I can't figure out how to set the mapping...

Thanks for your help !

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2016, 9:38am UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/2 "2016-02-01T09:38:01Z")

</div>

Hi François

Could you please edit your thread and add a proper formatting. It's really hard to read.

You can use this to format a full block

````
```

````

But don't use `` ` before each line.

Could you also give the versions you are using please?

---

<div class="post-metadata">

**Author:** ![Francois\_GUERIN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francois_guerin/32/5950_2.png) [@Francois\_GUERIN](https://discuss.elastic.co/u/Francois_GUERIN)\
**Post date:** [February 1, 2016, 9:59am UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/3 "2016-02-01T09:59:03Z")

</div>

I've updated with gist.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 1, 2016, 10:27am UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/4 "2016-02-01T10:27:46Z")

</div>

Which version please?

---

<div class="post-metadata">

**Author:** ![Francois\_GUERIN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francois_guerin/32/5950_2.png) [@Francois\_GUERIN](https://discuss.elastic.co/u/Francois_GUERIN)\
**Post date:** [February 1, 2016, 12:56pm UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/5 "2016-02-01T12:56:55Z")

</div>

I'm using mapper-attachments 3.1.1 with 2.1 elasticsearch.  
I've corrected some things :

- "mapping" key must be at the same level than "settings"
- The `rebuild_index` command explores the objects classes to index, then it builds the mapping. I've re-wrote the mapping building, and it works better now.

Thanks !

---

<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:19pm UTC](https://discuss.elastic.co/t/setting-a-mapping-for-mapper-attachments/40620/6 "2017-07-05T23:19:55Z")

</div>


