# How to implement whymatch in elastic search

**URL:** https://discuss.elastic.co/t/how-to-implement-whymatch-in-elastic-search/15657
**Category:** Elasticsearch
**Created:** [February 7, 2014, 6:24am UTC](https://discuss.elastic.co/t/how-to-implement-whymatch-in-elastic-search/15657 "2014-02-07T06:24:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Navneet\_Mathpal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navneet_mathpal/32/3677_2.png) [@Navneet\_Mathpal](https://discuss.elastic.co/u/Navneet_Mathpal)
#### Post date: [February 7, 2014, 6:24am UTC](https://discuss.elastic.co/t/how-to-implement-whymatch-in-elastic-search/15657/1 "2014-02-07T06:24:50Z")

</div>

Hi,

how to implement whymatch in elastic search, Is there is any procedure to  
calculate the term frequency for particular word.

for example :

search query- google founder

results are :- g123,g456,g789 (these are the docId corresponding to  
results )

In g123 google is in title field 3 times.

so how to calculate them.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0e2d9c72-ccbb-45cc-ab65-4899905487e3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0e2d9c72-ccbb-45cc-ab65-4899905487e3%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Britta\_Weber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/britta_weber/32/1113_2.png) [@Britta\_Weber](https://discuss.elastic.co/u/Britta_Weber)
#### Post date: [February 7, 2014, 1:09pm UTC](https://discuss.elastic.co/t/how-to-implement-whymatch-in-elastic-search/15657/2 "2014-02-07T13:09:21Z")

</div>

Hi,

you can use a script to find out term frequencies and more of a  
particular word in a field. This feature is available since 0.90.10.  
Check it out here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

You can use this either inside a function\_score [1] query if you want  
to use the tf to influence the score, or you can define a script field  
[2] if you only want to have the information returned.

If you want to write a native script, some examples how to use that  
from java are in this repository:

> **[GitHub - imotov/elasticsearch-native-script-example: Example of Now...](https://github.com/imotov/elasticsearch-native-script-example)**
>
> Example of Now Deprecated Native Script Plugin for Elasticsearch - GitHub - imotov/elasticsearch-native-script-example: Example of Now Deprecated Native Script Plugin for Elasticsearch

Hope that helps,  
Britta

[1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)  
[2] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html)

On Fri, Feb 7, 2014 at 7:24 AM, Navneet Mathpal  
[navneetmathpal93@gmail.com](mailto:navneetmathpal93@gmail.com) wrote:

> Hi,
> 
> how to implement whymatch in Elasticsearch, Is there is any procedure to  
> calculate the term frequency for particular word.
> 
> for example :
> 
> search query- google founder
> 
> results are :- g123,g456,g789 (these are the docId corresponding to results  
> )
> 
> In g123 google is in title field 3 times.
> 
> so how to calculate them.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/0e2d9c72-ccbb-45cc-ab65-4899905487e3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0e2d9c72-ccbb-45cc-ab65-4899905487e3%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALhJbBhi%3Dvjogo6UCERiLLng5pKP6z%2BsL\_zjgfceaGx%3D9ZTk\_A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALhJbBhi%3Dvjogo6UCERiLLng5pKP6z%2BsL_zjgfceaGx%3D9ZTk_A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:51am UTC](https://discuss.elastic.co/t/how-to-implement-whymatch-in-elastic-search/15657/3 "2017-07-06T01:51:46Z")

</div>


