fix(qdrant): raise ValueError for unsupported filter operators
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7e0968bbc8
commit
fb430b1a32
@@ -180,8 +180,11 @@ class Qdrant(VectorStoreBase):
|
|||||||
text = value.get("contains") or value.get("icontains")
|
text = value.get("contains") or value.get("icontains")
|
||||||
return FieldCondition(key=key, match=MatchText(text=text))
|
return FieldCondition(key=key, match=MatchText(text=text))
|
||||||
else:
|
else:
|
||||||
# Unknown operator — fall back to equality
|
supported = {"eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "icontains"}
|
||||||
return FieldCondition(key=key, match=MatchValue(value=value))
|
raise ValueError(
|
||||||
|
f"Unsupported filter operator(s) for field '{key}': {ops}. "
|
||||||
|
f"Supported operators: {supported}"
|
||||||
|
)
|
||||||
|
|
||||||
def _create_filter(self, filters: dict) -> Filter:
|
def _create_filter(self, filters: dict) -> Filter:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -535,5 +535,11 @@ class TestQdrantEnhancedFilters(unittest.TestCase):
|
|||||||
self.assertEqual(result.must[0].range.gte, 5)
|
self.assertEqual(result.must[0].range.gte, 5)
|
||||||
self.assertEqual(result.must[0].range.lte, 10)
|
self.assertEqual(result.must[0].range.lte, 10)
|
||||||
|
|
||||||
|
def test_unknown_operator_raises_error(self):
|
||||||
|
"""Unknown operator dict should raise ValueError, not ValidationError."""
|
||||||
|
with self.assertRaises(ValueError) as ctx:
|
||||||
|
self.qdrant._build_field_condition("field", {"unknown_op": "foo"})
|
||||||
|
self.assertIn("Unsupported", str(ctx.exception))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
del self.qdrant
|
del self.qdrant
|
||||||
|
|||||||
Reference in New Issue
Block a user