【发布时间】:2017-02-02 10:22:22
【问题描述】:
使用 NEST v.5 创建索引的正确方法是什么?我在这里看到了类似的帖子:Specifying and using a NGramTokenizer with the C# NEST client for Elastic Search。但似乎 API 已更改。我可以通过以下方式做到这一点:
ConnectionSettings settings = new ConnectionSettings(new Uri("http://localhost:9200"));
IndexSettings indexSettings = new IndexSettings();
CustomAnalyzer customAnalyzer = new CustomAnalyzer();
customAnalyzer.Tokenizer = "mynGram";
customAnalyzer.Filter = new List<string> { "lowercase" };
indexSettings.Analysis.Analyzers.Add("mynGram", customAnalyzer);
indexSettings.Analysis.Tokenizers.Add("mynGram",
new NGramTokenizer
{
MaxGram = 10,
MinGram = 2
});
elasticClient = new ElasticClient(settings);
elasticClient.CreateIndex("taskmanager", s => s
.Settings(sett => sett
.Analysis(a => a
.Analyzers(anl => anl
.Custom("customAnalyzer", c => c
// how to set my custom analyzer?
.Tokenizer("mynGram")
)
)
)
)
);
问题是我不知道如何使用 fluent API 进行设置。
【问题讨论】:
标签: c# elasticsearch nest