I'm trying to use NEST's Automapping to create an index template like so:
public void ConfigureTemplate()
{
var templateName = $"{config.ElasticIndexPrefix}_template";
var client = OpenConnection(config.ElasticEndpoints);
var indexResponse = client.PutIndexTemplate(templateName, t => t
.IndexPatterns($"{config.ElasticIndexPrefix}_*")
.Settings(s => s
.NumberOfReplicas(2)
.NumberOfShards(4)
.Setting("index.lifecycle.name", $"{config.ElasticIndexPrefix}-ilm-policy")
.Setting("index.lifecycle.rollover_alias", $"{config.ElasticIndexPrefix}_alias")
)
.Mappings(ms => ms
.Map<PodcastAsset>(m => m.AutoMap())
.Map<PodcastSource>(m => m.AutoMap())
)
.Aliases(a => a
.Alias($"{config.ElasticIndexPrefix}_alias", newAlias => newAlias
//No Setting for is_write_index here
)
)
);
_logger.Info($"Template {templateName} asserted.");
}
Via the REST api it's a matter of setting simply setting a key/value like this:
PUT /_templates/my-template
{
"index_patterns": ["mysystem-*"],
"aliases": {
"mysystem-logs": {
"is_write_index": true
}
},
"settings": {
"index.number_of_shards": 6,
"index.number_of_replicas": 0,
"index.lifecycle.name": "mysystem-ilm-policy",
"index.lifecycle.rollover_alias": "mysystem-logs"
},
"order": 10
}
While this works, the problem here is that I don't benefit from the automapping of the NEST integration.
How do I set a value for alias.is_write_index when creating an index template via NEST?
Many thanks!
-Z