Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't provide a set of synonyms when creating the analyzer #781

Closed
powfyy opened this issue Apr 11, 2024 · 7 comments
Closed

I can't provide a set of synonyms when creating the analyzer #781

powfyy opened this issue Apr 11, 2024 · 7 comments
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@powfyy
Copy link

powfyy commented Apr 11, 2024

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()
      );
@avaudo
Copy link

avaudo commented Apr 12, 2024

I am running into the same exact issue but with the .Net library. I have created the issue here:

elastic/elasticsearch-net#8125

@l-trotta
Copy link
Contributor

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.

@l-trotta l-trotta added the Area: Specification Related to the API spec used to generate client code label Apr 12, 2024
@l-trotta
Copy link
Contributor

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))
                        )))));

@powfyy
Copy link
Author

powfyy commented Apr 12, 2024

Thank you for your responsiveness <3

@avaudo
Copy link

avaudo commented Apr 12, 2024

Thank you. Do you know about how long this would take to be released?

@l-trotta
Copy link
Contributor

That depends on the client, but it's usually the next version after the api spec has been fixed

@l-trotta
Copy link
Contributor

fixed in 8.13.4!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code
Projects
None yet
Development

No branches or pull requests

3 participants