# Attachment Plugin : content-type autodetection

**URL:** <https://discuss.elastic.co/t/attachment-plugin-content-type-autodetection/8532>\
**Category:** Elasticsearch\
**Created:** [July 26, 2012, 9:21pm UTC](https://discuss.elastic.co/t/attachment-plugin-content-type-autodetection/8532 "2012-07-26T21:21:36Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [July 26, 2012, 9:21pm UTC](https://discuss.elastic.co/t/attachment-plugin-content-type-autodetection/8532/1 "2012-07-26T21:21:36Z")

</div>

Heya,

I'm working on an issue about content-type autodetection that doesn't seem  
to work as expected.

I just added a tika().detect() method and I'm able to see in debug mode that  
my file is right detected by the mapper attachment plugin.

But when Elasticsearch saved the document, metadata does not seem to be  
added.

@Shay : would you please have a look at my commit :  
[https://github.com/dadoonet/elasticsearch-mapper-attachments](https://github.com/dadoonet/elasticsearch-mapper-attachments)

> **[dadoonet/elasticsearch-mapper-attachments](https://github.com/dadoonet/elasticsearch-mapper-attachments)**
>
> elasticsearch-mapper-attachments - Mapper Attachments Type plugin for ElasticSearch

And run the test case I added :  
\<[https://github.com/dadoonet/elasticsearch-mapper-attachments/blob/master/sr](https://github.com/dadoonet/elasticsearch-mapper-attachments/blob/master/sr)  
c/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmen  
tIntegrationTests.java#L139\>  
[https://github.com/dadoonet/elasticsearch-mapper-attachments/blob/master/src](https://github.com/dadoonet/elasticsearch-mapper-attachments/blob/master/src)  
/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachment  
IntegrationTests.java#L139

You will see that assertThat(getResponse.field("file.content\_type"),  
notNullValue()); fail.

Same for assertThat(getResponse.field("file.\_content\_type"),  
notNullValue());

Any idea?

Thanks

David.

---

<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 6, 2017, 3:18am UTC](https://discuss.elastic.co/t/attachment-plugin-content-type-autodetection/8532/2 "2017-07-06T03:18:53Z")

</div>


