嵌套更新索引设置
Nest update index settings
我正在关注 post Creating an index Nest 并尝试更新我的索引设置。一切运行良好,但 html_strip
过滤器未剥离 HTML。我的密码是
var node = new Uri(_url + ":" + _port);
var settings = new ConnectionSettings(node);
settings.SetDefaultIndex(index);
_client = new ElasticClient(settings);
//to apply filters during indexing use folding to remove diacritics and html strip to remove html
_client.UpdateSettings(
f = > f.Analysis(descriptor = > descriptor
.Analyzers(
bases = > bases
.Add("folded_word", new CustomAnalyzer
{
Filter = new List < string > { "icu_folding", "trim" },
Tokenizer = "standard"
}
)
)
.CharFilters(
cf = > cf.Add("html_strip", new HtmlStripCharFilter())
)
)
);
您遇到错误:
Can't update non dynamic
settings[[index.analysis.analyzer.folded_word.filter.0,
index.analysis.char_filter.html_strip.type,
index.analysis.analyzer.folded_word.filter.1,
index.analysis.analyzer.folded_word.type,
index.analysis.analyzer.folded_word.tokenizer]] for open
indices[[my_index]]
在尝试更新设置之前,请先关闭索引,然后更新设置并重新打开。 Have a look.
client.CloseIndex(..);
client.UpdateSettings(..);
client.OpenIndex(..);
更新
向您的自定义分析器添加 html_strip
字符过滤器:
.Analysis(descriptor => descriptor
.Analyzers(bases => bases.Add("folded_word",
new CustomAnalyzer
{
Filter = new List<string> { "icu_folding", "trim" },
Tokenizer = "standard",
CharFilter = new List<string> { "html_strip" }
}))
)
现在您可以 运行 测试以检查此分析器是否 returns 正确的标记:
client.Analyze(a => a.Index(indexName).Text("this <a> is a test <div>").Analyzer("folded_word"));
输出:
this
is
a
test
希望对您有所帮助。
我正在关注 post Creating an index Nest 并尝试更新我的索引设置。一切运行良好,但 html_strip
过滤器未剥离 HTML。我的密码是
var node = new Uri(_url + ":" + _port);
var settings = new ConnectionSettings(node);
settings.SetDefaultIndex(index);
_client = new ElasticClient(settings);
//to apply filters during indexing use folding to remove diacritics and html strip to remove html
_client.UpdateSettings(
f = > f.Analysis(descriptor = > descriptor
.Analyzers(
bases = > bases
.Add("folded_word", new CustomAnalyzer
{
Filter = new List < string > { "icu_folding", "trim" },
Tokenizer = "standard"
}
)
)
.CharFilters(
cf = > cf.Add("html_strip", new HtmlStripCharFilter())
)
)
);
您遇到错误:
Can't update non dynamic settings[[index.analysis.analyzer.folded_word.filter.0, index.analysis.char_filter.html_strip.type, index.analysis.analyzer.folded_word.filter.1, index.analysis.analyzer.folded_word.type, index.analysis.analyzer.folded_word.tokenizer]] for open indices[[my_index]]
在尝试更新设置之前,请先关闭索引,然后更新设置并重新打开。 Have a look.
client.CloseIndex(..);
client.UpdateSettings(..);
client.OpenIndex(..);
更新
向您的自定义分析器添加 html_strip
字符过滤器:
.Analysis(descriptor => descriptor
.Analyzers(bases => bases.Add("folded_word",
new CustomAnalyzer
{
Filter = new List<string> { "icu_folding", "trim" },
Tokenizer = "standard",
CharFilter = new List<string> { "html_strip" }
}))
)
现在您可以 运行 测试以检查此分析器是否 returns 正确的标记:
client.Analyze(a => a.Index(indexName).Text("this <a> is a test <div>").Analyzer("folded_word"));
输出:
this
is
a
test
希望对您有所帮助。