计算SOLR索引中单词的总频率
如果我在SOLR索引中搜索一个单词,我会得到包含该单词的文档的文档计数,但是如果该单词在文档中包含的次数更多,则每个文档的总计数仍然是1 我需要计算每个返回的文档在字段中搜索单词的次数 我阅读并启用了术语向量组件,但它不起作用 我以这种方式配置了我的字段:计算SOLR索引中单词的总频率,solr,word-frequency,Solr,Word Frequency,如果我在SOLR索引中搜索一个单词,我会得到包含该单词的文档的文档计数,但是如果该单词在文档中包含的次数更多,则每个文档的总计数仍然是1 我需要计算每个返回的文档在字段中搜索单词的次数 我阅读并启用了术语向量组件,但它不起作用 我以这种方式配置了我的字段: <field name="text_text" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffset
<field name="text_text" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
我没有任何计数:
{
"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,但“Peter Pan”一词在所有12个文档中都包含了20次
你能帮我找出哪里错了吗
多谢各位 首先,我认为你的例子行不通,因为“彼得·潘”不是一个词或术语,而是一个短语。关于寻找短语频率的挑战,这里有一个很好的讨论:
我会用一个单词而不是一个短语来重新尝试您的示例,看看它是否适合您。尝试在响应中创建术语频率的这种结构:
http://localhost:8983/solr/core/select?indent=on&q=solr&fl=field,termfreq("field","term")&wt=json
参数tv.tf存在,但可以将空字符串测试为布尔值false。在您的查询中尝试使用这些参数。
tv=true&tv.tf=true
@Mat:您得到答案了吗。我也有同样的麻烦。你能帮我一下吗?@iNikkz:对不起,我不记得我在哪里使用过这个功能,但我有一个模糊的记忆,我没有解决它,我用另一种方式计算术语频率,不是直接从Solr计算的。对不起。@Mat:好的。谢谢我有解决办法。试试看。(一) 总术语频率=>http://localhost:8983/solr/collection1/spell?q=theq&wt=json&indent=true&fl=ttf(术语,the)
和(II)术语频率=>http://localhost:8983/solr/collection1/spell?q=gram:%22ago%22&rows=100&fl=gram,termfreq(克,年前)
http://localhost:8983/solr/core/select?indent=on&q=solr&fl=field,termfreq("field","term")&wt=json