Use SOLR's function query and get the TF*IDF value

Source: Internet
Author: User
Tags solr idf

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.