简体   繁体   中英

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

I have an ElasticSearch index. Given a document ID in the index, I want to get a list of words in the doc by TF-IDF scores. Is that possible to write an ES query to get the list?

Thanks in advance.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM