最简单的解决方案是原始问题中选项1的实现。
public void CreateIndex(string indexName, string json)
{
ElasticClient client = GetClient();
var response = _client.Raw.IndicesCreatePost(indexName, json);
if (!response.Success || response.HttpStatusCode != 200)
{
throw new ElasticsearchServerException(response.ServerError);
}
}
修改了转换器,JsonReaders和JsonSerializers之后,我发现IndexSettingsConverter似乎没有正确地将任意设置json反序列化为有效的IndexSettings对象。感觉到一个兔子洞,我接受了Manolis的建议,并弄清楚了如何直接对ElasticClient.IElasticsearchClient应用任意json以避免对安全性和连接细节进行逆向工程。
做出这个结论是费力的,而且如果不处理大量未记录的NEST代码,这是完全不可能的。