Filter expressions in WHERE clauses for QUERY, SCROLL, UPDATE, and DELETE statements.
Comparison Operators
Section titled “Comparison Operators”WHERE field = 'value' -- equalityWHERE field != 'value' -- inequalityWHERE field > 10 -- greater thanWHERE field >= 10 -- greater than or equalWHERE field < 100 -- less thanWHERE field <= 100 -- less than or equalWHERE field = 3.14 -- float equalityWHERE field = true -- boolean equalityWHERE field BETWEEN 10 AND 100WHERE year BETWEEN 2020 AND 2026WHERE score BETWEEN 0.5 AND 1.0Set Membership
Section titled “Set Membership”WHERE status IN ('active', 'pending', 'reviewed')WHERE status NOT IN ('deleted', 'archived')WHERE priority IN ('high', 'medium')WHERE year IN (2024, 2025, 2026)Null and Empty Checks
Section titled “Null and Empty Checks”WHERE field IS NULLWHERE field IS NOT NULLWHERE field IS EMPTYWHERE field IS NOT EMPTYText Matching
Section titled “Text Matching”WHERE content MATCH 'hello world' -- full-text matchWHERE content MATCH ANY 'hello world' -- match any termWHERE content MATCH PHRASE 'hello world' -- exact phrase matchLogical Operators
Section titled “Logical Operators”WHERE a = 1 AND b = 2WHERE a = 1 OR b = 2WHERE NOT a = 1WHERE (a = 1 OR b = 2) AND c = 3WHERE (team = 'search' OR team = 'infra') AND severity >= 3Precedence (highest to lowest)
Section titled “Precedence (highest to lowest)”- Comparison operators,
BETWEEN,IN,IS,MATCH NOTANDOR
Parentheses override precedence.
Nested Fields
Section titled “Nested Fields”WHERE meta.source = 'pubmed'WHERE doc.author.name = 'Alice'Examples
Section titled “Examples”-- Filter by status and yearQUERY 'search' FROM docs LIMIT 10 WHERE status = 'published' AND year >= 2024
-- Filter with set membershipQUERY 'retrieval' FROM docs LIMIT 10 WHERE category IN ('ml', 'nlp', 'cv')
-- Filter with rangeQUERY 'articles' FROM docs LIMIT 10 WHERE score BETWEEN 0.8 AND 1.0
-- Filter with text matchingQUERY 'search' FROM docs LIMIT 10 WHERE title MATCH PHRASE 'vector database'
-- Complex filterQUERY 'emergency' FROM docs LIMIT 10 WHERE (specialty = 'neurology' OR specialty = 'cardiology') AND priority = 'high' AND status != 'discharged'
-- Null checkQUERY 'records' FROM docs LIMIT 10 WHERE diagnosis IS NOT NULL
-- Filter in SCROLLSCROLL FROM docs WHERE topic = 'search' AND year >= 2024 LIMIT 20
-- Filter in DELETEDELETE FROM docs WHERE status = 'archived'
-- Filter in UPDATEUPDATE docs SET PAYLOAD = {'status': 'reviewed'} WHERE status = 'pending'Per-Prefetch Filters
Section titled “Per-Prefetch Filters”Filters can be applied to individual CTE prefetches:
WITH dense AS (QUERY 'search' USING dense LIMIT 200), sparse AS (QUERY 'search' USING sparse LIMIT 300)QUERY 'search' FROM docs LIMIT 10 PREFETCH ( dense WHERE category = 'tech' SCORE THRESHOLD 0.6, sparse WHERE priority = 'high' SCORE THRESHOLD 0.3 ) FUSION RRFPayload Indexes
Section titled “Payload Indexes”For efficient filtering, create payload indexes:
CREATE INDEX ON docs FOR status TYPE keywordCREATE INDEX ON docs FOR year TYPE integerCREATE INDEX ON docs FOR score TYPE floatCREATE INDEX ON docs FOR tags TYPE keyword WITH (is_tenant = true)CREATE INDEX ON docs FOR content TYPE text WITH (tokenizer = 'word', lowercase = true)Index Types
Section titled “Index Types”| Type | Use For |
|---|---|
keyword | String fields, enums, tags |
integer | Integer fields |
float | Float fields |
bool | Boolean fields |
uuid | UUID string fields |
datetime | ISO 8601 datetime fields |
geo | {lat, lon} geo coordinate fields |
text | Full-text search fields |
Text Index Options
Section titled “Text Index Options”CREATE INDEX ON docs FOR content TYPE text WITH ( tokenizer = 'word', -- 'word', 'whitespace', 'prefix', 'multilingual' min_token_len = 2, max_token_len = 20, lowercase = true, ascii_folding = true, phrase_matching = true, stopwords = ['en'])Keyword Index Options
Section titled “Keyword Index Options”CREATE INDEX ON docs FOR tenant_id TYPE keyword WITH ( is_tenant = true, -- tenant-aware HNSW partitioning on_disk = true, -- store index on disk enable_hnsw = false -- disable HNSW for this field)