From f45ce00347f56052a8690e4380b1b812a8cc509b Mon Sep 17 00:00:00 2001 From: Wang Qi Date: Thu, 30 Apr 2026 14:52:43 +0800 Subject: [PATCH] Not allow to sort by id (#14526) ### What problem does this PR solve? id as "text", not a "keyword", order by it will cause error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- memory/utils/es_conn.py | 2 ++ rag/utils/es_conn.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/memory/utils/es_conn.py b/memory/utils/es_conn.py index afa06a169a..15a360e340 100644 --- a/memory/utils/es_conn.py +++ b/memory/utils/es_conn.py @@ -206,6 +206,8 @@ class ESConnection(ESConnectionBase): order = "asc" if order == 0 else "desc" if field.endswith("_int") or field.endswith("_flt"): order_info = {"order": order, "unmapped_type": "float"} + elif field == "id": + continue # id as "text", not a "keyword", order by it will cause error else: order_info = {"order": order, "unmapped_type": "text"} orders.append({field: order_info}) diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py index 3e0ab369f5..cb4c3d8438 100644 --- a/rag/utils/es_conn.py +++ b/rag/utils/es_conn.py @@ -244,6 +244,8 @@ class ESConnection(ESConnectionBase): "mode": "avg", "numeric_type": "double"} elif field.endswith("_int") or field.endswith("_flt"): order_info = {"order": order, "unmapped_type": "float"} + elif field == "id": + continue # id as "text", not a "keyword", order by it will cause error else: order_info = {"order": order, "unmapped_type": "text"} orders.append({field: order_info})