# How to know the number of terms in query string matched

**URL:** <https://discuss.elastic.co/t/how-to-know-the-number-of-terms-in-query-string-matched/44643>\
**Category:** Elasticsearch\
**Created:** [March 17, 2016, 3:11am UTC](https://discuss.elastic.co/t/how-to-know-the-number-of-terms-in-query-string-matched/44643 "2016-03-17T03:11:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)\
**Post date:** [March 17, 2016, 3:11am UTC](https://discuss.elastic.co/t/how-to-know-the-number-of-terms-in-query-string-matched/44643/1 "2016-03-17T03:11:20Z")

</div>

Hello everyone.  
The term splited from query string are the same to each other in my querying.  
i just want to know how many term matched to a document.  
i dont need es score. i will caculate the score myself with the count of matched term in script score.

for example: the word "iphone 5s" will splited into two words: "iphone" "5s"  
in my scoring script, i may know the number of matched term are 2, 1 or 0.  
then i will caculate the score like: N \* 30 + other\_score;

can this be possible?

i dont know how to get the number of matched term to one doc.  
i now just think of constant\_score that would implement this.

---

<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, 11:07pm UTC](https://discuss.elastic.co/t/how-to-know-the-number-of-terms-in-query-string-matched/44643/2 "2017-07-05T23:07:41Z")

</div>


