【发布时间】:2020-06-04 09:02:46
【问题描述】:
我对 ES 很陌生。在探索 .Net 的 NEST 客户端时,我遇到了一种无法弄清楚如何使用 NEST.Net 实现的情况。
配置: .Net 4.6.1 巢 7.2.0
我正在尝试在现有索引上设置别名。我能够使用以下方法实现它。
await _client.Indices.PutAliasAsync(indexName, aliasName);
这会在索引上创建一个别名,尽管别名为空。
现在我想实现以下结构。
"MyIndexName" : {
"aliases" : {
"MyAliasName" : {
"filter" : {
"term" : {
"MyFilterTerm" : "MyFilterTermValue"
}
}
},
}
我在sn-p下面用过
await _client.Indices.PutAliasAsync(indexName, aliasName,
a => a.Filter<MyTestClass>(
f => f.Term("MyFilterTerm", "MyFilterTermValue")));
public class MyTestClass {// not sure what this was supposed to be}
然而这会产生如下的 json。
"MyIndexName" : {
"aliases" : {
"MyAliasName" : {
"filter" : {
"term" : {
"MyFilterTerm" : {
"value" : "MyFilterTermValue"
}
}
}
},
}
第一种JSON格式如何实现?
【问题讨论】:
标签: c# .net elasticsearch nest