Fix 500 error: replace datetime_range with range in Qdrant filter
qdrant-client 1.15.1 does not support datetime_range in FieldCondition. Use models.Range with string comparison (same as Lotus reference). Also wrap date filter in try-except to prevent crash on bad date format. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4ecba7d35a
commit
19fec2361e
1 changed files with 14 additions and 8 deletions
|
|
@ -18,15 +18,21 @@ def _build_filter(question: Question) -> models.Filter | None:
|
||||||
must_conditions: list[models.Condition] = []
|
must_conditions: list[models.Condition] = []
|
||||||
|
|
||||||
if question.date_range:
|
if question.date_range:
|
||||||
|
try:
|
||||||
|
must_conditions.append(
|
||||||
|
models.FieldCondition(
|
||||||
|
key="metadata.end",
|
||||||
|
range=models.Range(gte=question.date_range.from_),
|
||||||
|
)
|
||||||
|
)
|
||||||
must_conditions.append(
|
must_conditions.append(
|
||||||
models.FieldCondition(
|
models.FieldCondition(
|
||||||
key="metadata.start",
|
key="metadata.start",
|
||||||
datetime_range=models.DatetimeRange(
|
range=models.Range(lte=question.date_range.to),
|
||||||
gte=question.date_range.from_,
|
|
||||||
lte=question.date_range.to,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Date filter failed: %s", e)
|
||||||
|
|
||||||
if question.asker:
|
if question.asker:
|
||||||
must_conditions.append(
|
must_conditions.append(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue