# Sample code to find similar HTML Documents

**URL:** <https://discuss.elastic.co/t/sample-code-to-find-similar-html-documents/345140>\
**Category:** Elasticsearch\
**Created:** [October 16, 2023, 9:53pm UTC](https://discuss.elastic.co/t/sample-code-to-find-similar-html-documents/345140 "2023-10-16T21:53:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ata\_Zangene](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ata_zangene/32/124156_2.png) [@Ata\_Zangene](https://discuss.elastic.co/u/Ata_Zangene)\
**Post date:** [October 16, 2023, 9:53pm UTC](https://discuss.elastic.co/t/sample-code-to-find-similar-html-documents/345140/1 "2023-10-16T21:53:23Z")

</div>

Hi, I want to index around 10 million of web pages HTML code in elasticsearch,  
now, I want to give the HTML content as a search query and get the most similar documents related to the search query ( which is an HTML )

so If I put the HTML page that already indexed, it should return the exact same documents, otherwise, it should send nearest one.

how can I do this with elasticsearch? is there any sample code for this?

Best Regards

---

<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:** [October 17, 2023, 9:55am UTC](https://discuss.elastic.co/t/sample-code-to-find-similar-html-documents/345140/2 "2023-10-17T09:55:12Z")

</div>

Welcome!

> [@Ata\_Zangene](#):
>
> so If I put the HTML page that already indexed, it should return the exact same documents, otherwise, it should send nearest one.

That's normally the default behavior. It's all about relevancy.

> how can I do this with elasticsearch? is there any sample code for this?

Something like:

```auto
GET /indexname/_search
{
  "query": {
    "match": {
      "content": "YOUR HTML CONTENT HERE"
    }
  }
}

```

That might give you good results out of the box.

---

<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:** [November 14, 2023, 9:55am UTC](https://discuss.elastic.co/t/sample-code-to-find-similar-html-documents/345140/3 "2023-11-14T09:55:30Z")

</div>

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