# Create single index using multiple html files

**URL:** <https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551>\
**Category:** Elasticsearch\
**Created:** [May 12, 2017, 11:22am UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551 "2017-05-12T11:22:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitkumar](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@amitkumar](https://discuss.elastic.co/u/amitkumar)\
**Post date:** [May 12, 2017, 11:22am UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551/1 "2017-05-12T11:22:36Z")

</div>

Hi,  
I am very new user for elasticsearch.I want to create single index by using multiple html files how could i do this.please let me know proper way to do it in elasticsearch.  
I have upload an image which type of searching i want to implement using html files and its content.

 ![](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9fd928df4ad630611ec69da943d830f27210e5c3.PNG)

---

<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 12, 2017, 12:53pm UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551/2 "2017-05-12T12:53:07Z")

</div>

You need to crawl the webpages and for each one create a json document which contains page URL and content.

Then look at the analysis documentation in the guide. HTML strip might help you. [https://www.elastic.co/guide/en/elasticsearch/reference/5.4/analysis-htmlstrip-charfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/analysis-htmlstrip-charfilter.html)

---

<div class="post-metadata">

**Author:** ![amitkumar](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@amitkumar](https://discuss.elastic.co/u/amitkumar)\
**Post date:** [May 17, 2017, 8:12am UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551/3 "2017-05-17T08:12:47Z")

</div>

Thanks for answering.I tried it, but i am not able to achieve my goal using this.

My requirement is:

First I need to create an single index in elasticsearch for all html files.After that I want to get all html files and its content on web page as i will do searching.

ex. if i will search for ''content1'' if it is in file\_1 and file\_2 in index\_1 so both file should show on web page and its content.like this:  
search bar: content1  
file\_1 as link  
its content  
file\_2 as link  
its content

[1.In](http://1.In) attachment what I have shown you, is an [example.it](http://example.it) is showing multiple links that should be nothing but my html files and below down should be my content.  
[2.As](http://2.As) I will click on html file link so it should show content of clicked html file.  
3.how i will show only 2 or 3 lines of content.

Note: all this data which i want to show come from 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 23, 2017, 1:46pm UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551/4 "2017-05-23T13:46:48Z")

</div>

Not sure I'm following. But in short, create one document per html page like this:

```auto
{
  "content": "BASE64 content here",
  "url": "http://link.to.your.page/"
}

```

Then when you will get results, you will see something like:

```auto
{
  "attachment": {
      "content_type": "text/html",
      "content": "Lorem ipsum dolor sit amet",
      "content_length": 28
  },
  "url": "http://link.to.your.page/"
}

```

Just use that result to display some content of your document. Even better, use highlighting feature to only extract lines of text matching your query.  
And use the `url` field to display a link to your document.

---

<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 20, 2017, 1:46pm UTC](https://discuss.elastic.co/t/create-single-index-using-multiple-html-files/85551/5 "2017-06-20T13:46:54Z")

</div>

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