Elasticsearch score disable IDF

元气小坏坏 提交于 2019-11-29 07:45:58

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/33208587/elasticsearch-score-disable-idf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!