1
votes

Could Elasticsearch Template be used to do index sorting https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-index-sorting.html

2
Hi mitz, welcome to stack overflow, please edit your question to include the code you're presently using which is generating the error you've provided. - bdx

2 Answers

1
votes

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"
            }
        }
    }
}
1
votes

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.