# Turn off TF/IDF for searching human names

**URL:** https://discuss.elastic.co/t/turn-off-tf-idf-for-searching-human-names/234609
**Category:** Elasticsearch
**Created:** [May 27, 2020, 7:30pm UTC](https://discuss.elastic.co/t/turn-off-tf-idf-for-searching-human-names/234609 "2020-05-27T19:30:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gideongrossman](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gideongrossman](https://discuss.elastic.co/u/gideongrossman)
#### Post date: [May 27, 2020, 7:30pm UTC](https://discuss.elastic.co/t/turn-off-tf-idf-for-searching-human-names/234609/1 "2020-05-27T19:30:10Z")

</div>

I have a query that works fairly well for scoring matches in human name and address fields. However, some documents get an undesirably high score. For example, when I search for the string "CHR",  
**DONALD MCCLURE** at the address **#41 IROQUOIS/CHICKASAW**  
gets a higher score than **CHRIS LE** at the address **2021 FARMINGTON LAKES DR APT**  
I believe the issue is TF/IDF --\> Elasticsearch may be assigning the less relevant document a higher score because the ngram CH is uncommon in the address field.

I am using both ngram and edge\_ngram analyzers. I include reproducible code and more details in this stack overflow post... https://stackoverflow.com/questions/62032693/weird-relevance-ranking-in-elasticsearch

Cheers!

---

<div class="post-metadata">

### Author: ![gideongrossman](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gideongrossman](https://discuss.elastic.co/u/gideongrossman)
#### Post date: [May 28, 2020, 8:45pm UTC](https://discuss.elastic.co/t/turn-off-tf-idf-for-searching-human-names/234609/2 "2020-05-28T20:45:22Z")

</div>

I was able to turn off the TF/IDF by overriding the default similarity module like this in my index settings...

```
 {
    "index": {
    	"similarity": {
    		"default": {
    			"type": "scripted",
    			"script": {
    				"source": "return doc.freq > 0 ? 1 : 0;"
    			}
    		}
    	},.... 
}
```

---

<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: [June 25, 2020, 8:45pm UTC](https://discuss.elastic.co/t/turn-off-tf-idf-for-searching-human-names/234609/3 "2020-06-25T20:45:37Z")

</div>

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