沙师弟,师父的充电器掉了

sum_bucket 如何聚合bucket_script的计算结果

Elasticsearch | 作者 zhyusElastic | 发布于2019年02月16日 | 阅读数:4011

聚合:"aggs": {
        "cid": {
            "terms": {
                "field": "jsonData.cid",
                "size": 2000
            },
            "aggs": {
                "acc": {
                    "terms": {
                        "field": "jsonData.acc.keyword",
                        "size": 20000
                    },
                    "aggs": {
                        "max": {
                            "max": {
                                "field": "jsonData.hisNum"
                            }
                        },"min": {
                            "min": {
                                "field": "jsonData.hisNum"
                            }
                        },
                        "minus": {
                            "bucket_script": {
                                "buckets_path": {
                                    "max": "max",
                                    "min":"min"
                                },
                                "script": "params.max-params.min"
                            }
                        }
                    }
                }
            }
        },"total":{
          "sum_bucket": {
            "buckets_path": "cid>acc>minus"
          }
        }
    }
异常:
{
  "error": {
    "root_cause": [],
    "type": "search_phase_execution_exception",
    "reason": "",
    "phase": "fetch",
    "grouped": true,
    "failed_shards": [],
    "caused_by": {
      "type": "aggregation_execution_exception",
      "reason": "buckets_path must reference either a number value or a single value numeric metric aggregation, got: java.lang.Object[]"
    }
  },
  "status": 503
}
已邀请:

zhyusElastic - 90后IT java

赞同来自:

问题已解决,谢谢。 但是tophits的数据还是不能被bucketscript调用 正在找方法

要回复问题请先登录注册