“我想在指数使用ElasticSearch和NEST .NET客户端自动完成SEACH去创造。我下面就本教程http://qbox.io/blog/an-introduction-to-ngrams-in-elasticsearch和创建索引和它的设置时遇到了问题Sepcifically我想创建具有以下设置的指数(取直出本教程的TL的; DR,首先):
PUT /test_index
{
"settings": {
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"edge_ngram_filter"
]
}
}
}
}
我的问题是,我不知道如何发送的"filter": [ "lowercase", "edge_ngram_filter" ]
使用NEST部分。 我现在的尝试是这样的:
esclient.CreateIndex("test_index", s => s
.Settings(settings => settings
.Add("analysis.filter.edge_ngram_filter.type", "edge_ngram")
.Add("analysis.filter.edge_ngram_filter.min_gram", "2")
.Add("analysis.filter.edge_ngram_filter.max_gram", "20")
.Add("analysis.analyzer.edge_ngram_analyzer.type", "custom")
.Add("analysis.analyzer.edge_ngram_analyzer.tokenizer", "standard")
// Interesting part on the line below!
.Add("analysis.analyzer.edge_ngram_analyzer.filter", new string[] { "lowercase", "edge_ngram_filter" })
)
);
但这种失败枝条一JsonWriterException:“不支持的类型:System.String []使用JsonSerializer类来获取对象的JSON表示路径‘settings.index’。”。 我曾试图简单地手动提供JSON阵列( .Add("analysis.analyzer.edge_ngram_analyzer.filter", "[ \"lowercase\", "\edge_ngram_analyzer\" ]")
的JSON代替转义为一个字符串。
是否NEST API提供这样的方法吗?