# Understanding term frequency in ES query

**URL:** <https://discuss.elastic.co/t/understanding-term-frequency-in-es-query/18551>\
**Category:** Elasticsearch\
**Created:** [July 9, 2014, 9:01am UTC](https://discuss.elastic.co/t/understanding-term-frequency-in-es-query/18551 "2014-07-09T09:01:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ifta\_Khirul](https://avatars.discourse-cdn.com/v4/letter/i/f4b2a3/32.png) [@Ifta\_Khirul](https://discuss.elastic.co/u/Ifta_Khirul)\
**Post date:** [July 9, 2014, 9:01am UTC](https://discuss.elastic.co/t/understanding-term-frequency-in-es-query/18551/1 "2014-07-09T09:01:00Z")

</div>

Hi,

Please run the below statements -

curl -X DELETE localhost:9200/autocomplete\_scoring

curl -X PUT localhost:9200/autocomplete\_scoring -d '  
{  
"settings" : {  
"index" : {  
"analysis" : {  
"analyzer" : {  
"translation\_index\_analyzer" : {  
"type" : "custom",  
"tokenizer" : "standard",  
"filter" : "standard, lowercase,title\_edgeNgram"  
},  
"translation\_search\_analyzer" : {  
"type" : "custom",  
"tokenizer" : "standard",  
"filter" : "standard, lowercase"  
}  
},  
"filter" : {  
"title\_edgeNgram" : {  
"type" : "edgeNGram",  
"min\_gram" : 1,  
"max\_gram" : 10  
}  
}  
}  
}  
},  
"mappings": {  
"autoCompleter": {  
"properties": {  
"name": {  
"type": "string",  
"index\_analyzer": "translation\_index\_analyzer",  
"search\_analyzer": "translation\_search\_analyzer"  
},  
"hit": {  
"type": "long"  
},  
"lastAccessedDate": {  
"type": "date"  
}  
}  
}  
}  
}  
'  
curl -X POST "[http://localhost:9200/autocomplete\_scoring/suggestion](http://localhost:9200/autocomplete_scoring/suggestion)" -d '{  
"name" : "abc","hit" : 1, "lastAccessedDate" : "2014-07-08T08:00:00" }'  
curl -X POST "[http://localhost:9200/autocomplete\_scoring/suggestion](http://localhost:9200/autocomplete_scoring/suggestion)" -d '{  
"name" : "abc radio","hit" : 1, "lastAccessedDate" : "2014-07-01T08:00:00"  
}'

curl -XPOST  
"[http://localhost:9200/autocomplete\_scoring/\_search?pretty=True](http://localhost:9200/autocomplete_scoring/_search?pretty=True)" -d'  
{  
"explain": true,  
"query": {  
"function\_score": {  
"query":{  
"match":{  
"name":"abc"  
}  
}  
}  
}  
}'

== \> From the result -  
"\_source":{ "name" : "abc radio","hit" : 1, "lastAccessedDate" :  
"2014-07-01T08:00:00" },  
"\_explanation" : {  
"value" : 0.4451987,  
"description" : "weight(name:abc in 0) [PerFieldSimilarity], result  
of:",  
"details" : [ {  
"value" : 0.4451987,  
"description" : "fieldWeight in 0, product of:",  
"details" : [ {  
"value" : 1.0,  
"description" : "tf(freq=1.0), with freq of:",  
"details" : [ {  
"value" : 1.0,  
"description" : "termFreq=1.0"  
} ]  
}, {  
"value" : 0.71231794,  
"description" : "idf(docFreq=3, maxDocs=3)"  
}, {  
"value" : 0.625,  
"description" : "fieldNorm(doc=0)"  
} ]  
} ]  
}

Here the tf is 1.0 ?  
How.  
In my opinion it should be 1/2=0.5

--  
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/3b7e340d-87ba-49eb-8923-a8800178526d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3b7e340d-87ba-49eb-8923-a8800178526d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:17am UTC](https://discuss.elastic.co/t/understanding-term-frequency-in-es-query/18551/2 "2017-07-06T01:17:04Z")

</div>


