可以使用Elasticsearch模板进行索引排序https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-index-sorting.html
是,index sorting与其他设置一样,可以在index template中指定:
PUT _template/mytemplate
{
"index_patterns": ["myindex"],
"aliases": {},
"settings" : {
"index" : {
"number_of_shards": 2,
"number_of_replicas": 1,
"sort.field" : "date",
"sort.order" : "desc"
}
},
"mappings": {
"properties": {
"date": {
"type": "date"
}
}
}
}