Skip to content

Commit

Permalink
Fix filter depth limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
curquiza committed Sep 20, 2023
1 parent e4fdc3d commit 39d3aee
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions learn/inner_workings/known_limitations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,29 @@ If your query is `Hello - World`:

## Maximum filter depth

**Limitation:** Meilisearch does not accept searches with more than 2000 `OR` filters.
**Limitation:** Meilisearch accepts filtering searches (using the `filter` search parameter) with a maximum filtering depth of 2000.

**Explanation:** `OR` filters create nested structures which can lead to a stack overflow.
**Explanation:** Regarding filering, a the depth is increased when mixing and alterning `AND` and `OR` operators filters creating nested structures which can lead to a stack overflow.

### Example

Either of these filter expressions would cause a search query to fail:
The following filter with the chained `OR` operators corresponds to a depth of 1:

```sql
user = 1 OR user = 2 […] OR user = 1500 OR user = 1501 […] OR user = 2000 OR user = 2001
user = 1 OR user = 2 […] OR user = 10000
```

```json
[
["user = 1", "user = 2", [], "user = 1500", "user = 1501", [], "user = 2000", "user = 2001"]
]
```
We got the same behavior with chained `AND` operators: the depth is still 1.

However, when mixing and alterning `AND` and `OR` operators, we create depths:

```sql
# AND is nested inside the ORs, so we have a depth of 2
id = 1 OR id = 2 AND id = 3

# Here we have a depth of 4
id = 1 OR (id = 2 AND (id = 3 OR (id = 4 AND id = 5)))
```

## Size of integer fields

Expand Down

0 comments on commit 39d3aee

Please sign in to comment.