Add logger in Opensearch (#2957)
This commit is contained in:
@@ -83,19 +83,19 @@ class OpenSearchDB(VectorStoreBase):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.warning(f"Creating index {name}, it might take 1-2 minutes...")
|
||||||
if not self.client.indices.exists(index=name):
|
if not self.client.indices.exists(index=name):
|
||||||
self.client.indices.create(index=name, body=index_settings)
|
self.client.indices.create(index=name, body=index_settings)
|
||||||
logger.info(f"Created index {name}")
|
|
||||||
|
|
||||||
# Wait for index to be ready
|
# Wait for index to be ready
|
||||||
max_retries = 60 # 60 seconds timeout
|
max_retries = 180 # 3 minutes timeout
|
||||||
retry_count = 0
|
retry_count = 0
|
||||||
while retry_count < max_retries:
|
while retry_count < max_retries:
|
||||||
try:
|
try:
|
||||||
# Check if index is ready by attempting a simple search
|
# Check if index is ready by attempting a simple search
|
||||||
self.client.search(index=name, body={"query": {"match_all": {}}})
|
self.client.search(index=name, body={"query": {"match_all": {}}})
|
||||||
logger.info(f"Index {name} is ready")
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
logger.info(f"Index {name} is ready")
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
retry_count += 1
|
retry_count += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user