Fix: allow search id or _id (#14356)

### What problem does this PR solve?

Allow search id or _id when using es as doc_engine.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Lynn
2026-04-24 21:38:19 +08:00
committed by GitHub
parent 25089600d0
commit e22cf333ed

View File

@@ -170,6 +170,16 @@ class ESConnection(ESConnectionBase):
bool_query.filter.append(
Q("bool", must_not=Q("range", available_int={"lt": 1})))
continue
if k == "id":
if not v:
continue
if isinstance(v, list):
bool_query.filter.append(
Q("bool", should=[Q("terms", id=v), Q("terms", _id=v)], minimum_should_match=1))
elif isinstance(v, str) or isinstance(v, int):
bool_query.filter.append(
Q("bool", should=[Q("term", id=v), Q("term", _id=v)], minimum_should_match=1))
continue
if not v:
continue
if isinstance(v, list):