I can't provide a set of synonyms when creating the analyzer
powfyy opened this issue · 7 comments
Java API client version
8.13.2
Java version
17
Elasticsearch Version
8.12.2
Problem description
Hello, I read in the documentation: "Use synonyms_set configuration option to provide a synonym set created via Synonyms Management APIs:", but the SynonymGraphTokenFilter class does not have a corresponding field, there are only synonyms (String) and synonymsPath. How can I provide a set of synonyms?
private final ElasticsearchClient client;
client.indices().create(
new CreateIndexRequest.Builder()
.index(INDEX_PREFIX + "_" + name)
.settings(new IndexSettings.Builder()
.numberOfShards(SHARDS)
.numberOfReplicas(REPLICAS)
.analysis(new IndexSettingsAnalysis.Builder()
.analyzer("search_analyzer", new Analyzer.Builder()
.custom(new CustomAnalyzer.Builder()
.tokenizer("standard")
.filter("synonym_graph")
.build())
.build())
.filter("synonym_graph", new TokenFilter.Builder()
.definition(new TokenFilterDefinition.Builder()
.synonymGraph(new SynonymGraphTokenFilter.Builder()
.updateable(true)
.build())
.build())
.build())
.build())
.build())
.build()
);
I am running into the same exact issue but with the .Net library. I have created the issue here:
Hello, thanks for reporting this! The property is missing from the API specification which is used to generate the clients, so that's why this issue can also be found in the .NET one. We'll fix it and then regenerate the client to solve this.
also while waiting for a fix, here's how to shorten that request using the lambda version of the builders :D
client.indices().create(c -> c
.index(INDEX_PREFIX + "_" + name)
.settings(s -> s
.numberOfShards(SHARDS)
.numberOfReplicas(REPLICAS)
.analysis(an -> an
.analyzer("search_analyzer", anl -> anl
.custom(cu -> cu
.tokenizer("standard")
.filter("synonym_graph")))
.filter("synonym_graph", tf -> tf
.definition(def -> def
.synonymGraph(syn -> syn
.updateable(true))
)))));
Thank you for your responsiveness <3
Thank you. Do you know about how long this would take to be released?
That depends on the client, but it's usually the next version after the api spec has been fixed