Qdrant - Vector Database
Filtering: Filter API
Vector search finds what's semantically close. But 'show me only published English articles created after 2024 with price under 1000' - that's a filter. Together they deliver precise and intelligent search.
- **E-commerce:** 'red sneakers' (vector) + size=42 AND brand='Nike' AND in_stock=true (filter)
- **Knowledge base:** 'how to set up nginx' (vector) + category='devops' AND language='en' (filter)
- **Geolocation:** 'Italian restaurant' (vector) + geo_radius=2km AND rating>4 AND open_now=true (filter)
Предварительные знания
Filter structure: must / should / must_not
**Filter API** in Qdrant is a way to restrict search by payload. It works like SQL WHERE, but for vector search. Filtering happens BEFORE or AFTER the vector search - Qdrant picks the strategy automatically.
| Operator | SQL equivalent | Logic |
|---|---|---|
| must | AND | All conditions must be satisfied |
| should | OR | At least one condition must be satisfied |
| must_not | NOT | No conditions may be satisfied |
| min_should | OR with minimum | At least N of M conditions must be satisfied |
**Performance:** filtering is fast ONLY when a payload index exists. Without an index, Qdrant checks every point - O(N). With an index - O(log N). Always create indexes for fields you filter by (lesson qd-08).