简体   繁体   English

在弹性搜索中使用术语构面返回单个文档的术语计数

[英]Returning term count for a single document using the terms facet in elastic search

Say I have the following search query... 说我有以下搜索查询...

POST /topics/_search
{
    "fields": [
       "topic_attachment",
       "topic_replies",
       "topic_status"
    ],
    "query" : {
        "filtered" : {
            "query" : {
                "term" : { 
                    "_id" : "5478"
                }
            }
        }           
    },
    "facets": {
       "text": {
          "terms": {
             "field": "text",
             "size": 10,
             "order": "count"
            }
       }
    }
}

The result of this search is the following. 该搜索的结果如下。

{
   "took": 93,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "topics",
            "_type": "full-topic",
            "_id": "5478",
            "_score": 1,
            "fields": {
               "topic_replies": 1141,
               "topic_status": 0,
               "topic_attachment": false
            }
         }
      ]
   },
   "facets": {
      "text": {
         "_type": "terms",
         "missing": 0,
         "total": 8058,
         "other": 8048,
         "terms": [
            {
               "term": "ω",
               "count": 1
            },
            {
               "term": "œyouâ",
               "count": 1
            },
            {
               "term": "œyou",
               "count": 1
            },
            {
               "term": "œwhisperedâ",
               "count": 1
            },
            {
               "term": "œwalt",
               "count": 1
            },
            {
               "term": "œunderstandingâ",
               "count": 1
            },
            {
               "term": "œtieâ",
               "count": 1
            },
            {
               "term": "œthe",
               "count": 1
            },
            {
               "term": "œpersonally",
               "count": 1
            },
            {
               "term": "œnappiesâ",
               "count": 1
            }
         ]
      }
   }
}

Each term has a count of exactly 1. Why is this? 每个术语的计数均为1。这是为什么? I know the text from this document has more than one term in common. 我知道本文档中的文本有多个共同点。 Is this because the term count only increments once per document? 这是因为术语计数在每个文档中仅增加一次? If so how do I count a term more than once from a single document? 如果是这样,我如何从一个文档中多次计算一个术语?

That's the document count, not the term frequency. 那是文件数量,而不是术语频率。 Luckily with the new aggregations module (replacement for facets introduced in 1.0.Beta2) count has been renamed to doc_count to clarify what it is. 幸运的是,使用新的聚合模块(在1.0.Beta2中引入了替换构面), count已重命名为doc_count以阐明其含义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM