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)
This commit is contained in:
Wang Qi
2026-04-30 14:52:43 +08:00
committed by GitHub
parent 45d77dc778
commit f45ce00347
2 changed files with 4 additions and 0 deletions

View File

@@ -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})