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

Error When Creating Index with SynonymsSet in Elasticsearch #862

Closed
Roy-onout opened this issue Aug 12, 2024 · 0 comments
Closed

Error When Creating Index with SynonymsSet in Elasticsearch #862

Roy-onout opened this issue Aug 12, 2024 · 0 comments

Comments

@Roy-onout
Copy link

Roy-onout commented Aug 12, 2024

Java API client version

8.15.0

Java version

17

Elasticsearch Version

8.15.0

Problem description

I'm encountering an error while trying to create an Elasticsearch index using a custom synonym filter. The error occurs when setting up the index with a synonymsSet for the synonymGraph filter. Below is the Kotlin code snippet used for creating the index:

        val createIndexRequest = CreateIndexRequest.Builder()
            .index(indexName)
            .settings(
                IndexSettings.Builder()
                    .analysis {
                        it.filter("synonyms_filter") { filter ->
                            filter.definition {
                                it.synonymGraph { synonym ->
                                    synonym.synonymsSet("os_synonyms_sample")
                                }
                                it
                            }
                        }
                        it.analyzer(EsConstants.SYNONYM_ANALYZER) { analyzer ->
                            analyzer.custom { custom ->
                                custom.filter("synonyms_filter")
                                custom.tokenizer(EsConstants.NORI_TOKENIZER)
                                custom
                            }
                        }
                        it
                    }.build()
            )
            .mappings { mapping ->
                EsProduct.mappings(mapping)
            }.build()

The following error is encountered during execution:

Handler dispatch failed: java.lang.NoSuchMethodError: 'co.elastic.clients.elasticsearch._types.analysis.SynonymGraphTokenFilter$Builder co.elastic.clients.elasticsearch._types.analysis.SynonymGraphTokenFilter$Builder.synonymsSet(java.lang.String)'
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1104) ~[spring-webmvc-6.1.5.jar:6.1.5]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) ~[spring-webmvc-6.1.5.jar:6.1.5]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-6.1.5.jar:6.1.5]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.1.5.jar:6.1.5]

Steps to Reproduce
Create a synonyms set using the /_synonyms API with the name os_synonyms_sample.
Attempt to create an index with the above Kotlin code, which includes a custom analyzer and synonym graph filter.

Expected Behavior
The index should be created successfully with the synonym filter applied using the specified synonym set.

Actual Behavior
A NoSuchMethodError is thrown, indicating that the synonymsSet method is not found in the SynonymGraphTokenFilter$Builder class.

@Roy-onout Roy-onout changed the title java.lang.NoSuchMethodError: 'co.elastic.clients.elasticsearch._types.analysis.SynonymGraphTokenFilter$Builder co.elastic.clients.elasticsearch._types.analysis.SynonymGraphTokenFilter$Builder.synonymsSet(java.lang.String) Error When Creating Index with SynonymsSet in Elasticsearch Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant