In this guide you will see how to configure and use Meilisearch filters in a hypothetical movie database.
movie_ratings
containing the following fields:
filterableAttributes
list:
filterableAttributes
requires Meilisearch to re-index all your data, which will take an amount of time proportionate to your dataset size and complexity.
filterableAttributes
is empty. Filters do not work without first explicitly adding attributes to the filterableAttributes
list.filter
when searchingfilterableAttributes
index setting, you can use filter
to fine-tune your search results.
filter
is a search parameter you may use at search time. filter
accepts filter expressions built using any attributes present in the filterableAttributes
list.
The following code sample returns Avengers
movies released after 18 March 1995:
Batman
movies directed by either Tim Burton
or Christopher Nolan
:
Tim Burton
and released after 1995 or any film directed by Christopher Nolan
, without constraints on its release date. This happens because AND
takes precedence over OR
.
If you only want recent Planet of the Apes
movies that weren’t directed by Tim Burton
, you can use this filter:
SF
and San Francisco
set as synonyms, filtering by SF
and San Francisco
will show you different results.