How do I get the tf and idf score from a Solr query?

不羁岁月 提交于 2020-01-15 06:30:06

问题


Following Solr documentations (https://cwiki.apache.org/confluence/display/solr/Function+Queries and others) I should just put idf(fieldname, 'term') as I do with termfreq(fieldname, 'term') in the field list. However, whenever I try this I get an exception as:

org.apache.solr.client.solrj.SolrServerException: No live SolrServers available to handle this request

By looking at the logs I could find:

null:java.lang.UnsupportedOperationException: requires a TFIDFSimilarity (such as ClassicSimilarity)

And I have no idea what those are. Also when I use debugQuery=on it shows me, along with a lot of other things, the idf value for the document as:

4.406719 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5))

What should I do to fix these errors or to get desired tf and idf value for a term?


回答1:


You need to add following line in your "managed-schema" where similarity tag is commented at the end of the schema

<similarity class="solr.ClassicSimilarityFactory"/>



回答2:


I had run into the same issue and found this chrome extension -

https://chrome.google.com/webstore/detail/solr-query-debugger/gmpkeiamnmccifccnbfljffkcnacmmdl?hl=en

It is really helpful in breaking down "explain" and will display the value of idf for you.



来源:https://stackoverflow.com/questions/43692041/how-do-i-get-the-tf-and-idf-score-from-a-solr-query

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