Predicates Quick Reference
Operatorsβ
Comparison Operatorsβ
| Operator | Syntax | Example |
|---|---|---|
| Equals | key = value | author = "Alice" |
| Not Equals | key != value | status != "draft" |
| In | key IN [values] | category IN ["tech", "ai"] |
| Not In | key NOT IN [values] | priority NOT IN ["low"] |
Logical Operatorsβ
| Operator | Syntax | Example |
|---|---|---|
| AND | (condition) AND (condition) | (author = "Alice") AND (category = "tech") |
| OR | (condition) OR (condition) | (status = "draft") OR (status = "review") |
Common Patternsβ
Single Field Filterβ
GETPRED (category = "tech") IN articles
Multiple Field Filter (AND)β
GETPRED (author = "Alice") AND (status = "published") IN articles
Multiple Field Filter (OR)β
GETPRED (priority = "high") OR (priority = "urgent") IN tasks
Using IN for Multiple Valuesβ
GETPRED category IN ["tech", "science", "ai"] IN articles
Nested Conditionsβ
GETPRED
((author = "Alice") OR (author = "Bob"))
AND
(category = "tech")
IN articles
Hybrid Query (Similarity + Filter)β
AI:
GETSIMN 10 WITH [machine learning]
USING cosinesimilarity
IN articles
WHERE (author = "Alice")
DB:
GETSIMN 10 WITH [0.1, 0.2, 0.3, ...]
USING cosinesimilarity
IN articles
WHERE (category = "tech")
Index Managementβ
Create Indexβ
CREATEPREDINDEX author, category, status IN my_store
Drop Indexβ
DROPPREDINDEX category IN my_store
Drop Index with Error Handlingβ
DROPPREDINDEX category IN my_store ERRORIFDOESNOTEXIST
Store Creation with Predicatesβ
Ahnlich AIβ
CREATESTORE my_store
QUERYMODEL all-minilm-l6-v2
INDEXMODEL all-minilm-l6-v2
PREDICATES (author, category, status)
Ahnlich DBβ
CREATESTORE my_store
DIMENSION 384
CREATEPREDINDEX (author, category, status)
Delete by Predicateβ
Simple Deleteβ
DELPRED (status = "deleted") IN articles
Complex Deleteβ
DELPRED
(status = "draft")
AND
(last_modified < "2024-01-01")
IN articles
Tipsβ
β Do:
- Create indexes for frequently filtered fields
- Use
INfor multiple values instead of chainingOR - Keep metadata values small and simple
- Declare predicates when creating stores
β Don't:
- Store large text in metadata (use for filtering only)
- Create indexes on rarely used fields
- Forget to index high-cardinality fields (many unique values)
Syntax Cheat Sheetβ
Predicate:
key = "value"
key != "value"
key IN ["val1", "val2"]
key NOT IN ["val1"]
PredicateCondition:
(predicate)
(condition) AND (condition)
(condition) OR (condition)
((cond1) AND (cond2)) OR (cond3) # Nested
Commands:
CREATEPREDINDEX field1, field2 IN store
DROPPREDINDEX field1 IN store
GETPRED (condition) IN store
GETSIMN n WITH [input] USING algorithm IN store WHERE (condition)
DELPRED (condition) IN store