-
Notifications
You must be signed in to change notification settings - Fork 995
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
When version 1.0.0-M5 uses elastic as vectorstore, the query will report that the method cannot be found #2220
Comments
Is there a solution? I also encountered this problem. |
modify pom.xml as following:
and add following:
|
에서
사용하면 spring ai 에서는 에러가 안 납니다. |
으로 낮추면 그런 에러가 없습니다. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug description
When I use es8.15.5 as the vector storage of rag, and then use the following to conduct a local conversation, the following error is reported
java.lang.NoSuchMethodError: 'co.elastic.clients.elasticsearch._types.KnnSearch$Builder co.elastic.clients.elasticsearch._types.KnnSearch$Builder.k(java.lang.Long)'
Environment
spring-ai version: 1.0.0-M5
os: windows 10
jdk: 21
es:8.15.5(8.17.1 as same)
Through the java stack, I have found the cause of the problem. It is because 1.0.0-M5 integrates the elasticsearch-java.jar and elasticsearch-rest-client.jar of 8.15.5 by default. This version no longer has the long version of the .k method. Only 8.13.4 and previous versions have it.
the root cause as following:
when I use
String content = chatClient.prompt().user(message).call().content();
will invoke method asorg.springframework.ai.vectorstore.elasticsearch.ElasticsearchVectorStore#doSimilaritySearch
SearchResponse res = this.elasticsearchClient.search(
sr -> sr.index(this.options.getIndexName())
.knn(knn -> knn.queryVector(EmbeddingUtils.toList(vectors))
.similarity(finalThreshold)
.k((long) searchRequest.getTopK())
.field("embedding")
.numCandidates((long) (1.5 * searchRequest.getTopK()))
.filter(fl -> fl.queryString(
qs -> qs.query(getElasticsearchQueryString(searchRequest.getFilterExpression()))))),
Document.class);
Versions elasticsearch-java-8.13.4.jar .k() function prototype as following,
co.elastic.clients.elasticsearch._types.KnnSearch.Builder#k
public final Builder k(@nullable Long value) {
this.k = value;
return this;
}
but 8.14 and higher prototype as:
co.elastic.clients.elasticsearch._types.KnnSearch.Builder#k
public final Builder k(@nullable Integer value) {
this.k = value;
return this;
}
Therefore, I think it is caused by the mismatch between elasticsearch-java.jar and elasticsearch-rest-client.jar versions. Please refer to whether the version should be lowered or modified by modifying the org.springframework.ai.vectorstore.elasticsearch.ElasticsearchVectorStore#doSimilaritySearch function.
Please forgive me if the above is incorrect.
The text was updated successfully, but these errors were encountered: