1

I am trying to sort some data in my ES query. I have tried a lot of things and spend a lot of time, But unable to find the solution. Below is the query. Thanks in advance for help.

"size":0,
"aggs":{ 
"abc":{ 
"composite":{ 
"sources":[ 
{ 
"abc_id":{ 
"terms":{ 
"field":"l1.id"
}
}
}
],
"size":"100"
},
"aggs":{ 
"impressions":{ 
"filters":{ 
"filters":[ 
{ 
"bool":{ 
"must":[ 
{ 
"exists":{ 
"field":"l3.imp"
}
}
]
}
}
]
},
"aggs":{ 
"kpi":{ 
"bucket_script":{ 
"buckets_path":{ 
"imp":"sum_of_imp"
},
"script":"params.imp"
}
},
"sum_of_imp":{ 
"sum":{ 
"field":"l3.imp"
}
},
"sorting_sum_of_imp":{
  "bucket_sort": {
    "sort": [{
      "sum_of_imp":{
        "order":"desc"
      }
    }]
  }
}
}
}
}
}
},
"query":{ 
"bool":{ 
"filter":{ 
"bool":{ 
"must":[ 
{ 
"term":{ 
"ar.type":"search"
}
},
{ 
"range":{ 
"as_on":{ 
"gte":"2018-12",
"lte":"2019-12"
}
}
}
],
"must_not":[ 
]
}
}
}
}
}
ap.singh
  • 1,150
  • 4
  • 15
  • 35

0 Answers0