gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 01:25:51 26 4
gpt4 key购买 nike

我正在尝试使用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

最佳答案

糟糕,此问题在NEST 6.x的更高版本中得到了解决。

已验证存在于NEST / Elasticsearch.net 6.8.3

谢谢!

关于.net - 创建模板时如何在Elasticsearch.Net/NEST中设置Alias.is_write_index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58307031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com