# Indexing pdf documents

**URL:** <https://discuss.elastic.co/t/indexing-pdf-documents/67437>\
**Category:** Elasticsearch\
**Created:** [November 29, 2016, 5:53am UTC](https://discuss.elastic.co/t/indexing-pdf-documents/67437 "2016-11-29T05:53:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![soorajhere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/soorajhere/32/8396_2.png) [@soorajhere](https://discuss.elastic.co/u/soorajhere)\
**Post date:** [November 29, 2016, 5:53am UTC](https://discuss.elastic.co/t/indexing-pdf-documents/67437/1 "2016-11-29T05:53:07Z")

</div>

Hi All,

ES version - 2.1  
Mapper attachments plugin - 3.1

I am trying to index a pdf document in elastic search. I used Nest,[ElasticSearch.net](http://ElasticSearch.net) APIs to index the document. I have installed mapper-attachment plugin. Indexing part is done and when i query the file, i get the below mapping and settings  
{  
"file" : {  
"aliases" : { },  
"mappings" : {  
"document" : {  
"properties" : {  
"file" : {  
"type" : "attachment",  
"fields" : {  
"content" : {  
"type" : "string"  
},  
"author" : {  
"type" : "string"  
},  
"title" : {  
"type" : "string"  
},  
"name" : {  
"type" : "string"  
},  
"date" : {  
"type" : "date",  
"format" : "strict\_date\_optional\_time||epoch\_millis"  
},  
"keywords" : {  
"type" : "string"  
},  
"content\_type" : {  
"type" : "string"  
},  
"content\_length" : {  
"type" : "integer"  
},  
"language" : {  
"type" : "string"  
}  
}  
},  
"id" : {  
"type" : "integer"  
},  
"name" : {  
"type" : "string"  
},  
"title" : {  
"type" : "string",  
"store" : true  
}  
}  
}  
},  
"settings" : {  
"index" : {  
"creation\_date" : "1480322538205",  
"number\_of\_shards" : "5",  
"number\_of\_replicas" : "0",  
"uuid" : "XnDEug4OQ6205Ja\_1\_RSMA",  
"version" : {  
"created" : "2010199"  
}  
}  
},  
"warmers" : { }  
}  
}  
The pdf file is stored as encoded base 64 string and i am able to view it when is query  
localhost:9200/file/\_search?q=sometextinsidepdf  
it returns me the json  
{"took":25,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":0.02117227,"hits":[{"\_index":"file","\_type":"document","\_id":"1","\_score":0.02117227,"\_source":{  
"id": 1,  
"title": "test",  
"file": {  
"\_content": "....base 64 encoded string .....  
}  
}

Actually its returning the encoded string if the search text is present in pdf, but ideally i would like to see the actual text in the pdf returned instead of encoded string with highlighted search text . How to achieve this? Any help is really appreciated.  
Thanks,  
Sooraj.S

---

<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:** [November 29, 2016, 7:28am UTC](https://discuss.elastic.co/t/indexing-pdf-documents/67437/2 "2016-11-29T07:28:33Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Have a look at: [https://www.elastic.co/blog/the-future-of-attachments-for-elasticsearch-and-dotnet](https://www.elastic.co/blog/the-future-of-attachments-for-elasticsearch-and-dotnet)

Note that the original text won't be part of the `_source` document when using `mapper-attachments` plugin. You should use `ingest-attachment` instead as explained in "The future" part of the page I linked to..

---

<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:** [December 27, 2016, 7:29am UTC](https://discuss.elastic.co/t/indexing-pdf-documents/67437/3 "2016-12-27T07:29:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
