【发布时间】:2016-12-07 22:06:10
【问题描述】:
如果我在 SOLR 索引中搜索一个单词,我会得到包含该单词的文档的文档计数,但如果该单词在文档中包含的次数更多,则每个文档的总计数仍为 1。
我需要计算每个返回的文档在字段中出现搜索词的次数。
我阅读了Word frequency in Solr 和SOLR term frequency 并启用了术语向量组件,但它不起作用。
我以这种方式配置了我的字段:
<field name="text_text" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
但如果我进行以下查询:
http://localhost:8888/solr/sources/select?q=text_text%3A%22Peter+Pan%22&fl=text_text&wt=json&indent=true&tv.tf
我没有任何计数:
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"fl":"text_text",
"tv.tf":"",
"indent":"true",
"q":"text_text:\"Peter Pan\"",
"wt":"json"}},
"response":{"numFound":12,"start":0,"docs":[
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"},
{
"text_text":"Text of the document"}]
}}
我看到“numFound”值为 12,但“彼得潘”一词在所有 12 个文档中出现了 20 次。
请你帮我找出哪里错了吗?
非常感谢!
【问题讨论】:
-
参数 tv.tf 存在,但可以将空字符串测试为布尔值 false。在您的查询
tv=true&tv.tf=true中尝试使用这些参数。 -
@Mat :你得到答案了吗?我也有同样的麻烦。请你帮帮我好吗?
-
@iNikkz:对不起,我不记得我在哪里使用这个功能,但我有一个模糊的记忆,我没有解决它,我用另一种方式计算了词频,不是直接来自索尔。对不起。
-
@Mat:好的。谢谢。我有解决方案。试试看。 (I) 总词频 =>
http://localhost:8983/solr/collection1/spell?q=theq&wt=json&indent=true&fl=ttf(term,the)和 (II) 词频 =>http://localhost:8983/solr/collection1/spell?q=gram:%22ago%22&rows=100&fl=gram,termfreq(gram,ago)
标签: solr word-frequency