From dd81c309766c4b3976272523fab06a9853d62522 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Wed, 19 Mar 2025 11:25:11 +0800 Subject: [PATCH] Fix: tag_feas deletion error. (#6257) ### What problem does this PR solve? #6218 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/utils/es_conn.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py index 9cba60899..62c6cf0da 100644 --- a/rag/utils/es_conn.py +++ b/rag/utils/es_conn.py @@ -322,12 +322,19 @@ class ESConnection(DocStoreConnection): # update specific single document chunkId = condition["id"] for i in range(ATTEMPT_TIME): + for k in doc.keys(): + if "feas" != k.split("_")[-1]: + continue + try: + self.es.update(index=indexName, id=chunkId, script=f"ctx._source.remove(\"{k}\");") + except Exception: + logger.exception(f"ESConnection.update(index={indexName}, id={chunkId}, doc={json.dumps(condition, ensure_ascii=False)}) got exception") try: self.es.update(index=indexName, id=chunkId, doc=doc) return True except Exception as e: logger.exception( - f"ESConnection.update(index={indexName}, id={id}, doc={json.dumps(condition, ensure_ascii=False)}) got exception") + f"ESConnection.update(index={indexName}, id={chunkId}, doc={json.dumps(condition, ensure_ascii=False)}) got exception") if re.search(r"(timeout|connection)", str(e).lower()): continue break