@mhalder/qdrant-mcp-server 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.env.example +92 -0
  2. package/.github/workflows/ci.yml +61 -0
  3. package/.github/workflows/claude-code-review.yml +57 -0
  4. package/.github/workflows/claude.yml +50 -0
  5. package/.github/workflows/release.yml +52 -0
  6. package/.husky/commit-msg +1 -0
  7. package/.husky/pre-commit +1 -0
  8. package/.releaserc.json +59 -0
  9. package/.yamlfmt +4 -0
  10. package/CHANGELOG.md +73 -0
  11. package/CONTRIBUTING.md +176 -0
  12. package/LICENSE +21 -0
  13. package/README.md +714 -0
  14. package/build/embeddings/base.d.ts +23 -0
  15. package/build/embeddings/base.d.ts.map +1 -0
  16. package/build/embeddings/base.js +2 -0
  17. package/build/embeddings/base.js.map +1 -0
  18. package/build/embeddings/cohere.d.ts +17 -0
  19. package/build/embeddings/cohere.d.ts.map +1 -0
  20. package/build/embeddings/cohere.js +102 -0
  21. package/build/embeddings/cohere.js.map +1 -0
  22. package/build/embeddings/cohere.test.d.ts +2 -0
  23. package/build/embeddings/cohere.test.d.ts.map +1 -0
  24. package/build/embeddings/cohere.test.js +279 -0
  25. package/build/embeddings/cohere.test.js.map +1 -0
  26. package/build/embeddings/factory.d.ts +10 -0
  27. package/build/embeddings/factory.d.ts.map +1 -0
  28. package/build/embeddings/factory.js +98 -0
  29. package/build/embeddings/factory.js.map +1 -0
  30. package/build/embeddings/factory.test.d.ts +2 -0
  31. package/build/embeddings/factory.test.d.ts.map +1 -0
  32. package/build/embeddings/factory.test.js +329 -0
  33. package/build/embeddings/factory.test.js.map +1 -0
  34. package/build/embeddings/ollama.d.ts +18 -0
  35. package/build/embeddings/ollama.d.ts.map +1 -0
  36. package/build/embeddings/ollama.js +135 -0
  37. package/build/embeddings/ollama.js.map +1 -0
  38. package/build/embeddings/ollama.test.d.ts +2 -0
  39. package/build/embeddings/ollama.test.d.ts.map +1 -0
  40. package/build/embeddings/ollama.test.js +399 -0
  41. package/build/embeddings/ollama.test.js.map +1 -0
  42. package/build/embeddings/openai.d.ts +16 -0
  43. package/build/embeddings/openai.d.ts.map +1 -0
  44. package/build/embeddings/openai.js +108 -0
  45. package/build/embeddings/openai.js.map +1 -0
  46. package/build/embeddings/openai.test.d.ts +2 -0
  47. package/build/embeddings/openai.test.d.ts.map +1 -0
  48. package/build/embeddings/openai.test.js +283 -0
  49. package/build/embeddings/openai.test.js.map +1 -0
  50. package/build/embeddings/voyage.d.ts +19 -0
  51. package/build/embeddings/voyage.d.ts.map +1 -0
  52. package/build/embeddings/voyage.js +113 -0
  53. package/build/embeddings/voyage.js.map +1 -0
  54. package/build/embeddings/voyage.test.d.ts +2 -0
  55. package/build/embeddings/voyage.test.d.ts.map +1 -0
  56. package/build/embeddings/voyage.test.js +371 -0
  57. package/build/embeddings/voyage.test.js.map +1 -0
  58. package/build/index.d.ts +3 -0
  59. package/build/index.d.ts.map +1 -0
  60. package/build/index.js +534 -0
  61. package/build/index.js.map +1 -0
  62. package/build/index.test.d.ts +2 -0
  63. package/build/index.test.d.ts.map +1 -0
  64. package/build/index.test.js +241 -0
  65. package/build/index.test.js.map +1 -0
  66. package/build/qdrant/client.d.ts +37 -0
  67. package/build/qdrant/client.d.ts.map +1 -0
  68. package/build/qdrant/client.js +142 -0
  69. package/build/qdrant/client.js.map +1 -0
  70. package/build/qdrant/client.test.d.ts +2 -0
  71. package/build/qdrant/client.test.d.ts.map +1 -0
  72. package/build/qdrant/client.test.js +340 -0
  73. package/build/qdrant/client.test.js.map +1 -0
  74. package/commitlint.config.js +25 -0
  75. package/docker-compose.yml +22 -0
  76. package/docs/test_report.md +259 -0
  77. package/examples/README.md +315 -0
  78. package/examples/basic/README.md +111 -0
  79. package/examples/filters/README.md +262 -0
  80. package/examples/knowledge-base/README.md +207 -0
  81. package/examples/rate-limiting/README.md +376 -0
  82. package/package.json +59 -0
  83. package/scripts/verify-providers.js +238 -0
  84. package/src/embeddings/base.ts +25 -0
  85. package/src/embeddings/cohere.test.ts +408 -0
  86. package/src/embeddings/cohere.ts +152 -0
  87. package/src/embeddings/factory.test.ts +453 -0
  88. package/src/embeddings/factory.ts +163 -0
  89. package/src/embeddings/ollama.test.ts +543 -0
  90. package/src/embeddings/ollama.ts +196 -0
  91. package/src/embeddings/openai.test.ts +402 -0
  92. package/src/embeddings/openai.ts +158 -0
  93. package/src/embeddings/voyage.test.ts +520 -0
  94. package/src/embeddings/voyage.ts +168 -0
  95. package/src/index.test.ts +304 -0
  96. package/src/index.ts +614 -0
  97. package/src/qdrant/client.test.ts +456 -0
  98. package/src/qdrant/client.ts +195 -0
  99. package/tsconfig.json +19 -0
  100. package/vitest.config.ts +37 -0
