使用 dmesg 来查看一些硬件或驱动程序的信息或问题。

terms聚合size不能为0吗

Elasticsearch | 作者 aoliao_paopao | 发布于2018年04月09日 | 阅读数:7376

我看别人的size可以为0,但是我的报错了
{
  "query": {

  },
  "aggs": {
    "test": {
      "terms": {
        "field": "account_id",
        "size": 0
      }
    }
  }
}
 
{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[terms] failed to parse field [size]",
        "line": 9,
        "col": 17
      }
    ],
    "type": "parsing_exception",
    "reason": "[terms] failed to parse field [size]",
    "line": 9,
    "col": 17,
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "[size] must be greater than 0. Found [0] in [test]"
    }
  },
  "status": 400
}
已邀请:

zhihuizhou

赞同来自:

必须大于0,可以在top中指定为1

zhihuizhou

赞同来自:

size是对应查询的条数,top指定的是你显示聚合中id相同显示的条数.
{
  "aggregations": {
    "agg": {
      "terms": {
        "field": "supplierId",
        "size": 9
      },
      "aggregations": {
        "top": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  }
}

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

size为0是早期版本,0代表全部;5.x,6.x都不允许为0了。

要回复问题请先登录注册