Reputation: 993
I am following the post Creating an index Nest and trying to update my index settings. All runs fine however the html_strip
filter is not stripping HTML. My code is
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())
)
)
);
Upvotes: 1
Views: 4336
Reputation: 9979
You are getting error:
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]]
Before you will try to update settings, close index first, update settings and reopen afterwards. Have a look.
client.CloseIndex(..);
client.UpdateSettings(..);
client.OpenIndex(..);
UPDATE
Add html_strip
char filter to you custom analyzer:
.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" }
}))
)
Now you can run test to check if this analyzer returns correct tokens:
client.Analyze(a => a.Index(indexName).Text("this <a> is a test <div>").Analyzer("folded_word"));
Output:
this
is
a
test
Hope it helps.
Upvotes: 2