# Customized document to term scoring

**URL:** <https://discuss.elastic.co/t/customized-document-to-term-scoring/239559>\
**Category:** Elasticsearch\
**Created:** [July 2, 2020, 12:49am UTC](https://discuss.elastic.co/t/customized-document-to-term-scoring/239559 "2020-07-02T00:49:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snakeztc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snakeztc/32/60686_2.png) [@snakeztc](https://discuss.elastic.co/u/snakeztc)\
**Post date:** [July 2, 2020, 12:49am UTC](https://discuss.elastic.co/t/customized-document-to-term-scoring/239559/1 "2020-07-02T00:49:22Z")

</div>

Hi, I am using ES to do research for my learning to rank algorithm. Essentially instead of using TF-IDF or BM25, my scoring function looks like:

`TF(D, t) = model(D, t)`

where `t` is each term in the document. Instead of just counting the frequency of the term, a model will predict the term score. Additionally, I will not use the IDF score.

So this should be compatible with the underlying inverted index. I just need to replace the TF/IDF score with my computed score for each term in the document. Before indexing time, I already compute the term\_score of each term in the doc, so I want to cache these results as the TF term in ES.

Right now I am using rank\_feature as a by\_pass to achieve this. The speed was okay for a small index, but then index \> 50 million, it's much slower than BM25 search on the text. Can you please give instructions on how to modify the term to doc scores directly? Thanks!

---

<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 30, 2020, 12:49am UTC](https://discuss.elastic.co/t/customized-document-to-term-scoring/239559/2 "2020-07-30T00:49:22Z")

</div>

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