计算SOLR索引中单词的总频率

Mat*_*Mat 6 solr word-frequency

如果我在SOLR索引中搜索某个单词,则会得到包含该单词的文档的文档计数,但是如果该单词在文档中包含的次数更多,则每个文档的总数仍为1。

我需要对每个返回的文档进行计数,以计算它们在该字段中具有搜索词的次数。

在SolrSOLR术语频率中读取词频率,并启用了术语向量分量,但是它不起作用。

我以这种方式配置字段:

<field name="text_text" type="textgen" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
Run Code Online (Sandbox Code Playgroud)

但是,如果我进行以下查询:

http://localhost:8888/solr/sources/select?q=text_text%3A%22Peter+Pan%22&fl=text_text&wt=json&indent=true&tv.tf
Run Code Online (Sandbox Code Playgroud)

我没有任何数:

{
  "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"}]
  }}
Run Code Online (Sandbox Code Playgroud)

我看到“ numFound”值为12,但在所有12个文档中都包含20次“ Peter Pan”。

你能帮我找到我错了吗?

非常感谢你!

Joh*_*one 0

我认为首先你的例子不起作用,因为“Peter Pan”不是一个单词或术语 - 它是一个短语。关于查找短语频率的挑战的一个很好的讨论如下:

短语的 termfreq

我会用一个单词而不是短语重新尝试您的示例,看看它是否适合您。