1. Use function df (Field,keyword) and IDF (Field,keyword).
http://118.85.207.11:11100/solr/mobile/select?q={!func}product%28idf%28title,%e9%97%ae%e9%a2%98% 29,tf%28title,%e9%97%ae%e9%a2%98%29%29&fl=title,score,product%28idf%28title,%e9%97%ae%e9%a2%98%29,tf% 28title,%e9%97%ae%e9%a2%98%29%29&wt=json
Where the value of TF*IDF is the same as the value of score.
It can also be implemented in SOLRJ:
Public classapptest {@Test Public voidTest1 ()throwssolrserverexception{httpsolrserver solrserver=NewHttpsolrserver ("Http://118.85.207.11:11100/solr/mobile"); String keyword= "Problem"; Solrquery Solrquery=NewSolrquery ("Q={!func}product" (IDF (title, $keyword), TF (title, $keyword) keyword= "+keyword+") "); Solrquery.addfield ("Title,score"); Solrquery.setrows (1); Queryresponse Queryresponse=solrserver.query (solrquery); System.out.println (Queryresponse.tostring ()); }}
Results:
{responseheader={status=0,qtime=16,params={fl=title,score,q=q={!func}product (IDF (title, $keyword), TF (title,$ Keyword) keyword= problem), wt=javabin,version=2,rows=1}},response={numfound=3,start=0,maxscore=0.078723446,docs=[ SOLRDOCUMENT{TITLE=4G Hot Issues-Package, score=0.078723446}]},highlighting={10001={title=[4g hot <font color= ' #FF0000 ' > Questions </font> Answers-Package],content=[4g hot <font color= ' #FF0000 ' > Questions </font> FAQ-package]}}}
Use SOLR's function query and get the TF*IDF value