lang/ELK

ELK sort script

C/H 2021. 2. 25. 17:59

script sort

{
  index: 'index_name',
  body: {
    form: 0,
    size: 20,
    query: {
      bool: {
        filter: [
          { match: { userId: `${userId}`} },
          { match: { delete_at: null }
        ]
    }
  },
  sort: [
    {
      _script: {
      type: `number`,
      script: {
          params: { score: { "live": 9, "catchup": 99, "vod": 999 } },
        source: `params.score[doc.broadcastTypeCode.value]`,
        },
      order: "asc"
    },
//  {
//    _script: {
//      type: "number",
//      script: `doc.broadcastTypeCode.value==="live" ? 9: doc.broadcastTypeCode.value==="catchup" ? 99 : 999`,
//      order: "asc",
//    }
//  },
    { regDt: { order: "desc" } },  
  ]
}
반응형

'lang > ELK' 카테고리의 다른 글

ELK datetime Sort, Diff  (0) 2021.03.03
ELK, EFK Stack, And Splunk  (0) 2016.06.29