# Which is the best way of disabling IDF?

**URL:** <https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647>\
**Category:** Elasticsearch\
**Created:** [October 10, 2016, 3:55pm UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647 "2016-10-10T15:55:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drount](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drount/32/10022_2.png) [@drount](https://discuss.elastic.co/u/drount)\
**Post date:** [October 10, 2016, 3:55pm UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/1 "2016-10-10T15:55:14Z")

</div>

Hello,

in Elasticsearch documentation there are references on how to disable TF-IDF. However, I need to just disable IDF (while keeping TF, queryNorm, ...)

Which would be the best way of archiving that?

Thank you.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 11, 2016, 3:09am UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/2 "2016-10-11T03:09:33Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-function-score-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-function-score-query.html) might be an option.

---

<div class="post-metadata">

**Author:** ![drount](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drount/32/10022_2.png) [@drount](https://discuss.elastic.co/u/drount)\
**Post date:** [October 11, 2016, 7:13am UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/3 "2016-10-11T07:13:38Z")

</div>

Thanks for your answer. I indeed explored this option before. However, I do not see a clear way of just "disabling" IDF.

Any idea?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [October 11, 2016, 10:36am UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/4 "2016-10-11T10:36:02Z")

</div>

Hi,

AFAIK there is no simple option that just turns of IDF, since customizing the similarity calculation is very much an expert thing. If you don't want to go the function score query route, I think the only option left is to write your own lucene similarity and use it as a plug in. I found a blog and a project describing this here, but didn't try this myself, but maybe this is a starting point for exploration: [http://stefansavev.com/blog/custom-similarity-for-elasticsearch/](http://stefansavev.com/blog/custom-similarity-for-elasticsearch/)

---

<div class="post-metadata">

**Author:** ![drount](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drount/32/10022_2.png) [@drount](https://discuss.elastic.co/u/drount)\
**Post date:** [October 12, 2016, 7:55am UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/5 "2016-10-12T07:55:00Z")

</div>

Thanks for your reply.

I'll go for the custom similarity.

---

<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 5, 2017, 10:13pm UTC](https://discuss.elastic.co/t/which-is-the-best-way-of-disabling-idf/62647/6 "2017-07-05T22:13:08Z")

</div>


