提问要多花一点心思哦

Es5.2聚合查询错误

Elasticsearch | 作者 yuan327159409 | 发布于2017年05月04日 | 阅读数:14793

查询语句:
{
  "from" : 0,
  "size" : 10,
  "aggregations" : {
    "userName" : {
      "terms" : {
        "size" : 10,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      },
      "aggregations" : {
        "quantity" : {
          "avg" : {
            "field" : "quantity"
          }
        }
      }
    }
  }
}
 
 
异常:
Caused by: java.lang.IllegalStateException: value source config is invalid; must have either a field context or a script or marked as unwrapped
    at org.elasticsearch.search.aggregations.support.ValuesSourceConfig.toValuesSource(ValuesSourceConfig.java:228)
    at org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory.createInternal(ValuesSourceAggregatorFactory.java:52)
    at org.elasticsearch.search.aggregations.AggregatorFactory.create(AggregatorFactory.java:226)
    at org.elasticsearch.search.aggregations.AggregatorFactories.createTopLevelAggregators(AggregatorFactories.java:103)
    at org.elasticsearch.search.aggregations.AggregationPhase.preProcess(AggregationPhase.java:57)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:104)
    at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:246)
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:260)
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:298)
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:295)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
    at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
 
已邀请:

要回复问题请先登录注册