From 99afc1b4f84314fa699da83a34db39e62bc625a8 Mon Sep 17 00:00:00 2001 From: Shilong Dai Date: Mon, 23 Oct 2023 14:08:55 -0500 Subject: [PATCH] Fixed hardcoded "vector" and replaced with vector_query_field variable (#12126) - **Description:** In the max_marginal_relevance_search function of the ElasticsearchStore vector store, the name of the field corresponding to the vector embedding of the document is hard coded in the delete statement that drops the field from the document metadata. This results in an exception if the vector embedding field is customized. This PR changes the hard-coded "vector" into the vector_query_field variable. - **Issue:** None - **Dependencies:** None - **Tag maintainer:** @hwchase17 Co-authored-by: Shilong Dai --- libs/langchain/langchain/vectorstores/elasticsearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/vectorstores/elasticsearch.py b/libs/langchain/langchain/vectorstores/elasticsearch.py index e1eed36f3c9..4bf2d4c47e5 100644 --- a/libs/langchain/langchain/vectorstores/elasticsearch.py +++ b/libs/langchain/langchain/vectorstores/elasticsearch.py @@ -662,7 +662,7 @@ class ElasticsearchStore(VectorStore): if remove_vector_query_field_from_metadata: for doc in selected_docs: - del doc.metadata["vector"] + del doc.metadata[self.vector_query_field] return selected_docs