# Ingesting HTML file into elasticsearch

**URL:** <https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716>\
**Category:** Elasticsearch\
**Created:** [May 31, 2017, 10:31am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716 "2017-05-31T10:31:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshraddha](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jshraddha](https://discuss.elastic.co/u/jshraddha)\
**Post date:** [May 31, 2017, 10:31am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/1 "2017-05-31T10:31:32Z")

</div>

Hi,

Is there any way to ingest html file into elasticsearch? So far I have seen a command to ingest json files.

I have a file which contains html content different html tags etc. Requirement is to store some content as a String and some tags as it is in the elasticsearch.

---

<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:** [May 31, 2017, 10:59am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/2 "2017-05-31T10:59:00Z")

</div>

You can use [html trip char filter](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/analysis-htmlstrip-charfilter.html).  
You can also look at ingest-attachment plugin.

---

<div class="post-metadata">

**Author:** ![jshraddha](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jshraddha](https://discuss.elastic.co/u/jshraddha)\
**Post date:** [May 31, 2017, 11:33am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/3 "2017-05-31T11:33:00Z")

</div>

Thanks @dadoonet  
I saw the plugin document and installed it but I could not understand how the file should be provided in that API

In document it is shown as  
PUT my\_index/my\_type/my\_id?pipeline=attachment  
{  
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="  
}

Ho can I specify my file? Do I need to specify file path somewhere?

---

<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:** [May 31, 2017, 12:09pm UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/4 "2017-05-31T12:09:25Z")

</div>

You need to encode the content of the file in BASE64 and add this to The json document.

You can also look at FSCrawler project if you wish. Might help

---

<div class="post-metadata">

**Author:** ![jshraddha](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jshraddha](https://discuss.elastic.co/u/jshraddha)\
**Post date:** [June 1, 2017, 8:34am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/5 "2017-06-01T08:34:38Z")

</div>

Thanks @dadoonet : Encoding with BASE64 worked. It stores the actual text in the index. Is there any way if I want to store it with actual HTML tags. I wanted to store few tags like table tag as it is in the index whereas rest of the data can be stored by eliminating html tags.

---

<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 1, 2017, 9:00am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/6 "2017-06-01T09:00:34Z")

</div>

Then you need to send as well the HTML content within another field. Which can be not indexed

---

<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:** [June 29, 2017, 9:00am UTC](https://discuss.elastic.co/t/ingesting-html-file-into-elasticsearch/87716/7 "2017-06-29T09:00:56Z")

</div>

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