@@ -0,0 +1,315 @@
1
+ # Qdrant MCP Server Examples
2
+
3
+ Practical examples demonstrating how to use the Qdrant MCP Server for various use cases.
4
+
5
+ ## Quick Start
6
+
7
+ Before running these examples, ensure you have:
8
+
9
+ 1. **Qdrant and Ollama running**: `docker compose up -d`
10
+ 2. **Ollama model pulled**: `docker exec ollama ollama pull nomic-embed-text`
11
+ 3. **MCP Server configured**: See main [README](../README.md) for setup
12
+ 4. **Optional - Alternative providers**: Configure API key for OpenAI, Cohere, or Voyage AI if not using Ollama
13
+
14
+ ## Available Examples
15
+
16
+ ### 🎯 [Basic Usage](./basic/)
17
+
18
+ **Start here if you're new to the MCP server.**
19
+
20
+ Learn fundamental operations:
21
+
22
+ - Creating collections
23
+ - Adding documents
24
+ - Performing semantic searches
25
+ - Managing resources
26
+
27
+ **Time:** 5-10 minutes
28
+ **Difficulty:** Beginner
29
+
30
+ ---
31
+
32
+ ### ⚡ [Rate Limiting](./rate-limiting/)
33
+
34
+ **Understand automatic rate limit handling for batch operations.**
35
+
36
+ Topics covered:
37
+
38
+ - Configuring rate limits for your embedding provider
39
+ - Batch document processing
40
+ - Exponential backoff retry behavior
41
+ - Monitoring and troubleshooting
42
+
43
+ **Use cases:**
44
+
45
+ - High-volume document ingestion
46
+ - Free tier optimization
47
+ - Production reliability
48
+ - Batch operations
49
+
50
+ **Time:** 10-15 minutes
51
+ **Difficulty:** Beginner to Intermediate
52
+
53
+ ---
54
+
55
+ ### 📚 [Knowledge Base](./knowledge-base/)
56
+
57
+ **Build a searchable documentation system with metadata.**
58
+
59
+ Topics covered:
60
+
61
+ - Structuring documents with rich metadata
62
+ - Organizing content by team, topic, and difficulty
63
+ - Filtering searches by categories
64
+ - Scaling and maintenance strategies
65
+
66
+ **Use cases:**
67
+
68
+ - Company documentation
69
+ - Help centers
70
+ - Internal wikis
71
+ - Educational content
72
+
73
+ **Time:** 15-20 minutes
74
+ **Difficulty:** Intermediate
75
+
76
+ ---
77
+
78
+ ### 🔍 [Advanced Filtering](./filters/)
79
+
80
+ **Master complex search filters with boolean logic.**
81
+
82
+ Learn to:
83
+
84
+ - Combine multiple filter conditions (AND, OR, NOT)
85
+ - Filter by categories, prices, ratings, and availability
86
+ - Use range filters for numeric values
87
+ - Build sophisticated e-commerce searches
88
+
89
+ **Use cases:**
90
+
91
+ - Product catalogs
92
+ - Inventory management
93
+ - Content filtering
94
+ - Access control
95
+
96
+ **Time:** 20-30 minutes
97
+ **Difficulty:** Intermediate to Advanced
98
+
99
+ ---
100
+
101
+ ## Example Structure
102
+
103
+ Each example includes:
104
+
105
+ - **README.md** - Step-by-step tutorial with commands
106
+ - **Sample data** - Documents with metadata to copy/paste
107
+ - **Search examples** - Real queries you can try
108
+ - **Best practices** - Tips and recommendations
109
+
110
+ ## How to Use These Examples
111
+
112
+ ### Option 1: Interactive with Claude Code
113
+
114
+ Copy commands directly into Claude Code:
115
+
116
+ ```
117
+ Create a collection named "test"
118
+ Add documents...
119
+ Search for...
120
+ ```
121
+
122
+ ### Option 2: Understand the Concepts
123
+
124
+ Read through examples to understand:
125
+
126
+ - Metadata design patterns
127
+ - Filter syntax and structure
128
+ - Search result ranking
129
+ - Collection organization
130
+
131
+ ### Option 3: Adapt for Your Use Case
132
+
133
+ Use examples as templates:
134
+
135
+ 1. Start with the closest matching example
136
+ 2. Modify metadata structure for your data
137
+ 3. Adjust search queries for your needs
138
+ 4. Scale up with your own documents
139
+
140
+ ## Learning Path
141
+
142
+ ```
143
+ ┌─────────────┐
144
+ │ Basic │ Start here - core operations
145
+ └──────┬──────┘
146
+
147
+ ├──────────┐
148
+ │ ▼
149
+ │ ┌─────────────┐
150
+ │ │ Rate │ Learn automatic rate limit handling
151
+ │ │ Limiting │ (especially for batch operations)
152
+ │ └─────────────┘
153
+
154
+
155
+ ┌─────────────┐
156
+ │ Knowledge │ Add structure with metadata
157
+ │ Base │
158
+ └──────┬──────┘
159
+
160
+
161
+ ┌─────────────┐
162
+ │ Advanced │ Master complex filtering
163
+ │ Filtering │
164
+ └─────────────┘
165
+ ```
166
+
167
+ ## Common Patterns
168
+
169
+ ### Pattern 1: Content Organization
170
+
171
+ ```
172
+ metadata: {
173
+ "category": "type",
174
+ "topic": "subject",
175
+ "author": "creator",
176
+ "date": "2024-01-15"
177
+ }
178
+ ```
179
+
180
+ Good for: Blogs, documentation, articles
181
+
182
+ ### Pattern 2: E-commerce
183
+
184
+ ```
185
+ metadata: {
186
+ "category": "electronics",
187
+ "price": 99.99,
188
+ "rating": 4.5,
189
+ "in_stock": true,
190
+ "brand": "BrandName"
191
+ }
192
+ ```
193
+
194
+ Good for: Product catalogs, inventory systems
195
+
196
+ ### Pattern 3: Access Control
197
+
198
+ ```
199
+ metadata: {
200
+ "visibility": "internal",
201
+ "department": "engineering",
202
+ "sensitivity": "confidential"
203
+ }
204
+ ```
205
+
206
+ Good for: Enterprise knowledge bases, secure documents
207
+
208
+ ### Pattern 4: Temporal Data
209
+
210
+ ```
211
+ metadata: {
212
+ "created_at": "2024-01-15",
213
+ "updated_at": "2024-03-20",
214
+ "status": "published",
215
+ "version": "2.1"
216
+ }
217
+ ```
218
+
219
+ Good for: Versioned content, time-series data
220
+
221
+ ## Tips for All Examples
222
+
223
+ ### 1. Start Small
224
+
225
+ Test with 5-10 documents before scaling to thousands.
226
+
227
+ ### 2. Design Metadata First
228
+
229
+ Plan your metadata structure before adding documents:
230
+
231
+ - What fields do you need?
232
+ - What will you filter by?
233
+ - What types (string, number, boolean)?
234
+
235
+ ### 3. Use Consistent IDs
236
+
237
+ Choose an ID scheme:
238
+
239
+ - Sequential: `1`, `2`, `3`
240
+ - Prefixed: `doc-001`, `doc-002`
241
+ - Semantic: `eng-api-auth`, `sales-pricing`
242
+ - UUIDs: Generated automatically
243
+
244
+ ### 4. Test Searches
245
+
246
+ Try various queries to validate:
247
+
248
+ - Semantic matching works correctly
249
+ - Filters return expected results
250
+ - Result ranking makes sense
251
+
252
+ ### 5. Clean Up
253
+
254
+ Delete test collections when done:
255
+
256
+ ```
257
+ Delete collection "collection-name"
258
+ ```
259
+
260
+ ## Troubleshooting
261
+
262
+ ### Collection Already Exists
263
+
264
+ ```
265
+ Delete collection "name"
266
+ Create a collection named "name"
267
+ ```
268
+
269
+ ### No Search Results
270
+
271
+ - Check collection has documents: `Get info about "collection-name"`
272
+ - Verify filter syntax matches metadata exactly
273
+ - Try search without filters first
274
+
275
+ ### Unexpected Results
276
+
277
+ - Check document metadata structure
278
+ - Validate filter conditions
279
+ - Review semantic similarity scores
280
+
281
+ ### Error Messages
282
+
283
+ - **"Collection not found"**: Create the collection first
284
+ - **"Bad Request"**: Check filter JSON syntax
285
+ - **"API error"**: Verify your embedding provider API key and credits
286
+
287
+ ## Next Steps
288
+
289
+ After completing these examples:
290
+
291
+ 1. **Read the main [README](../README.md)** - Full tool documentation
292
+ 2. **Explore your own data** - Apply concepts to real use cases
293
+ 3. **Check out advanced features** - Quantization, hybrid search (future)
294
+ 4. **Join the community** - Contribute examples and improvements
295
+
296
+ ## Contributing
297
+
298
+ Have a great example to share? Please open a PR!
299
+
300
+ We're especially interested in:
301
+
302
+ - Domain-specific use cases (legal, medical, finance)
303
+ - Integration examples (RAG pipelines, chatbots)
304
+ - Performance optimization patterns
305
+ - Novel metadata structures
306
+
307
+ ## Additional Resources
308
+
309
+ - [Qdrant Documentation](https://qdrant.tech/documentation/)
310
+ - [OpenAI Embeddings Guide](https://platform.openai.com/docs/guides/embeddings)
311
+ - [Cohere Embeddings Guide](https://docs.cohere.com/docs/embeddings)
312
+ - [Voyage AI Documentation](https://docs.voyageai.com/)
313
+ - [Ollama Documentation](https://ollama.ai/docs)
314
+ - [Model Context Protocol](https://modelcontextprotocol.io/)
315
+ - [Main Project README](../README.md)
@@ -0,0 +1,111 @@
1
+ # Basic Usage Example
2
+
3
+ This example demonstrates the fundamental operations of the Qdrant MCP Server.
4
+
5
+ ## What You'll Learn
6
+
7
+ - Creating a collection
8
+ - Adding documents with metadata
9
+ - Performing semantic search
10
+ - Cleaning up resources
11
+
12
+ ## Prerequisites
13
+
14
+ - Qdrant and Ollama running via Docker Compose
15
+ - Ollama model pulled (nomic-embed-text)
16
+ - Qdrant MCP Server configured
17
+ - Claude Code or another MCP client
18
+
19
+ **Optional**: Configure OpenAI, Cohere, or Voyage AI if not using Ollama (default)
20
+
21
+ ## Example Workflow
22
+
23
+ ### 1. Create a Collection
24
+
25
+ ```
26
+ Create a collection named "basic-example"
27
+ ```
28
+
29
+ This creates a new vector collection with default settings (Cosine distance, 768 dimensions for Ollama's nomic-embed-text model).
30
+
31
+ ### 2. Add Documents
32
+
33
+ ```
34
+ Add these documents to basic-example:
35
+ - id: 1, text: "The quick brown fox jumps over the lazy dog"
36
+ - id: 2, text: "Machine learning is a subset of artificial intelligence"
37
+ - id: 3, text: "Python is a popular programming language"
38
+ ```
39
+
40
+ Documents are automatically embedded using Ollama (or your configured alternative provider).
41
+
42
+ ### 3. Search for Similar Documents
43
+
44
+ ```
45
+ Search basic-example for "AI and computer programs"
46
+ ```
47
+
48
+ Expected results:
49
+
50
+ - Document 2 (ML/AI) should rank highest
51
+ - Document 3 (Python/programming) may appear with lower score
52
+
53
+ ### 4. Get Collection Information
54
+
55
+ ```
56
+ Get info about "basic-example" collection
57
+ ```
58
+
59
+ Returns:
60
+
61
+ - Vector dimensions
62
+ - Number of documents
63
+ - Distance metric used
64
+
65
+ ### 5. View All Collections
66
+
67
+ ```
68
+ List all collections
69
+ ```
70
+
71
+ Shows all available collections in your Qdrant instance.
72
+
73
+ ### 6. Delete Documents (Optional)
74
+
75
+ ```
76
+ Delete documents [1, 3] from basic-example
77
+ ```
78
+
79
+ Removes specific documents by ID.
80
+
81
+ ### 7. Clean Up
82
+
83
+ ```
84
+ Delete collection "basic-example"
85
+ ```
86
+
87
+ Removes the collection and all its data.
88
+
89
+ ## Try It Yourself
90
+
91
+ Copy these commands into Claude Code:
92
+
93
+ ```
94
+ Create a collection named "my-first-collection"
95
+
96
+ Add these documents to my-first-collection:
97
+ - id: "doc1", text: "Coffee is a popular morning beverage"
98
+ - id: "doc2", text: "Tea comes in many varieties like green, black, and oolong"
99
+ - id: "doc3", text: "Orange juice is rich in vitamin C"
100
+
101
+ Search my-first-collection for "healthy drinks"
102
+
103
+ Get info about "my-first-collection" collection
104
+
105
+ Delete collection "my-first-collection"
106
+ ```
107
+
108
+ ## Next Steps
109
+
110
+ - [Knowledge Base Example](../knowledge-base/) - Learn about metadata and organization
111
+ - [Advanced Filtering](../filters/) - Discover powerful search filtering
@@ -0,0 +1,262 @@
1
+ # Advanced Filtering Examples
2
+
3
+ This example demonstrates powerful metadata filtering capabilities using Qdrant's filter syntax.
4
+
5
+ ## What You'll Learn
6
+
7
+ - Complex boolean logic (AND, OR, NOT)
8
+ - Range filters for numeric values
9
+ - Combining multiple filter conditions
10
+ - Real-world filtering scenarios
11
+
12
+ ## Setup
13
+
14
+ Create a collection with sample e-commerce data:
15
+
16
+ ```
17
+ Create a collection named "products"
18
+
19
+ Add these documents to products:
20
+ - id: "p1", text: "Wireless Bluetooth headphones with noise cancellation and 30-hour battery life", metadata: {"category": "electronics", "price": 199.99, "rating": 4.5, "in_stock": true, "brand": "AudioTech"}
21
+ - id: "p2", text: "Organic cotton t-shirt, comfortable fit, available in multiple colors", metadata: {"category": "clothing", "price": 29.99, "rating": 4.2, "in_stock": true, "brand": "EcoWear"}
22
+ - id: "p3", text: "Stainless steel water bottle, insulated, keeps drinks cold for 24 hours", metadata: {"category": "accessories", "price": 34.99, "rating": 4.8, "in_stock": false, "brand": "HydroFlow"}
23
+ - id: "p4", text: "Mechanical keyboard with RGB lighting and customizable switches", metadata: {"category": "electronics", "price": 149.99, "rating": 4.6, "in_stock": true, "brand": "KeyMaster"}
24
+ - id: "p5", text: "Yoga mat with excellent grip, eco-friendly materials, includes carrying strap", metadata: {"category": "sports", "price": 39.99, "rating": 4.7, "in_stock": true, "brand": "FlexFit"}
25
+ - id: "p6", text: "Smart watch with fitness tracking, heart rate monitor, and GPS", metadata: {"category": "electronics", "price": 299.99, "rating": 4.3, "in_stock": true, "brand": "TechTime"}
26
+ - id: "p7", text: "Running shoes with responsive cushioning and breathable mesh upper", metadata: {"category": "sports", "price": 89.99, "rating": 4.4, "in_stock": false, "brand": "SpeedFoot"}
27
+ - id: "p8", text: "Leather laptop bag with padded compartments and adjustable shoulder strap", metadata: {"category": "accessories", "price": 79.99, "rating": 4.5, "in_stock": true, "brand": "ProCarry"}
28
+ ```
29
+
30
+ ## Filter Examples
31
+
32
+ ### 1. Simple Match Filter (AND)
33
+
34
+ Find electronics products:
35
+
36
+ ```
37
+ Search products for "device for music" with filter {"must": [{"key": "category", "match": {"value": "electronics"}}]}
38
+ ```
39
+
40
+ Expected: Returns p1, p4, p6 (all electronics)
41
+
42
+ ### 2. Multiple Conditions (AND)
43
+
44
+ Find in-stock electronics:
45
+
46
+ ```
47
+ Search products for "gadgets" with filter {"must": [{"key": "category", "match": {"value": "electronics"}}, {"key": "in_stock", "match": {"value": true}}]}
48
+ ```
49
+
50
+ Expected: Returns p1, p4, p6 (in-stock electronics only)
51
+
52
+ ### 3. OR Logic with Should
53
+
54
+ Find either sports or accessories:
55
+
56
+ ```
57
+ Search products for "gear" with filter {"should": [{"key": "category", "match": {"value": "sports"}}, {"key": "category", "match": {"value": "accessories"}}]}
58
+ ```
59
+
60
+ Expected: Returns p3, p5, p7, p8 (sports OR accessories)
61
+
62
+ ### 4. Negation with Must Not
63
+
64
+ Find everything except clothing:
65
+
66
+ ```
67
+ Search products for "shopping" with filter {"must_not": [{"key": "category", "match": {"value": "clothing"}}]}
68
+ ```
69
+
70
+ Expected: Returns all products except p2
71
+
72
+ ### 5. Range Filter - Greater Than
73
+
74
+ **Note:** Range filters require Qdrant's range condition syntax. The current implementation supports match filters. For range queries, you would need to use Qdrant's native range syntax:
75
+
76
+ Conceptual example (not yet implemented in MCP server):
77
+
78
+ ```json
79
+ {
80
+ "must": [
81
+ {
82
+ "key": "price",
83
+ "range": {
84
+ "gt": 100.0
85
+ }
86
+ }
87
+ ]
88
+ }
89
+ ```
90
+
91
+ ### 6. Complex Boolean Logic
92
+
93
+ Find in-stock products that are either:
94
+
95
+ - Electronics with rating > 4.5, OR
96
+ - Sports items under $50
97
+
98
+ ```
99
+ Search products for "quality products" with filter {"must": [{"key": "in_stock", "match": {"value": true}}], "should": [{"key": "category", "match": {"value": "electronics"}}, {"key": "category", "match": {"value": "sports"}}]}
100
+ ```
101
+
102
+ ### 7. Combining Multiple Must Conditions
103
+
104
+ Find highly-rated in-stock electronics:
105
+
106
+ ```
107
+ Search products for "best gadgets" with filter {"must": [{"key": "category", "match": {"value": "electronics"}}, {"key": "in_stock", "match": {"value": true}}, {"key": "rating", "match": {"value": 4.5}}]}
108
+ ```
109
+
110
+ Note: Exact match on rating. For range queries, use Qdrant's range filter syntax.
111
+
112
+ ### 8. Brand Filtering
113
+
114
+ Find AudioTech products:
115
+
116
+ ```
117
+ Search products for "audio equipment" with filter {"must": [{"key": "brand", "match": {"value": "AudioTech"}}]}
118
+ ```
119
+
120
+ Expected: Returns p1 only
121
+
122
+ ### 9. Out of Stock Products
123
+
124
+ Find what needs restocking:
125
+
126
+ ```
127
+ Search products for "items" with filter {"must": [{"key": "in_stock", "match": {"value": false}}]}
128
+ ```
129
+
130
+ Expected: Returns p3, p7 (out of stock items)
131
+
132
+ ### 10. Category Exclusion with Multiple Conditions
133
+
134
+ Find non-electronic in-stock items:
135
+
136
+ ```
137
+ Search products for "shopping" with filter {"must": [{"key": "in_stock", "match": {"value": true}}], "must_not": [{"key": "category", "match": {"value": "electronics"}}]}
138
+ ```
139
+
140
+ Expected: Returns p2, p5, p8 (in-stock, non-electronics)
141
+
142
+ ## Filter Syntax Reference
143
+
144
+ ### Structure
145
+
146
+ ```json
147
+ {
148
+ "must": [], // AND - all conditions must be true
149
+ "should": [], // OR - at least one condition must be true
150
+ "must_not": [] // NOT - conditions must be false
151
+ }
152
+ ```
153
+
154
+ ### Match Filter
155
+
156
+ Exact value matching:
157
+
158
+ ```json
159
+ {
160
+ "key": "field_name",
161
+ "match": {
162
+ "value": "exact_value"
163
+ }
164
+ }
165
+ ```
166
+
167
+ Works with:
168
+
169
+ - Strings: `"value": "electronics"`
170
+ - Numbers: `"value": 4.5`
171
+ - Booleans: `"value": true`
172
+
173
+ ### Range Filter (Qdrant Native)
174
+
175
+ For numeric comparisons (future enhancement):
176
+
177
+ ```json
178
+ {
179
+ "key": "price",
180
+ "range": {
181
+ "gt": 50, // greater than
182
+ "gte": 50, // greater than or equal
183
+ "lt": 200, // less than
184
+ "lte": 200 // less than or equal
185
+ }
186
+ }
187
+ ```
188
+
189
+ ## Real-World Scenarios
190
+
191
+ ### E-commerce Product Search
192
+
193
+ "Show me affordable fitness equipment"
194
+
195
+ ```
196
+ Search products for "fitness equipment" with filter {"must": [{"key": "category", "match": {"value": "sports"}}, {"key": "in_stock", "match": {"value": true}}]}
197
+ ```
198
+
199
+ ### Inventory Management
200
+
201
+ "Which electronics need restocking?"
202
+
203
+ ```
204
+ Search products for "electronics" with filter {"must": [{"key": "category", "match": {"value": "electronics"}}, {"key": "in_stock", "match": {"value": false}}]}
205
+ ```
206
+
207
+ ### Quality Control
208
+
209
+ "Show me all highly-rated available products"
210
+
211
+ ```
212
+ Search products for "top rated products" with filter {"must": [{"key": "in_stock", "match": {"value": true}}]}
213
+ ```
214
+
215
+ ## Limitations and Workarounds
216
+
217
+ ### Current Limitations
218
+
219
+ 1. **No native range filters**: Can't directly filter by price ranges like "between $50-$100"
220
+ 2. **No text search on metadata**: Metadata matching is exact, not fuzzy
221
+ 3. **No nested object queries**: Flat metadata structure only
222
+
223
+ ### Workarounds
224
+
225
+ 1. **Price ranges**: Add price_tier to metadata:
226
+
227
+ ```json
228
+ {"price_tier": "budget", "price": 29.99} // budget: <$50
229
+ {"price_tier": "mid", "price": 149.99} // mid: $50-$200
230
+ {"price_tier": "premium", "price": 299.99} // premium: >$200
231
+ ```
232
+
233
+ 2. **Multiple categories**: Use array-based tags:
234
+
235
+ ```json
236
+ { "tags": ["electronics", "wearable", "fitness"] }
237
+ ```
238
+
239
+ 3. **Date filtering**: Store dates as strings in comparable format:
240
+ ```json
241
+ { "created_date": "2024-03-15" } // YYYY-MM-DD for lexicographic comparison
242
+ ```
243
+
244
+ ## Best Practices
245
+
246
+ 1. **Keep metadata flat**: Avoid deep nesting for better filter performance
247
+ 2. **Use consistent types**: Don't mix strings and numbers for the same field
248
+ 3. **Index commonly filtered fields**: Design metadata around common queries
249
+ 4. **Test filters first**: Validate filter syntax before complex queries
250
+ 5. **Combine with semantic search**: Use filters to narrow, then semantic search to rank
251
+
252
+ ## Clean Up
253
+
254
+ ```
255
+ Delete collection "products"
256
+ ```
257
+
258
+ ## Next Steps
259
+
260
+ - Review [Qdrant filtering documentation](https://qdrant.tech/documentation/concepts/filtering/)
261
+ - Explore the [Knowledge Base Example](../knowledge-base/) for organizational patterns
262
+ - Check the main README for full filter syntax support