# Change score function to return number of matches of search term in the documents

**URL:** https://discuss.elastic.co/t/change-score-function-to-return-number-of-matches-of-search-term-in-the-documents/175759
**Category:** Elasticsearch
**Created:** [April 8, 2019, 5:51am UTC](https://discuss.elastic.co/t/change-score-function-to-return-number-of-matches-of-search-term-in-the-documents/175759 "2019-04-08T05:51:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Harsha\_Yerasi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsha_yerasi/32/42985_2.png) [@Harsha\_Yerasi](https://discuss.elastic.co/u/Harsha_Yerasi)
#### Post date: [April 8, 2019, 5:51am UTC](https://discuss.elastic.co/t/change-score-function-to-return-number-of-matches-of-search-term-in-the-documents/175759/1 "2019-04-08T05:51:25Z")

</div>

Hi,

I have gone through the default scoring function that elasticsearch uses.

```
score(q,d) = 
        queryNorm(q) 
      * coord(q,d) 
      * SUM ( 
            tf(t in d), 
            idf(t)², 
            t.getBoost(), 
            norm(t,d) 
                    ) (t in q)

```

score(q,d) is the relevance score of document d for query q.  
queryNorm(q) is the query normalization factor.  
coord(q,d) is the coordination factor.  
The sum of the weights for each term t in the query q for document d.  
tf(t in d) is the term frequency for term t in document d.  
idf(t) is the inverse document frequency for term t.  
t.getBoost() is the boost that has been applied to the query.  
norm(t,d) is the field-length norm, combined with the index-time field-level boost, if any.

I want to use Coordination factor alone as my score.

Any help here is highly appreciated.

Thanks,  
HarshaYerasi.

---

<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: [May 6, 2019, 5:51am UTC](https://discuss.elastic.co/t/change-score-function-to-return-number-of-matches-of-search-term-in-the-documents/175759/2 "2019-05-06T05:51:36Z")

</div>

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