6

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

我需要计算每个返回的文档在字段中搜索单词的次数。

在 SolrSOLR词频中阅读了词频,并启用了词向量组件,但它不起作用。

我以这种方式配置了我的字段:

<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 次。

你能帮我找出我错的地方吗?

非常感谢!

4

2 回答 2

0

我认为首先你的例子是行不通的,因为“彼得潘”不是一个词或术语——它是一个短语。关于寻找短语频率的挑战的一个很好的讨论在这里:

词组的 termfreq

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

于 2014-04-30T01:28:01.347 回答
0

Try this structure of creating term frequency in the response:

http://localhost:8983/solr/core/select?indent=on&q=solr&fl=field,termfreq("field","term")&wt=json
于 2016-12-07T14:06:10.307 回答