Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch score disable IDF

I'm using ES for searching a huge list of human names employing fuzzy search techniques.

TF is applicable for scoring, but IDF is really not required for me in this case. This is really diluting the score. I still want TF and Field Norm to be applied to the score.

How do I disable/suppress IDF for my queries, but keep TF and Field Norm?

I came across the Disable IDF calculation thread, but it did not help me. It also seems like the constant score query would not help me in this case.

like image 386
user1189332 Avatar asked Oct 19 '15 07:10

user1189332


1 Answers

When create index, we can put our own similarity calculate method into the setting parts, if you need only disable IDF and use others as the default setting, you can write just a simple script such as:

"script": {"source": "double tf = Math.sqrt(doc.freq); double idf = 1.0; double norm = 1/Math.sqrt(doc.length); return query.boost * tf * idf * norm;"`}

This is shown here.

like image 126
even Avatar answered Oct 09 '22 22:10

even