0
votes

I want to create an index and modify its setting with template and at the same time create an alias for it

"template_1" : {
    "order" : 0,
    "index_patterns" : [
      "test*"
    ],
    "settings" : {
      "index" : {
        "number_of_shards" : "2",
        "number_of_replicas" : "2"
      }
    },
    "mappings" : { },
    "aliases" : { 
        "some-alias" : { }
    }
  }
} 

when I am trying to put a document using alias, it tries to create an index with the alias name. However I am looking for something which will search for the index which has this alias and throws an error that there are no index exist with this alias

1

1 Answers

0
votes

The problem is you are referencing multiple indexes with a single alias, so when you PUT a document ES does not know in which document to store it to. Quoting the doc:

If no write index is specified and there are multiple indices referenced by an alias, then writes will not be allowed.

One solution, as per quote above, is to specify a write index (see docs) as the default destination for new documents (its also possible to specify rollover rules to update it).

The other solution, of course, is use the actual index name when putting docs.