How to get a list of words in a doc by TF/IDF scores How to get a list of words in a doc by TF/IDF scores elasticsearch elasticsearch

How to get a list of words in a doc by TF/IDF scores


You could retrieve the list of all terms in the document and then use explain while searching for all words in the document.

Ex:If the document contains foo and bar, query would be:

/MY_INDEX/MY_TYPE/_search?q=_id:MY_ID foo bar&explain=true&size=1

In the score explanation you will see the idf score and the tf score for each word.