fix: Bugfix/elasticsearch store read config dict (#2577)

This commit is contained in:
geebytes 2025-04-10 07:36:43 +08:00 committed by GitHub
parent ae4112cf35
commit 90e22ac136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -167,7 +167,7 @@ class ElasticStore(VectorStoreBase):
self._vector_store_config = vector_store_config
connect_kwargs = {}
elasticsearch_vector_config = vector_store_config.dict()
elasticsearch_vector_config = vector_store_config.to_dict()
self.uri = os.getenv(
"ELASTICSEARCH_URL", "localhost"
) or elasticsearch_vector_config.get("uri")
@ -224,7 +224,10 @@ class ElasticStore(VectorStoreBase):
"`pip install elasticsearch`."
)
try:
if self.username != "" and self.password != "":
# The condition should check for both None and empty string ("")
# When reading non-existent keys from env/config files,
# the value will be None
if self.username and self.password:
self.es_client_python = Elasticsearch(
f"http://{self.uri}:{self.port}",
basic_auth=(self.username, self.password),
@ -248,7 +251,7 @@ class ElasticStore(VectorStoreBase):
# create es index
try:
if self.username != "" and self.password != "":
if self.username and self.password:
self.db_init = ElasticsearchStore(
es_url=f"http://{self.uri}:{self.port}",
index_name=self.index_name,