有个人长的像洋葱,走着走着就哭了…….

elasticsearch聚合结果不准确

Elasticsearch | 作者 lc32781971 | 发布于2016年11月19日 | 阅读数:8366

在用es搜索时,hits结果里面有的属性没有出现在聚合结果里面.

比如hits里面有一个 
"attributes": [
    {
        "option_id": "1",
        "option_name": "口味",
        "value_id": "8",
        "value_name": "什锦味"
    }
    ,
    {
        "option_id": "3",
        "option_name": "包装",
        "value_id": "21",
        "value_name": "盒装"
    }
]

但是聚合结果只能出来
"aggregations": {

    "attributes": {
        "doc_count": 430,
        "attributes": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 175,
            "buckets": [
                {
                    "key": "26",
                    "doc_count": 38
                }
           ]
已邀请:

martindu - 搜披露创始人

赞同来自:

聚合的是哪个字段?value_id吗?
 
terms aggregation默认是按照桶(bucket)内文档数量返回前十个桶,你看你的response里面有个sum_other_doc_count,这些是不在你这10个桶里面的。如果你想返回所有的桶的话,可以根据你的文档设置一个大一点的size,或者将size设为0(文档多慎用)。

要回复问题请先登录注册