mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-24 12:45:45 +00:00
fix: Bugfix/elasticsearch store read config dict (#2577)
This commit is contained in:
parent
ae4112cf35
commit
90e22ac136
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user