java api还原DSL语法如下,我手动改了下面红色标识的地方
GET /xw/_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": {
"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": "bz",
"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
}