Aggregations order error

Environmental Science

JDK: 1.8
elasticsearch: 5.5.0

DSL:

GET /data/_search
{
  "from" : 0,
  "size" : 0,
  "query" : {
    "bool" : {
      "must" : [
        {
          "term" : {
            "stage" : {
              "value" : "1",
              "boost" : 1.0
            }
          }
        },
        {
          "bool" : {
            "should" : [
              {
                "bool" : {
                  "must" : [
                    {
                      "term" : {
                        "title_ngram_sore" : {
                          "value" : "北京",
                          "boost" : 1.0
                        }
                      }
                    }
                  ],
                  "disable_coord" : false,
                  "adjust_pure_negative" : true,
                  "boost" : 1.0
                }
              },
              {
                "bool" : {
                  "must" : [
                    {
                      "term" : {
                        "text_nlp" : {
                          "value" : "北京",
                          "boost" : 1.0
                        }
                      }
                    }
                  ],
                  "disable_coord" : false,
                  "adjust_pure_negative" : true,
                  "boost" : 1.0
                }
              },
              {
                "bool" : {
                  "must" : [
                    {
                      "term" : {
                        "title_ngram_sore" : {
                          "value" : "人工智能",
                          "boost" : 1.0
                        }
                      }
                    }
                  ],
                  "disable_coord" : false,
                  "adjust_pure_negative" : true,
                  "boost" : 1.0
                }
              },
              {
                "bool" : {
                  "must" : [
                    {
                      "term" : {
                        "text_nlp" : {
                          "value" : "人工智能",
                          "boost" : 1.0
                        }
                      }
                    }
                  ],
                  "disable_coord" : false,
                  "adjust_pure_negative" : true,
                  "boost" : 1.0
                }
              }
            ],
            "disable_coord" : false,
            "adjust_pure_negative" : true,
            "boost" : 1.0
          }
        }
      ],
      "disable_coord" : false,
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },
  "aggregations" : {
    "group" : {
      "terms" : {
        "field" : "dataSource",
        "size" : 8,
        "min_doc_count" : 1,

        "order" : [
          {
            "top.pubdate" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      },
      "aggregations" : {
        "top" : {
          "top_hits" : {
           
            "from" : 0,
            "size" : 1,
            "version" : false,
            "explain" : false,
            "sort" : [
              {
                "reprint" : {
                  "order" : "desc"
                }
              },
              {
                "pubdate" : {
                  "order" : "desc"
                }
              }
            ]
          }
        }
      }
    }
  }
}

ERROR

   {
   "error": {
      "root_cause": [
         {
            "type": "aggregation_execution_exception",
            "reason": "Invalid terms aggregation order path [top.pubdate]. Terms buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end."
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "xw",
            "node": "9GXVKVesQXCKY4vheQqtpQ",
            "reason": {
               "type": "aggregation_execution_exception",
               "reason": "Invalid terms aggregation order path [top.pubdate]. Terms buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end."
            }
         }
      ]
   },
   "status": 500
}

I want to sort the data field after the bucket, but there is a mistake that I don't know how to solve. Please help me look at it. Thank you very much.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.