From 9944ad7f5faa9fc70beae19c0b9d44abebeb6af6 Mon Sep 17 00:00:00 2001 From: caiyueliang <393900414@qq.com> Date: Sat, 15 Jun 2024 08:13:11 +0800 Subject: [PATCH] community: 'Solve the issue where the _search function in ElasticsearchStore supports passing a query_vector parameter, but the parameter does not take effect. (#21532) **Issue:** When using the similarity_search_with_score function in ElasticsearchStore, I expected to pass in the query_vector that I have already obtained. I noticed that the _search function does support the query_vector parameter, but it seems to be ineffective. I am attempting to resolve this issue. Co-authored-by: Isaac Francisco <78627776+isahers1@users.noreply.github.com> --- .../community/langchain_community/vectorstores/elasticsearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/elasticsearch.py b/libs/community/langchain_community/vectorstores/elasticsearch.py index 09f818ff05e..2b517a98799 100644 --- a/libs/community/langchain_community/vectorstores/elasticsearch.py +++ b/libs/community/langchain_community/vectorstores/elasticsearch.py @@ -805,7 +805,7 @@ class ElasticsearchStore(VectorStore): if self.query_field not in fields: fields.append(self.query_field) - if self.embedding and query is not None: + if self.embedding and query is not None and query_vector is None: query_vector = self.embedding.embed_query(query) query_body = self.strategy.query(