gpt4 book ai didi

elasticsearch - 巢状更新索引设定

转载 作者:行者123 更新时间:2023-12-02 23:02:28 28 4
gpt4 key购买 nike

我关注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" }
}))
)

现在,您可以运行测试以检查此分析器是否返回正确的 token :

client.Analyze(a => a.Index(indexName).Text("this <a> is a test <div>").Analyzer("folded_word"));

输出:

this
is
a
test

希望能帮助到你。

关于elasticsearch - 巢状更新索引设定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30935973/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com