我正在尝试编写此查询;

localhost/solr/tvrh/?q=queryString&version=2.2&indent=on&tv.tf_idf=true


使用solrj。

我想在下面获取tf和idf值;

<lst name="doc-40797">
<str name="uniqueKey">test20508</str>
<lst name="content">
<lst name="98">
<double name="tf-idf">0.002304147465437788</double>
</lst>
<lst name="apaan">
<double name="tf-idf">0.16666666666666666</double>
</lst>
<lst name="aryadea">
<        double name="tf-idf">1.0</double>
</lst>
<lst name="chelsea">
<double name="tf-idf">0.005208333333333333</double>
</lst>
<lst name="gua">
<double name="tf-idf">0.05555555555555555</double>
</lst>
<lst name="osa">
<double name="tf-idf">0.004662004662004662</double>
</lst>
<lst name="pegangı">
<double name="tf-idf">0.5</double>
</lst>
<lst name="rt">
<double name="tf-idf">1.4009526478005044E-4</double>
</lst>
<lst name="vs">
<double name="tf-idf">0.0030581039755351682</double>
</lst>
</lst>
</lst>
<str name="uniqueKeyFieldName">id</str>
<lst name="doc-40746">
<str name="uniqueKey">test20457</str>
<lst name="content">
<lst name="075">
<double name="tf-idf">0.027777777777777776</double>
</lst>
<lst name="9">
<double name="tf-idf">9.76657876745776E-5</double>
</lst>
<lst name="atlético">
<double name="tf-idf">0.045454545454545456</double>
</lst>
<lst name="co">
<double name="tf-idf">1.1130899376669635E-4</double>
</lst>
<lst name="http">
<double name="tf-idf">1.034233116144379E-4</double>
</lst>
<lst name="jorna">
<double name="tf-idf">0.25</double>
</lst>
<lst name="lh">
<double name="tf-idf">0.07142857142857142</double>
</lst>
<lst name="ngn">
<double name="tf-idf">0.5</double>
</lst>
<lst name="osa">
<double name="tf-idf">0.004662004662004662</double>
</lst>
<lst name="puntuaciones">
<double name="tf-idf">1.0</double>
</lst>
<lst name="t">
<double name="tf-idf">7.038783698176955E-5</double>
</lst>
<lst name="vavelco">
<double name="tf-idf">0.2</double>
</lst>
<lst name="vía">
<double name="tf-idf">0.03125</double>
</lst>
</lst>
</lst>
<str name="uniqueKeyFieldName">id</str>


到现在;

        SolrQuery query = new SolrQuery(queryString);
        query.setQueryType("/tvrh");
        query.setParam("tv.tf_idf", true);
        QueryResponse response = server.query(query);


我已经编写了查询,我想我将需要QueryResponse对象,我认为这是事实。但是我不知道接下来使用solrj获得那些tf-idf值的方法是什么。

谢谢

最佳答案

您几乎在那里:

QueryResponse qr = server.query(query);
TermsResponse resp = qr.getTermsResponse();


TermsResponse对象包含术语向量分量输出。不知道它是否包含所有信息。

08-16 05:16