0

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

1 Answer 1

1

Whoops this was fixed in a later release of NEST 6.x.

Verified present in NEST/Elasticsearch.net 6.8.3

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.