> ## Documentation Index
> Fetch the complete documentation index at: https://docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> FalkorDB is a graph database that speaks the Redis protocol. Queries are issued as OpenCypher through the GRAPH.QUERY and GRAPH.RO_QUERY commands, not over Bolt or a SQL connection.
> FalkorDB implements a subset of OpenCypher with proprietary extensions. Do not assume Neo4j-only syntax or procedures are available — check /cypher/cypher-support and /cypher/known-limitations before using a clause.
> FalkorDB is the successor to RedisGraph, but they are separate products. Do not present RedisGraph commands, versions, or limitations as current FalkorDB behavior.
> Use the official clients listed in /getting-started/clients rather than generic Redis or Neo4j drivers, and prefer the language the user is already working in.
> Configuration parameters are set with GRAPH.CONFIG SET or at startup; cite the exact parameter name from /getting-started/configuration rather than inventing one.
> This site covers four products: FalkorDB (core), FalkorDB Cloud, FalkorDB Enterprise, and the GraphRAG SDK. Name which one an answer applies to, since setup and operations differ.

# WHERE

> Filter query results in FalkorDB with the Cypher WHERE clause, using comparison operators, string predicates such as CONTAINS and STARTS WITH, and boolean logic.

The `WHERE` clause is optional and is used to filter results based on predicates (conditions).

## Supported Comparison Operators

| Operator      | Description                  |
| ------------- | ---------------------------- |
| `=`           | Equal to                     |
| `<>`          | Not equal to                 |
| `<`           | Less than                    |
| `<=`          | Less than or equal to        |
| `>`           | Greater than                 |
| `>=`          | Greater than or equal to     |
| `CONTAINS`    | String contains substring    |
| `ENDS WITH`   | String ends with substring   |
| `IN`          | Value is in list             |
| `STARTS WITH` | String starts with substring |

## Combining Predicates

Predicates can be combined using the logical operators `AND`, `OR`, and `NOT`.

Use parentheses to control precedence when combining multiple predicates.

### Examples:

```sql theme={null}
WHERE (actor.name = "john doe" OR movie.rating > 8.8) AND movie.votes <= 250
```

```sql theme={null}
WHERE actor.age >= director.age AND actor.age > 32
```

## Inline Property Filters

You can specify equality predicates directly within node patterns using curly braces:

```sql theme={null}
(:President {name:"Jed Bartlett"})-[:WON]->(:State)
```

This requires that the president node's `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:

```sh theme={null}
MATCH (p:President), (s:State) WHERE (p)-[:WON]->(s) RETURN p, s
```

```sh theme={null}
MATCH (p:President)-[:WON]->(s:State) RETURN p, s
```

Pattern predicates can be negated and combined with logical operators. This query returns presidents who did not win in states where they were governors:

```sh theme={null}
MATCH (p:President), (s:State) WHERE NOT (p)-[:WON]->(s) AND (p)-[:GOVERNOR]->(s) RETURN p, s
```

## Label Filtering

Nodes can be filtered by label in the WHERE clause:

```sh theme={null}
MATCH (n)-[:R]->() WHERE n:L1 OR n:L2 RETURN n 
```

**Best Practice:** When possible, specify labels directly in the node pattern of the MATCH clause for better performance.

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What comparison operators does WHERE support?">
    FalkorDB supports `=`, `<>`, `<`, `<=`, `>`, `>=`, plus string operators `CONTAINS`, `STARTS WITH`, `ENDS WITH`, and the list operator `IN`.
  </Accordion>

  <Accordion title="Can I combine multiple conditions in WHERE?">
    Yes. Use `AND`, `OR`, and `NOT` logical operators to combine predicates. Parentheses control evaluation precedence.
  </Accordion>

  <Accordion title="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.
  </Accordion>

  <Accordion title="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.
  </Accordion>

  <Accordion title="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.
  </Accordion>
</AccordionGroup>
