diff --git a/elasticsearch/helpers/vectorstore/_async/vectorstore.py b/elasticsearch/helpers/vectorstore/_async/vectorstore.py index 3b8c1e9e9..b642f8753 100644 --- a/elasticsearch/helpers/vectorstore/_async/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_async/vectorstore.py @@ -83,10 +83,11 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field"): + if ( + hasattr(retrieval_strategy, "text_field") + and retrieval_strategy.text_field is None + ): retrieval_strategy.text_field = text_field - if hasattr(retrieval_strategy, "vector_field"): - retrieval_strategy.vector_field = vector_field self.client = client self.index = index diff --git a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py index 3c4a0d51a..40772d99c 100644 --- a/elasticsearch/helpers/vectorstore/_sync/vectorstore.py +++ b/elasticsearch/helpers/vectorstore/_sync/vectorstore.py @@ -80,10 +80,11 @@ def __init__( # client.options preserves existing (non-user-agent) headers. client = client.options(headers={"User-Agent": user_agent}) - if hasattr(retrieval_strategy, "text_field"): + if ( + hasattr(retrieval_strategy, "text_field") + and retrieval_strategy.text_field is None + ): retrieval_strategy.text_field = text_field - if hasattr(retrieval_strategy, "vector_field"): - retrieval_strategy.vector_field = vector_field self.client = client self.index = index