- [Elasticsearch order by a certain field value first](https://stackoverflow.com/questions/39762238/elasticsearch-order-by-a-certain-field-value-first
darklow/elasticsearch.custom.sort.py
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 |