WHERE clause is optional and is used to filter results based on predicates (conditions).
Supported Comparison Operators
Combining Predicates
Predicates can be combined using the logical operatorsAND, OR, and NOT.
Use parentheses to control precedence when combining multiple predicates.
Examples:
Inline Property Filters
You can specify equality predicates directly within node patterns using curly braces:name property equals “Jed Bartlett”.
Inline predicates are functionally equivalent to predicates specified in the WHERE clause.
Pattern Predicates
You can also filter based on graph patterns. These two queries are equivalent and both return presidents and the states they won:Label Filtering
Nodes can be filtered by label in the WHERE clause:Frequently Asked Questions
What comparison operators does WHERE support?
What comparison operators does WHERE support?
FalkorDB supports
=, <>, <, <=, >, >=, plus string operators CONTAINS, STARTS WITH, ENDS WITH, and the list operator IN.Can I combine multiple conditions in WHERE?
Can I combine multiple conditions in WHERE?
Yes. Use
AND, OR, and NOT logical operators to combine predicates. Parentheses control evaluation precedence.What are inline property filters?
What are inline property filters?
Inline filters use curly braces within node patterns, e.g.
(n:Person {name: 'Alice'}). They are functionally equivalent to a WHERE clause equality check but offer more concise syntax.Do WHERE predicates benefit from indexes?
Do WHERE predicates benefit from indexes?
Yes. When a WHERE clause filters on a property that has a range index, FalkorDB automatically uses an index scan instead of a full label scan. Use
GRAPH.EXPLAIN to verify index usage.Can I filter by graph patterns in WHERE?
Can I filter by graph patterns in WHERE?
Yes. Pattern predicates like
WHERE (a)-[:KNOWS]->(b) or negated patterns WHERE NOT (a)-[:KNOWS]->(b) can be used directly in the WHERE clause.