fix(qdrant): raise ValueError for unsupported filter operators
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -180,8 +180,11 @@ class Qdrant(VectorStoreBase):
|
||||
text = value.get("contains") or value.get("icontains")
|
||||
return FieldCondition(key=key, match=MatchText(text=text))
|
||||
else:
|
||||
# Unknown operator — fall back to equality
|
||||
return FieldCondition(key=key, match=MatchValue(value=value))
|
||||
supported = {"eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "contains", "icontains"}
|
||||
raise ValueError(
|
||||
f"Unsupported filter operator(s) for field '{key}': {ops}. "
|
||||
f"Supported operators: {supported}"
|
||||
)
|
||||
|
||||
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.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):
|
||||
del self.qdrant
|
||||
|
||||
Reference in New Issue
Block a user