From 09c5be6146df16ac1c7b0e608dedb75505ca432c Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Tue, 26 Nov 2024 17:47:19 +0800 Subject: [PATCH] Fix es get NotFoundError --- rag/utils/es_conn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py index 0630f84136e..a5b266b8f27 100644 --- a/rag/utils/es_conn.py +++ b/rag/utils/es_conn.py @@ -215,11 +215,11 @@ def get(self, chunkId: str, indexName: str, knowledgebaseIds: list[str]) -> dict id=chunkId, source=True, ) if str(res.get("timed_out", "")).lower() == "true": raise Exception("Es Timeout.") - if not res.get("found"): - return None chunk = res["_source"] chunk["id"] = chunkId return chunk + except NotFoundError: + return None except Exception as e: logging.exception(f"ESConnection.get({chunkId}) got exception") if str(e).find("Timeout") > 0: