1

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

mitz
  • 13
  • 3
  • 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 Sep 26 '19 at 03:07

2 Answers2

1

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"
            }
        }
    }
}
Val
  • 207,596
  • 13
  • 358
  • 360
1

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.

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66