[创建模板时如何在Elasticsearch.Net/NEST中设置Alias.is_write_index

问题描述 投票:0回答:1

我正在尝试使用NEST的自动映射来创建索引模板,如下所示:

    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.");
    }

通过REST api,只需设置像这样的键/值就可以了:

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
}

虽然这可行,但这里的问题是我无法从NEST集成的自动映射中受益。

通过NEST创建索引模板时如何为alias.is_write_index设置值?

非常感谢!

-Z

.net elasticsearch nest elasticsearch-net
1个回答
0
投票

希望在更高版本的NEST 6.x中修复此问题。

在NEST / Elasticsearch.net 6.8.3中已验证的存在

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.