From efe6d23d61cece4431feec0af52698787aec811c Mon Sep 17 00:00:00 2001 From: Lynn Date: Sat, 9 May 2026 17:41:08 +0800 Subject: [PATCH] Fix: handle id as keyword (#14729) ### What problem does this PR solve? Update mapping.json to treat id as a keyword. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- conf/mapping.json | 2 +- memory/utils/es_conn.py | 2 +- rag/utils/es_conn.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/mapping.json b/conf/mapping.json index f32acb02bc..495f7c7763 100644 --- a/conf/mapping.json +++ b/conf/mapping.json @@ -92,7 +92,7 @@ { "kwd": { "match_pattern": "regex", - "match": "^(.*_(kwd|id|ids|uid|uids)|uid)$", + "match": "^(.*_(kwd|id|ids|uid|uids)|uid|id)$", "mapping": { "type": "keyword", "similarity": "boolean", diff --git a/memory/utils/es_conn.py b/memory/utils/es_conn.py index 15a360e340..60eda59f62 100644 --- a/memory/utils/es_conn.py +++ b/memory/utils/es_conn.py @@ -209,7 +209,7 @@ class ESConnection(ESConnectionBase): elif field == "id": continue # id as "text", not a "keyword", order by it will cause error else: - order_info = {"order": order, "unmapped_type": "text"} + order_info = {"order": order, "unmapped_type": "keyword"} orders.append({field: order_info}) s = s.sort(*orders) diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py index cb4c3d8438..51356befad 100644 --- a/rag/utils/es_conn.py +++ b/rag/utils/es_conn.py @@ -247,7 +247,7 @@ class ESConnection(ESConnectionBase): elif field == "id": continue # id as "text", not a "keyword", order by it will cause error else: - order_info = {"order": order, "unmapped_type": "text"} + order_info = {"order": order, "unmapped_type": "keyword"} orders.append({field: order_info}) s = s.sort(*orders) if agg_fields: