# Percentage of matched terms in Elasticsearch

**URL:** https://discuss.elastic.co/t/percentage-of-matched-terms-in-elasticsearch/56342
**Category:** Elasticsearch
**Created:** [July 25, 2016, 9:45pm UTC](https://discuss.elastic.co/t/percentage-of-matched-terms-in-elasticsearch/56342 "2016-07-25T21:45:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sau.sharma](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sau.sharma](https://discuss.elastic.co/u/sau.sharma)
#### Post date: [July 25, 2016, 9:45pm UTC](https://discuss.elastic.co/t/percentage-of-matched-terms-in-elasticsearch/56342/1 "2016-07-25T21:45:22Z")

</div>

I am using elasticsearch to find similar documents. Below is the query I am using:

```
{
    "query": {
        "more_like_this":{
            "like": {
                "_index": "docs",
                "_type": "pdfs",
                "_id": "pdf_1"
            },
            "min_term_freq": 1,
            "min_doc_freq": 1,
            "max_query_terms: 50,
            "minimum_should_match": "50%"
        }
    }
}

```

I am extracting the text from PDF and storing in my index "docs". Below are the mappings for type "pdfs":

```
{
 "properties": {
        "content":{
            "type": "string",
            "analyzer": "my_analyzer"
        }   
    }   
}

```

In the result sets I am getting similar documents with their scores. Based on what I have read so far it is not possible to calculate percentage similarity based on score so I am not trying to do that. I am trying to figure out if it is possible to know:

"Out of 50 query terms from the source document how many terms are matched in a document? or percentage of terms matched?"  
As you can see that in my query I am specifying minimum\_should\_match as 50% so I am assuming that elasticsearch is filtering the documents somewhere based on the how much percentage of terms are matched in a document. I want to get that percentage. I am fairly new to elasticsearch. So far I have gone through the documentation but couldn't find out how to do it. Any pointer/help is appreciated!

---

<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: [July 5, 2017, 10:33pm UTC](https://discuss.elastic.co/t/percentage-of-matched-terms-in-elasticsearch/56342/2 "2017-07-05T22:33:04Z")

</div>


