# How do I map an array of attachments

**URL:** <https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419>\
**Category:** Elasticsearch\
**Created:** [October 7, 2010, 2:04pm UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419 "2010-10-07T14:04:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 7, 2010, 2:04pm UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/1 "2010-10-07T14:04:03Z")

</div>

I have items, which I want to index, which have multiple attachments.  
On beforehand I don't know how much, so I want to make an array of  
attachments.

Basic checks:

- Using Elasticsearch 0.11.0
- Installed the attachments mapper (on running it says loaded [mapper-  
attachments, analysis-icu])
- Using the REST API

So i have the index myitems, and the type docitem.

For indexing I use:

URL: [http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
Content:  
{  
"id" : 1,  
"name": "test",  
"description": "test",  
"files" : [  
{  
"\_content\_type" : "application/msword",  
"\_name" : "resource/name/of/my.doc",  
"content" : "... base64 encoded attachment ..."  
},  
{  
"\_content\_type" : "application/pdf",  
"\_name" : "resource/name/of/my.pdf",  
"content" : "... base64 encoded attachment ..."  
},  
{  
"\_content\_type" : "application/msexcel",  
"\_name" : "resource/name/of/my.xls",  
"content" : "... base64 encoded attachment ..."  
},  
]  
}

So I suppose the put\_mapping whould be:

URL: [http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
Content:  
{  
"docitem": {  
"properties" : {  
"files" : { "type" : "attachment" }  
}  
}  
}

But when I search the contents of a word document as attachment, I  
don't get any result, but searching for any other field does.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [October 7, 2010, 2:14pm UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/2 "2010-10-07T14:14:45Z")

</div>

Hi,

do you think you could share your query? How it looks like?

Regards,  
Lukas

On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghuizen@gmail.com](mailto:michieleghuizen@gmail.com) wrote:

> I have items, which I want to index, which have multiple attachments.  
> On beforehand I don't know how much, so I want to make an array of  
> attachments.
> 
> Basic checks:
> 
> - Using Elasticsearch 0.11.0
> - Installed the attachments mapper (on running it says loaded [mapper-  
> attachments, analysis-icu])
> - Using the REST API
> 
> So i have the index myitems, and the type docitem.
> 
> For indexing I use:
> 
> URL: [http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> Content:  
> {  
> "id" : 1,  
> "name": "test",  
> "description": "test",  
> "files" : [  
> {  
> "\_content\_type" : "application/msword",  
> "\_name" : "resource/name/of/my.doc",  
> "content" : "... base64 encoded attachment  
> ..."  
> },  
> {  
> "\_content\_type" : "application/pdf",  
> "\_name" : "resource/name/of/my.pdf",  
> "content" : "... base64 encoded attachment  
> ..."  
> },  
> {  
> "\_content\_type" : "application/msexcel",  
> "\_name" : "resource/name/of/my.xls",  
> "content" : "... base64 encoded attachment  
> ..."  
> },  
> ]  
> }
> 
> So I suppose the put\_mapping whould be:
> 
> URL: [http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> Content:  
> {  
> "docitem": {  
> "properties" : {  
> "files" : { "type" : "attachment" }  
> }  
> }  
> }
> 
> But when I search the contents of a word document as attachment, I  
> don't get any result, but searching for any other field does.
> 
> What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 7, 2010, 3:25pm UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/3 "2010-10-07T15:25:41Z")

</div>

Actally plain and simple, because I read default\_filed is by default  
\_all.

URL: [http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)

And Sync4J is a word in the content of the MS Word document.

On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> Hi,
> 
> do you think you could share your query? How it looks like?
> 
> Regards,  
> Lukas
> 
> On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> 
> > I have items, which I want to index, which have multiple attachments.  
> > On beforehand I don't know how much, so I want to make an array of  
> > attachments.
> 
> > Basic checks:
> > 
> > - Using Elasticsearch 0.11.0
> > - Installed the attachments mapper (on running it says loaded [mapper-  
> > attachments, analysis-icu])
> > - Using the REST API
> 
> > So i have the index myitems, and the type docitem.
> 
> > For indexing I use:
> 
> > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > Content:  
> > {  
> > "id" : 1,  
> > "name": "test",  
> > "description": "test",  
> > "files" : [  
> > {  
> > "\_content\_type" : "application/msword",  
> > "\_name" : "resource/name/of/my.doc",  
> > "content" : "... base64 encoded attachment  
> > ..."  
> > },  
> > {  
> > "\_content\_type" : "application/pdf",  
> > "\_name" : "resource/name/of/my.pdf",  
> > "content" : "... base64 encoded attachment  
> > ..."  
> > },  
> > {  
> > "\_content\_type" : "application/msexcel",  
> > "\_name" : "resource/name/of/my.xls",  
> > "content" : "... base64 encoded attachment  
> > ..."  
> > },  
> > ]  
> > }
> 
> > So I suppose the put\_mapping whould be:
> 
> > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > Content:  
> > {  
> > "docitem": {  
> > "properties" : {  
> > "files" : { "type" : "attachment" }  
> > }  
> > }  
> > }
> 
> > But when I search the contents of a word document as attachment, I  
> > don't get any result, but searching for any other field does.
> 
> > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [October 7, 2010, 9:19pm UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/4 "2010-10-07T21:19:37Z")

</div>

I did not try to index attachments in array myself but single attachment per  
document works fine or me. And your mappings look good to me. If I were you  
I would try to check if other words from that document work for search or  
not. Then I would try to check what content the Tika was able to get out of  
this document (there is Swing console for Tika that can be used for quick  
tests, see:  
[http://tika.apache.org/0.7/gettingstarted.html#Using\_Tika\_as\_a\_command\_line\_utility](http://tika.apache.org/0.7/gettingstarted.html#Using_Tika_as_a_command_line_utility)  
,  
just run it and drag and drop that document to it and see the content Tika  
is able extract). If the word is there then I would try check elasticsearch  
index with Luke.

HTH,  
Lukas

On Thu, Oct 7, 2010 at 5:25 PM, Michiel [michieleghuizen@gmail.com](mailto:michieleghuizen@gmail.com) wrote:

> Actally plain and simple, because I read default\_filed is by default  
> \_all.
> 
> URL: [http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)
> 
> And Sync4J is a word in the content of the MS Word document.
> 
> On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> 
> > Hi,
> > 
> > do you think you could share your query? How it looks like?
> > 
> > Regards,  
> > Lukas
> > 
> > On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com)  
> > wrote:
> > 
> > > I have items, which I want to index, which have multiple attachments.  
> > > On beforehand I don't know how much, so I want to make an array of  
> > > attachments.
> > 
> > > Basic checks:
> > > 
> > > - Using Elasticsearch 0.11.0
> > > - Installed the attachments mapper (on running it says loaded [mapper-  
> > > attachments, analysis-icu])
> > > - Using the REST API
> > 
> > > So i have the index myitems, and the type docitem.
> > 
> > > For indexing I use:
> > 
> > > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > > Content:  
> > > {  
> > > "id" : 1,  
> > > "name": "test",  
> > > "description": "test",  
> > > "files" : [  
> > > {  
> > > "\_content\_type" : "application/msword",  
> > > "\_name" : "resource/name/of/my.doc",  
> > > "content" : "... base64 encoded  
> > > attachment  
> > > ..."  
> > > },  
> > > {  
> > > "\_content\_type" : "application/pdf",  
> > > "\_name" : "resource/name/of/my.pdf",  
> > > "content" : "... base64 encoded  
> > > attachment  
> > > ..."  
> > > },  
> > > {  
> > > "\_content\_type" : "application/msexcel",  
> > > "\_name" : "resource/name/of/my.xls",  
> > > "content" : "... base64 encoded  
> > > attachment  
> > > ..."  
> > > },  
> > > ]  
> > > }
> > 
> > > So I suppose the put\_mapping whould be:
> > 
> > > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > > Content:  
> > > {  
> > > "docitem": {  
> > > "properties" : {  
> > > "files" : { "type" : "attachment" }  
> > > }  
> > > }  
> > > }
> > 
> > > But when I search the contents of a word document as attachment, I  
> > > don't get any result, but searching for any other field does.
> > 
> > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 8, 2010, 7:11am UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/5 "2010-10-08T07:11:03Z")

</div>

I found and solved "temporary" the problem.

I did try to check if tika could make something from the Word  
document, and it did. It could read the document successfully.

I got the error message (as a part of an MapperParsingException and a  
backtrace):  
Caused by: org.elasticsearch.common.jackson.JsonParseException:  
Failed to decode VALUE\_STRING as base64 (MIME-NO-LINEFEEDS): Illegal  
character '' (code 0x5c) in base64 content

Now I use PHP, and php with json\_encode does escape / characters. So  
in the whole document there were a lot of / Now as a matter of test  
I did replace all / occurences back to / and then it did index. So  
there seems to be a bug in, or PHP or in Elasticsearch JSON parser  
Jackson. I'm going to make a proof of concept, so I post this as bug  
report.

Thanks for the help.

Greetings,

Michiel

On Oct 7, 11:19 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:

> I did not try to index attachments in array myself but single attachment per  
> document works fine or me. And your mappings look good to me. If I were you  
> I would try to check if other words from that document work for search or  
> not. Then I would try to check what content the Tika was able to get out of  
> this document (there is Swing console for Tika that can be used for quick  
> tests, see:[Apache Tika – Getting Started with Apache Tika](http://tika.apache.org/0.7/gettingstarted.html#Using_Tika_as_a_comman)...  
> ,  
> just run it and drag and drop that document to it and see the content Tika  
> is able extract). If the word is there then I would try check elasticsearch  
> index with Luke.
> 
> HTH,  
> Lukas
> 
> On Thu, Oct 7, 2010 at 5:25 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> 
> > Actally plain and simple, because I read default\_filed is by default  
> > \_all.
> 
> > URL:[http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)
> 
> > And Sync4J is a word in the content of the MS Word document.
> 
> > On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> > 
> > > Hi,
> 
> > > do you think you could share your query? How it looks like?
> 
> > > Regards,  
> > > Lukas
> 
> > > On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com)  
> > > wrote:
> > > 
> > > > I have items, which I want to index, which have multiple attachments.  
> > > > On beforehand I don't know how much, so I want to make an array of  
> > > > attachments.
> 
> > > > Basic checks:
> > > > 
> > > > - Using Elasticsearch 0.11.0
> > > > - Installed the attachments mapper (on running it says loaded [mapper-  
> > > > attachments, analysis-icu])
> > > > - Using the REST API
> 
> > > > So i have the index myitems, and the type docitem.
> 
> > > > For indexing I use:
> 
> > > > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > > > Content:  
> > > > {  
> > > > "id" : 1,  
> > > > "name": "test",  
> > > > "description": "test",  
> > > > "files" : [  
> > > > {  
> > > > "\_content\_type" : "application/msword",  
> > > > "\_name" : "resource/name/of/my.doc",  
> > > > "content" : "... base64 encoded  
> > > > attachment  
> > > > ..."  
> > > > },  
> > > > {  
> > > > "\_content\_type" : "application/pdf",  
> > > > "\_name" : "resource/name/of/my.pdf",  
> > > > "content" : "... base64 encoded  
> > > > attachment  
> > > > ..."  
> > > > },  
> > > > {  
> > > > "\_content\_type" : "application/msexcel",  
> > > > "\_name" : "resource/name/of/my.xls",  
> > > > "content" : "... base64 encoded  
> > > > attachment  
> > > > ..."  
> > > > },  
> > > > ]  
> > > > }
> 
> > > > So I suppose the put\_mapping whould be:
> 
> > > > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > > > Content:  
> > > > {  
> > > > "docitem": {  
> > > > "properties" : {  
> > > > "files" : { "type" : "attachment" }  
> > > > }  
> > > > }  
> > > > }
> 
> > > > But when I search the contents of a word document as attachment, I  
> > > > don't get any result, but searching for any other field does.
> 
> > > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 9, 2010, 8:44am UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/6 "2010-10-09T08:44:52Z")

</div>

Seems a bug in PHP (see: [PHP :: Request #49366 :: Make slash escaping optional in json\_encode()](http://bugs.php.net/bug.php?id=49366) )  
however they don't seem to think it's a bug, but jackson won't handle  
it as escaped character though.

On 8 okt, 09:11, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:

> I found and solved "temporary" the problem.
> 
> I did try to check if tika could make something from the Word  
> document, and it did. It could read the document successfully.
> 
> I got the error message (as a part of an MapperParsingException and a  
> backtrace):  
> Caused by: org.elasticsearch.common.jackson.JsonParseException:  
> Failed to decode VALUE\_STRING as base64 (MIME-NO-LINEFEEDS): Illegal  
> character '' (code 0x5c) in base64 content
> 
> Now I use PHP, and php with json\_encode does escape / characters. So  
> in the whole document there were a lot of / Now as a matter of test  
> I did replace all / occurences back to / and then it did index. So  
> there seems to be a bug in, or PHP or in Elasticsearch JSON parser  
> Jackson. I'm going to make a proof of concept, so I post this as bug  
> report.
> 
> Thanks for the help.
> 
> Greetings,
> 
> Michiel
> 
> On Oct 7, 11:19 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> 
> > I did not try to index attachments in array myself but single attachment per  
> > document works fine or me. And your mappings look good to me. If I were you  
> > I would try to check if other words from that document work for search or  
> > not. Then I would try to check what content the Tika was able to get out of  
> > this document (there is Swing console for Tika that can be used for quick  
> > tests, see:[Apache Tika – Getting Started with Apache Tika](http://tika.apache.org/0.7/gettingstarted.html#Using_Tika_as_a_comman)...  
> > ,  
> > just run it and drag and drop that document to it and see the content Tika  
> > is able extract). If the word is there then I would try check elasticsearch  
> > index with Luke.
> 
> > HTH,  
> > Lukas
> 
> > On Thu, Oct 7, 2010 at 5:25 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> > 
> > > Actally plain and simple, because I read default\_filed is by default  
> > > \_all.
> 
> > > URL:[http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)
> 
> > > And Sync4J is a word in the content of the MS Word document.
> 
> > > On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> > > 
> > > > Hi,
> 
> > > > do you think you could share your query? How it looks like?
> 
> > > > Regards,  
> > > > Lukas
> 
> > > > On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > I have items, which I want to index, which have multiple attachments.  
> > > > > On beforehand I don't know how much, so I want to make an array of  
> > > > > attachments.
> 
> > > > > Basic checks:
> > > > > 
> > > > > - Using Elasticsearch 0.11.0
> > > > > - Installed the attachments mapper (on running it says loaded [mapper-  
> > > > > attachments, analysis-icu])
> > > > > - Using the REST API
> 
> > > > > So i have the index myitems, and the type docitem.
> 
> > > > > For indexing I use:
> 
> > > > > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > > > > Content:  
> > > > > {  
> > > > > "id" : 1,  
> > > > > "name": "test",  
> > > > > "description": "test",  
> > > > > "files" : [  
> > > > > {  
> > > > > "\_content\_type" : "application/msword",  
> > > > > "\_name" : "resource/name/of/my.doc",  
> > > > > "content" : "... base64 encoded  
> > > > > attachment  
> > > > > ..."  
> > > > > },  
> > > > > {  
> > > > > "\_content\_type" : "application/pdf",  
> > > > > "\_name" : "resource/name/of/my.pdf",  
> > > > > "content" : "... base64 encoded  
> > > > > attachment  
> > > > > ..."  
> > > > > },  
> > > > > {  
> > > > > "\_content\_type" : "application/msexcel",  
> > > > > "\_name" : "resource/name/of/my.xls",  
> > > > > "content" : "... base64 encoded  
> > > > > attachment  
> > > > > ..."  
> > > > > },  
> > > > > ]  
> > > > > }
> 
> > > > > So I suppose the put\_mapping whould be:
> 
> > > > > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > > > > Content:  
> > > > > {  
> > > > > "docitem": {  
> > > > > "properties" : {  
> > > > > "files" : { "type" : "attachment" }  
> > > > > }  
> > > > > }  
> > > > > }
> 
> > > > > But when I search the contents of a word document as attachment, I  
> > > > > don't get any result, but searching for any other field does.
> 
> > > > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 9, 2010, 8:46am UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/7 "2010-10-09T08:46:50Z")

</div>

However seeing this chart on [JSON.org](http://JSON.org) [http://www.json.org/string.gif](http://www.json.org/string.gif)  
It does say that it's standard. But everything besides this chart says  
not anything about escaping the / char.

On 9 okt, 10:44, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:

> Seems a bug in PHP (see:[PHP :: Request #49366 :: Make slash escaping optional in json\_encode()](http://bugs.php.net/bug.php?id=49366))  
> however they don't seem to think it's a bug, but jackson won't handle  
> it as escaped character though.
> 
> On 8 okt, 09:11, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> 
> > I found and solved "temporary" the problem.
> 
> > I did try to check if tika could make something from the Word  
> > document, and it did. It could read the document successfully.
> 
> > I got the error message (as a part of an MapperParsingException and a  
> > backtrace):  
> > Caused by: org.elasticsearch.common.jackson.JsonParseException:  
> > Failed to decode VALUE\_STRING as base64 (MIME-NO-LINEFEEDS): Illegal  
> > character '' (code 0x5c) in base64 content
> 
> > Now I use PHP, and php with json\_encode does escape / characters. So  
> > in the whole document there were a lot of / Now as a matter of test  
> > I did replace all / occurences back to / and then it did index. So  
> > there seems to be a bug in, or PHP or in Elasticsearch JSON parser  
> > Jackson. I'm going to make a proof of concept, so I post this as bug  
> > report.
> 
> > Thanks for the help.
> 
> > Greetings,
> 
> > Michiel
> 
> > On Oct 7, 11:19 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> 
> > > I did not try to index attachments in array myself but single attachment per  
> > > document works fine or me. And your mappings look good to me. If I were you  
> > > I would try to check if other words from that document work for search or  
> > > not. Then I would try to check what content the Tika was able to get out of  
> > > this document (there is Swing console for Tika that can be used for quick  
> > > tests, see:[Apache Tika – Getting Started with Apache Tika](http://tika.apache.org/0.7/gettingstarted.html#Using_Tika_as_a_comman)...  
> > > ,  
> > > just run it and drag and drop that document to it and see the content Tika  
> > > is able extract). If the word is there then I would try check elasticsearch  
> > > index with Luke.
> 
> > > HTH,  
> > > Lukas
> 
> > > On Thu, Oct 7, 2010 at 5:25 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> > > 
> > > > Actally plain and simple, because I read default\_filed is by default  
> > > > \_all.
> 
> > > > URL:[http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)
> 
> > > > And Sync4J is a word in the content of the MS Word document.
> 
> > > > On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> > > > 
> > > > > Hi,
> 
> > > > > do you think you could share your query? How it looks like?
> 
> > > > > Regards,  
> > > > > Lukas
> 
> > > > > On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > I have items, which I want to index, which have multiple attachments.  
> > > > > > On beforehand I don't know how much, so I want to make an array of  
> > > > > > attachments.
> 
> > > > > > Basic checks:
> > > > > > 
> > > > > > - Using Elasticsearch 0.11.0
> > > > > > - Installed the attachments mapper (on running it says loaded [mapper-  
> > > > > > attachments, analysis-icu])
> > > > > > - Using the REST API
> 
> > > > > > So i have the index myitems, and the type docitem.
> 
> > > > > > For indexing I use:
> 
> > > > > > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > > > > > Content:  
> > > > > > {  
> > > > > > "id" : 1,  
> > > > > > "name": "test",  
> > > > > > "description": "test",  
> > > > > > "files" : [  
> > > > > > {  
> > > > > > "\_content\_type" : "application/msword",  
> > > > > > "\_name" : "resource/name/of/my.doc",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > {  
> > > > > > "\_content\_type" : "application/pdf",  
> > > > > > "\_name" : "resource/name/of/my.pdf",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > {  
> > > > > > "\_content\_type" : "application/msexcel",  
> > > > > > "\_name" : "resource/name/of/my.xls",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > ]  
> > > > > > }
> 
> > > > > > So I suppose the put\_mapping whould be:
> 
> > > > > > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > > > > > Content:  
> > > > > > {  
> > > > > > "docitem": {  
> > > > > > "properties" : {  
> > > > > > "files" : { "type" : "attachment" }  
> > > > > > }  
> > > > > > }  
> > > > > > }
> 
> > > > > > But when I search the contents of a word document as attachment, I  
> > > > > > don't get any result, but searching for any other field does.
> 
> > > > > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Michiel](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Michiel](https://discuss.elastic.co/u/Michiel)\
**Post date:** [October 9, 2010, 9:09am UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/8 "2010-10-09T09:09:08Z")

</div>

Never mind, seems that / is a escapeable character, but some people  
think it doesn't have to be escaped. That it doesn't have to be  
escaped I didn't find yet, so I guess it's not true.

[json.org](http://json.org) as well as jackson source code (  
[http://svn.jackson.codehaus.org/browse/jackson/trunk/src/java/org/codehaus/jackson/impl/ReaderBasedParser.java?r=HEAD#l881](http://svn.jackson.codehaus.org/browse/jackson/trunk/src/java/org/codehaus/jackson/impl/ReaderBasedParser.java?r=HEAD#l881)  
) says / is an escapeable char.

On 9 okt, 10:44, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:

> Seems a bug in PHP (see:[http://bugs.php.net/bug.php?id=49366](http://bugs.php.net/bug.php?id=49366))  
> however they don't seem to think it's a bug, but jackson won't handle  
> it as escaped character though.
> 
> On 8 okt, 09:11, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> 
> > I found and solved "temporary" the problem.
> 
> > I did try to check if tika could make something from the Word  
> > document, and it did. It could read the document successfully.
> 
> > I got the error message (as a part of an MapperParsingException and a  
> > backtrace):  
> > Caused by: org.elasticsearch.common.jackson.JsonParseException:  
> > Failed to decode VALUE\_STRING as base64 (MIME-NO-LINEFEEDS): Illegal  
> > character '' (code 0x5c) in base64 content
> 
> > Now I use PHP, and php with json\_encode does escape / characters. So  
> > in the whole document there were a lot of / Now as a matter of test  
> > I did replace all / occurences back to / and then it did index. So  
> > there seems to be a bug in, or PHP or in Elasticsearch JSON parser  
> > Jackson. I'm going to make a proof of concept, so I post this as bug  
> > report.
> 
> > Thanks for the help.
> 
> > Greetings,
> 
> > Michiel
> 
> > On Oct 7, 11:19 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> 
> > > I did not try to index attachments in array myself but single attachment per  
> > > document works fine or me. And your mappings look good to me. If I were you  
> > > I would try to check if other words from that document work for search or  
> > > not. Then I would try to check what content the Tika was able to get out of  
> > > this document (there is Swing console for Tika that can be used for quick  
> > > tests, see:[Apache Tika – Getting Started with Apache Tika](http://tika.apache.org/0.7/gettingstarted.html#Using_Tika_as_a_comman)...  
> > > ,  
> > > just run it and drag and drop that document to it and see the content Tika  
> > > is able extract). If the word is there then I would try check elasticsearch  
> > > index with Luke.
> 
> > > HTH,  
> > > Lukas
> 
> > > On Thu, Oct 7, 2010 at 5:25 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com) wrote:
> > > 
> > > > Actally plain and simple, because I read default\_filed is by default  
> > > > \_all.
> 
> > > > URL:[http://myserver:9200/myitems/docitem/\_search?q=Sync4J](http://myserver:9200/myitems/docitem/_search?q=Sync4J)
> 
> > > > And Sync4J is a word in the content of the MS Word document.
> 
> > > > On Oct 7, 4:14 pm, Lukáš Vlček [lukas.vl...@gmail.com](mailto:lukas.vl...@gmail.com) wrote:
> > > > 
> > > > > Hi,
> 
> > > > > do you think you could share your query? How it looks like?
> 
> > > > > Regards,  
> > > > > Lukas
> 
> > > > > On Thu, Oct 7, 2010 at 4:04 PM, Michiel [michieleghui...@gmail.com](mailto:michieleghui...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > I have items, which I want to index, which have multiple attachments.  
> > > > > > On beforehand I don't know how much, so I want to make an array of  
> > > > > > attachments.
> 
> > > > > > Basic checks:
> > > > > > 
> > > > > > - Using Elasticsearch 0.11.0
> > > > > > - Installed the attachments mapper (on running it says loaded [mapper-  
> > > > > > attachments, analysis-icu])
> > > > > > - Using the REST API
> 
> > > > > > So i have the index myitems, and the type docitem.
> 
> > > > > > For indexing I use:
> 
> > > > > > URL:[http://myserver:9200/myitems/docitem/1](http://myserver:9200/myitems/docitem/1)  
> > > > > > Content:  
> > > > > > {  
> > > > > > "id" : 1,  
> > > > > > "name": "test",  
> > > > > > "description": "test",  
> > > > > > "files" : [  
> > > > > > {  
> > > > > > "\_content\_type" : "application/msword",  
> > > > > > "\_name" : "resource/name/of/my.doc",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > {  
> > > > > > "\_content\_type" : "application/pdf",  
> > > > > > "\_name" : "resource/name/of/my.pdf",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > {  
> > > > > > "\_content\_type" : "application/msexcel",  
> > > > > > "\_name" : "resource/name/of/my.xls",  
> > > > > > "content" : "... base64 encoded  
> > > > > > attachment  
> > > > > > ..."  
> > > > > > },  
> > > > > > ]  
> > > > > > }
> 
> > > > > > So I suppose the put\_mapping whould be:
> 
> > > > > > URL:[http://myserver:9200/myitems/docitem/\_mapping](http://myserver:9200/myitems/docitem/_mapping)  
> > > > > > Content:  
> > > > > > {  
> > > > > > "docitem": {  
> > > > > > "properties" : {  
> > > > > > "files" : { "type" : "attachment" }  
> > > > > > }  
> > > > > > }  
> > > > > > }
> 
> > > > > > But when I search the contents of a word document as attachment, I  
> > > > > > don't get any result, but searching for any other field does.
> 
> > > > > > What am I doing wrong?

---

<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, 4:18am UTC](https://discuss.elastic.co/t/how-do-i-map-an-array-of-attachments/3419/9 "2017-07-06T04:18:09Z")

</div>


