如何在 Elastic Search NEST 中设置设置 7.x

How to set settings in Elastic Search NEST 7.x

在为项目编制索引时,returns出现此错误: 索引 [] 被阻止:[FORBIDDEN/12/index 只读/允许删除 (api)];

我找到了解决方案: curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' 解决方案来源:https://benjaminknofe.com/blog/2017/12/23/forbidden-12-index-read-only-allow-delete-api-read-only-elasticsearch-indices/

如何在 NEST 7.x 中将此设置应用到我的 ElasticClient 对象?

谢谢,

有 NEST 7.x

var client = new ElasticClient();

var response = client.Indices.UpdateSettings(Indices.All, u => u
    .IndexSettings(i => i
        .Setting("index.blocks.read_only_allow_delete", false)
    )
);

大多数设置都有适用于它们的方法,但目前没有(会添加)。如果方法不存在,.Setting() 可以与设置名称和值一起使用。传递 false 的结果与传递 null 的结果相同。