You could use a scripted sort as follows:
POST index_name/_search
{
"query": {
"term": {
"tags": {
"value": 1
}
}
},
"sort": [
{
"_script": {
"type": "number",
"script": {
"lang": "painless",
"source": "params._source.tags.indexOf(params.target)",
"params": {
"target": 1
}
},
"order": "asc"
}
}
]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…