# Finding relevant documents

**URL:** https://discuss.elastic.co/t/finding-relevant-documents/97083
**Category:** Elasticsearch
**Created:** [August 15, 2017, 9:32am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083 "2017-08-15T09:32:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![NikhilJoshi2](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NikhilJoshi2](https://discuss.elastic.co/u/NikhilJoshi2)
#### Post date: [August 15, 2017, 9:32am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/1 "2017-08-15T09:32:45Z")

</div>

Hello, I was going though "more\_like\_this" clause but not able to find relevant documents. I have below data in ElasticSearch and "description" field is having huge non-indexed data of size \>1 million bytes. Like below I have ten thousand documents. How can I figure out a set of documents which are matching at least 80% with each other:

```
{
	"_index": "school",
	"_type": "book",
	"_id": "1",
	"_source": {
	  "title": "How to drive safely",
	  "description": "The book is written to help readers about giving driving safety guidelines. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. LONG...."
	}
}

```

At the end, I am looking for list of document ID's which have at least 80% matching contents. Possible expected result containing matching document IDs (any format is fine):  
`[[1,30, 500, 8000], [2, 40, 199], .... ]`

Do I need to write batch and compare each document with all others and build output set?

Please guide.

---

<div class="post-metadata">

### Author: ![NikhilJoshi2](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NikhilJoshi2](https://discuss.elastic.co/u/NikhilJoshi2)
#### Post date: [August 16, 2017, 8:27am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/2 "2017-08-16T08:27:47Z")

</div>

Can someone please help.

++ @dadoonet @warkolm

---

<div class="post-metadata">

### Author: ![NikhilJoshi2](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NikhilJoshi2](https://discuss.elastic.co/u/NikhilJoshi2)
#### Post date: [August 18, 2017, 7:57am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/3 "2017-08-18T07:57:53Z")

</div>

**Anyone** would like to help? 😥

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [August 18, 2017, 8:34am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/4 "2017-08-18T08:34:08Z")

</div>

> [@NikhilJoshi2](#):
>
> At the end, I am looking for list of document ID’s which have at least 80% matching contents. Possible expected result containing matching document IDs (any format is fine):

If you run a query with only the title it'll not be relevant. If you run a query with the description you'll have to truncate it and you'll have some strange results due to small words (the, is , to , about, etc...) I think that you should extract words from the description, then keep relevant words (len \> 5 for exemple) and finaly run a query with 80% of minimun should match. ([minimum\_should\_match parameter | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html)) Using a dictionnary could be interesting too.

---

<div class="post-metadata">

### Author: ![NikhilJoshi2](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NikhilJoshi2](https://discuss.elastic.co/u/NikhilJoshi2)
#### Post date: [August 18, 2017, 8:55am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/5 "2017-08-18T08:55:16Z")

</div>

Hello @xavierfacq, thanks a lot for the response. So if I fire below query, will it only compare " **description**" fields of all available books against " **description**" field of document **id 50** and show documents matching **"80%"** of " **description**" field?

```
GET school/book/_search
{
  "query": {
    "more_like_this": {
      "fields": [
        "description"
      ],
      "like": [
        {
          "_index": "school",
          "_type": "book",
          "_id": "50"
        }
      ],
      "minimum_should_match": "80%"
    }
  }
}
```

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [August 18, 2017, 9:02am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/6 "2017-08-18T09:02:34Z")

</div>

I would say yes but I'm not very familiar with the more\_like\_this query...

What I suggested was to get the document (\_id 50) extract relevant words, and then run a match query with the "minimum\_should\_match": "80%".

---

<div class="post-metadata">

### Author: ![NikhilJoshi2](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NikhilJoshi2](https://discuss.elastic.co/u/NikhilJoshi2)
#### Post date: [August 18, 2017, 9:10am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/7 "2017-08-18T09:10:10Z")

</div>

This is certainly doable, but volume is an issue. I need to do it for all 10,000 documents. And keep on doing this for newly added documents or remove reference of purged documents. Using " **stop\_words**" enables query to ignore specific words during search, but not sure if there is anything better?

Does ElasticSearch offers something **out of the box**?

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [August 18, 2017, 9:20am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/8 "2017-08-18T09:20:44Z")

</div>

> [@NikhilJoshi2](#):
>
> Does Elasticsearch offers something out of the box?

I don't know ☹

---

<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: [September 15, 2017, 9:20am UTC](https://discuss.elastic.co/t/finding-relevant-documents/97083/9 "2017-09-15T09:20:58Z")

</div>

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