Could Elasticsearch Template be used to do index sorting https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-index-sorting.html
2 Answers
I guess that your question targets Spring Data Elasticsearch as you tagged it correspondingly.
Spring Data Elasticsearch currently does not support managing index templates, theres is a ticket in Jira to support this.
You can of course add the index templates manually in ES like shown in Val's answer.
Comments
Yes, index sorting is like any other settings and can be specified in an 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"
}
}
}
}