首页 > 解决方案 > elasticsearch termvectors RESTful 接口返回错误结果

问题描述

我的 Elasticsearch 文档中只存储了一个文档,然后我调用{{es-host}}/word_text/data/AXuBd0JbG6dDNwCvvmgY/_termvectors了 restful 接口来获取术语 statsitc 信息,请求男孩:

{
    "fields": [
        "content"
    ],
    "offsets": false,
    "payloads": false,
    "positions": false,
    "term_statistics": true,
    "field_statistics": true,
    "per_field_analyzer": {
        "content": "ik_smart"
    }
}

最后,我得到如下结果

{
    "_index": "word_text",
    "_type": "data",
    "_id": "AXuBd0JbG6dDNwCvvmgY",
    "_version": 1,
    "found": true,
    "took": 33,
    "term_vectors": {
        "content": {
            "field_statistics": {
                "sum_doc_freq": 342,
                "doc_count": 1,
                "sum_ttf": 909
            },
            "terms": {
                "10月": {
                    "term_freq": 1
                },
                "12": {
                    "doc_freq": 1,
                    "ttf": 2,
                    "term_freq": 2
                },
                "19日": {
                    "term_freq": 1
                },
                "2": {
                    "doc_freq": 1,
                    "ttf": 1,
                    "term_freq": 1
                },
                "2019": {
                    "doc_freq": 1,
                    "ttf": 4,
                    "term_freq": 3
                }

我对这个结果有一些疑问。

  1. 理论上每个term应该有doc_freq、ttf、term_freq三个统计属性,但是这个结果中只有一些词有三个属性,有的只有一个属性,缺少doc_freq和ttf属性。

  2. 在这个 ES 索引中,只有一个文档。这时候tf值应该和ttf值一样,但是在部分termsstatistics两个值不同。

标签: javaelasticsearch

解决方案


推荐阅读