# Trouble with tutorial: Attachment Type in Action

**URL:** <https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011>\
**Category:** Elasticsearch\
**Created:** [June 7, 2012, 7:38pm UTC](https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011 "2012-06-07T19:38:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meltemi](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@Meltemi](https://discuss.elastic.co/u/Meltemi)\
**Post date:** [June 7, 2012, 7:38pm UTC](https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011/1 "2012-06-07T19:38:05Z")

</div>

Trying to successfully index a PDF with elasticsearch and failing.

Followed instructions in for tutorial: Attachment Type in Action[http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html](http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html)  
:

Installed the _Attachment Type_ plugin and got response: "Installed  
mapper-attachments".

All's peachy until

curl -X POST "localhost:9200/test/attachment/" -d @json.file

in the shell script when the shell hangs.

Also tried using the gist [https://gist.github.com/1075067](https://gist.github.com/1075067) and it hangs on  
exact same command.

"json.file" was successfully created (both times). it's Base64 gibberish.  
So not sure if it's valid?!? But assuming so I tried to POST directly from  
command line:

$ curl -X POST "localhost:9200/test/attachment/" -d json.file  
{"error":"ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108,  
101]]","status":400}

log shows:

[2012-06-07 12:32:16,742][DEBUG][action.index] [Bailey, Paul]  
[test][0], node[AHLHFKBWSsuPnTIRVhNcuw], [P], s[STARTED]: Failed to execute  
[index {[test][attachment][DauMB-vtTIaYGyKD4P8Y\_w], source[json.file]}]  
org.elasticsearch.ElasticSearchParseException: Failed to derive xcontent  
from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]  
at  
org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:147)  
at  
org.elasticsearch.common.xcontent.XContentHelper.createParser(XContentHelper.java:50)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:451)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:437)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:290)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:680)

which is beyond my pay-grade. Can anyone help me figure out how/where I  
failed?

preesh!

---

<div class="post-metadata">

**Author:** ![James\_Cook\_3](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@James\_Cook\_3](https://discuss.elastic.co/u/James_Cook_3)\
**Post date:** [June 7, 2012, 8:49pm UTC](https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011/2 "2012-06-07T20:49:55Z")

</div>

I'm not sure how to correct the problem you are experiencing, but:

$ curl -X POST "localhost:9200/test/attachment/" -d json.file  
{"error":"ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108,  
101]]","status":400}

Is just telling you that ES, has received 'json.file' as some type of  
incoming content that it does not understand how to parse. The contents of  
'json.file' were not transmitted.

-- jim

On Thursday, June 7, 2012 3:38:05 PM UTC-4, Meltemi wrote:

> Trying to successfully index a PDF with elasticsearch and failing.
> 
> Followed instructions in for tutorial: Attachment Type in Action[http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html](http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html)  
> :
> 
> Installed the _Attachment Type_ plugin and got response: "Installed  
> mapper-attachments".
> 
> All's peachy until
> 
> curl -X POST "localhost:9200/test/attachment/" -d @json.file
> 
> in the shell script when the shell hangs.
> 
> Also tried using the gist [https://gist.github.com/1075067](https://gist.github.com/1075067) and it hangs  
> on exact same command.
> 
> "json.file" was successfully created (both times). it's Base64 gibberish.  
> So not sure if it's valid?!? But assuming so I tried to POST directly from  
> command line:
> 
> $ curl -X POST "localhost:9200/test/attachment/" -d json.file  
> {"error":"ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108,  
> 101]]","status":400}
> 
> log shows:
> 
> [2012-06-07 12:32:16,742][DEBUG][action.index] [Bailey, Paul]  
> [test][0], node[AHLHFKBWSsuPnTIRVhNcuw], [P], s[STARTED]: Failed to execute  
> [index {[test][attachment][DauMB-vtTIaYGyKD4P8Y\_w], source[json.file]}]  
> org.elasticsearch.ElasticSearchParseException: Failed to derive xcontent  
> from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]  
> at  
> org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:147)  
> at  
> org.elasticsearch.common.xcontent.XContentHelper.createParser(XContentHelper.java:50)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:451)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:437)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:290)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:680)
> 
> which is beyond my pay-grade. Can anyone help me figure out how/where I  
> failed?
> 
> preesh!

---

<div class="post-metadata">

**Author:** ![Meltemi](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@Meltemi](https://discuss.elastic.co/u/Meltemi)\
**Post date:** [June 7, 2012, 9:10pm UTC](https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011/3 "2012-06-07T21:10:10Z")

</div>

Well, the json.file was encoded (as per the tutorial) with:

coded=`cat fn6742.pdf | perl -MMIME::Base64 -ne 'print encode_base64($_)'`  
json="{"file":"${coded}"}"  
echo "$json" \> json.file

and there were no errors until the next line (where it hangs):

curl -X POST "${host}/test/attachment/" -d @json.file

The tutorial wants the file to be converted into Base64. Is this always the  
case? If so, is there another way to do so?

I'd really like to get PDFs (even just one) indexed with elasticsearch so I  
can start playing with it.

Thanks for your help!

On Thursday, June 7, 2012 1:49:55 PM UTC-7, James Cook wrote:

> I'm not sure how to correct the problem you are experiencing, but:
> 
> $ curl -X POST "localhost:9200/test/attachment/" -d json.file  
> {"error":"ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108,  
> 101]]","status":400}
> 
> Is just telling you that ES, has received 'json.file' as some type of  
> incoming content that it does not understand how to parse. The contents of  
> 'json.file' were not transmitted.
> 
> -- jim
> 
> On Thursday, June 7, 2012 3:38:05 PM UTC-4, Meltemi wrote:
> 
> > Trying to successfully index a PDF with elasticsearch and failing.
> > 
> > Followed instructions in for tutorial: Attachment Type in Action[http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html](http://www.elasticsearch.org/tutorials/2011/07/18/attachment-type-in-action.html)  
> > :
> > 
> > Installed the _Attachment Type_ plugin and got response: "Installed  
> > mapper-attachments".
> > 
> > All's peachy until
> > 
> > curl -X POST "localhost:9200/test/attachment/" -d @json.file
> > 
> > in the shell script when the shell hangs.
> > 
> > Also tried using the gist [https://gist.github.com/1075067](https://gist.github.com/1075067) and it hangs  
> > on exact same command.
> > 
> > "json.file" was successfully created (both times). it's Base64 gibberish.  
> > So not sure if it's valid?!? But assuming so I tried to POST directly from  
> > command line:
> > 
> > $ curl -X POST "localhost:9200/test/attachment/" -d json.file  
> > {"error":"ElasticSearchParseException[Failed to derive xcontent from  
> > (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108,  
> > 101]]","status":400}
> > 
> > log shows:
> > 
> > [2012-06-07 12:32:16,742][DEBUG][action.index] [Bailey,  
> > Paul] [test][0], node[AHLHFKBWSsuPnTIRVhNcuw], [P], s[STARTED]: Failed to  
> > execute [index {[test][attachment][DauMB-vtTIaYGyKD4P8Y\_w],  
> > source[json.file]}]  
> > org.elasticsearch.ElasticSearchParseException: Failed to derive xcontent  
> > from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]  
> > at  
> > org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:147)  
> > at  
> > org.elasticsearch.common.xcontent.XContentHelper.createParser(XContentHelper.java:50)  
> > at  
> > org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:451)  
> > at  
> > org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:437)  
> > at  
> > org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:290)  
> > at  
> > org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)  
> > at  
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
> > at  
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> > at java.lang.Thread.run(Thread.java:680)
> > 
> > which is beyond my pay-grade. Can anyone help me figure out how/where I  
> > failed?
> > 
> > preesh!

---

<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:25am UTC](https://discuss.elastic.co/t/trouble-with-tutorial-attachment-type-in-action/8011/4 "2017-07-06T03:25:17Z")

</div>


