# Problem with .docx and the mapper-attachments plugin

**URL:** <https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804>\
**Category:** Elasticsearch\
**Created:** [March 18, 2016, 8:03am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804 "2016-03-18T08:03:40Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markus\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markus_ziegler/32/8550_2.png) [@Markus\_Ziegler](https://discuss.elastic.co/u/Markus_Ziegler)\
**Post date:** [March 18, 2016, 8:03am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/1 "2016-03-18T08:03:40Z")

</div>

Hi guys.

I'm currently evaluating elastic search for one of my little private software projects 🙂

I'm trying to index attachments with the mapper-attachments plugin and the indexing of .txt and .pdf files works fine.

But I think there is an error in the indexing of .docx files. When searching for my test string, I get the PDF and .txt results, but not the .docx results. I already searched for this problem but I can't find a solution for this one.

I followed the instructions for index creation on [https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/mapper-attachments-highlighting.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/mapper-attachments-highlighting.html) and added the .docx file with the following command:

PUT /test/person/4?refresh=true  
{  
"file": {  
"\_content\_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",  
"\_content": "... MY BASE64 CONTENT ..."  
}  
}

Is this problem repeatable by anyone?

Thanks 🙂

---

<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:** [March 18, 2016, 8:15am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/2 "2016-03-18T08:15:10Z")

</div>

Yes. [https://github.com/elastic/elasticsearch/pull/17059](https://github.com/elastic/elasticsearch/pull/17059)

---

<div class="post-metadata">

**Author:** ![Markus\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markus_ziegler/32/8550_2.png) [@Markus\_Ziegler](https://discuss.elastic.co/u/Markus_Ziegler)\
**Post date:** [March 18, 2016, 8:31am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/3 "2016-03-18T08:31:24Z")

</div>

Thanks a lot for your hint.

Is there a way to update the plugin without the need of compiling it?

With the command "bin\plugin.bat install mapper-attachments" the docx files still won't work.

Thanks! 🙂

---

<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:** [March 18, 2016, 9:06am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/4 "2016-03-18T09:06:48Z")

</div>

I'm afraid you have to wait for elasticsearch 2.3.0 which fixes this.  
I'm unsure if there is a plan to backport in 2.2.x.

@Clinton_Gormley1 WDYT?

---

<div class="post-metadata">

**Author:** ![Markus\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markus_ziegler/32/8550_2.png) [@Markus\_Ziegler](https://discuss.elastic.co/u/Markus_Ziegler)\
**Post date:** [March 21, 2016, 6:36am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/5 "2016-03-21T06:36:36Z")

</div>

Ok thanks, then I will wait till the release of 2.3.0

Is there an approximate release date of this version?

Thanks!

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [June 3, 2016, 7:40pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/6 "2016-06-03T19:40:19Z")

</div>

Hi @Markus_Ziegler

How is your project going?

it´s working now! I have used only the extension file when indexing, as below:

```
$filetype = 'docx'; // Or 'pdf' or 'txt' or 'doc'

  'body' => [
       'file' => [
             '_content_type' => 'application/' . $filetype,
             '_name' => $file, // full file pathname
             '_language' => $lang, //language
             '_indexed_chars' => -1,
             '_content' => base64_encode(file_get_contents($file))
      ]
 ] 

```

Code for php library.

Cheers!

---

<div class="post-metadata">

**Author:** ![Drammy](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Drammy](https://discuss.elastic.co/u/Drammy)\
**Post date:** [June 29, 2016, 9:47am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/7 "2016-06-29T09:47:08Z")

</div>

Hi @evert, what version are you running?

---

<div class="post-metadata">

**Author:** ![Markus\_Ziegler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markus_ziegler/32/8550_2.png) [@Markus\_Ziegler](https://discuss.elastic.co/u/Markus_Ziegler)\
**Post date:** [June 29, 2016, 9:59am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/8 "2016-06-29T09:59:56Z")

</div>

Thanks for all your assistance.

It's working now in the current version 2.3.3 and I'm able to index docx files as expected.

Loving this project 🙂

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [June 29, 2016, 10:11am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/9 "2016-06-29T10:11:28Z")

</div>

Hi @Drammy I am using 2.3.3.

---

<div class="post-metadata">

**Author:** ![Drammy](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Drammy](https://discuss.elastic.co/u/Drammy)\
**Post date:** [June 29, 2016, 3:00pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/10 "2016-06-29T15:00:47Z")

</div>

That's great, thanks.

Is there a list somewhere of the supported document types? (or is it just those supported in Tika?)

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [June 29, 2016, 3:37pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/11 "2016-06-29T15:37:48Z")

</div>

I think it's the ones supported in Tika. It uses Tika.

---

<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:** [June 29, 2016, 4:14pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/12 "2016-06-29T16:14:53Z")

</div>

Actually we removed some dependencies and kept the most common ones for common file types like PDF, oOo, MSOffice, text...

---

<div class="post-metadata">

**Author:** ![Drammy](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Drammy](https://discuss.elastic.co/u/Drammy)\
**Post date:** [June 29, 2016, 4:29pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/13 "2016-06-29T16:29:57Z")

</div>

Hi David,

Do you know if there's a list somewhere?

We need to index documents from a system that can store any doc type. If ES doesn't index a given document we'll need to handle that scenario by reading in the contents ourselves and indexing them separately...

---

<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:** [June 29, 2016, 5:04pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/14 "2016-06-29T17:04:49Z")

</div>

That's what I'd do for all docs instead of sending binary content to Elasticsearch.  
So I mean: don't use mapper attachments plugin if you can do text extraction in another way. You can use Tika by yourself actually.

I don't have such a list.

---

<div class="post-metadata">

**Author:** ![Drammy](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Drammy](https://discuss.elastic.co/u/Drammy)\
**Post date:** [June 30, 2016, 9:18pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/15 "2016-06-30T21:18:44Z")

</div>

Thanks David, we'll look into this approach - makes sense to me.

Do you know where I can get such a list? Anyone I can ask?  
I'd have thought there should be a list somewhere of what doc types the attachment plugin supports...

---

<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 1, 2016, 5:44am UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/16 "2016-07-01T05:44:03Z")

</div>

Well. We wrote this issue at some point: [https://github.com/elastic/elasticsearch-mapper-attachments/issues/163](https://github.com/elastic/elasticsearch-mapper-attachments/issues/163)

But if you use Tika on your side you are not limited by our implementation.

So the Tika list is [https://tika.apache.org/1.13/formats.html](https://tika.apache.org/1.13/formats.html)

---

<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, 10:39pm UTC](https://discuss.elastic.co/t/problem-with-docx-and-the-mapper-attachments-plugin/44804/17 "2017-07-05T22:39:06Z")

</div>


