-
Couldn't load subscription status.
- Fork 26
Description
Related to: meilisearch/integration-guides#136
In the README, we want to add the Custom Search With Filters sub section in the Getting Started section to make the users are aware of filtering.
This should
- be placed right after the
Custom Searchsub section - contain the following content:
---------- beginning of the content
If you want to enable filtering, you must add your attributes to the filterableAttributes index setting.
--- Add an example corresponding to the current repository. See this example in JS:
await index.updateAttributesForFaceting([
'id',
'genres'
])--- end of example
You only need to perform this operation once.
Note that MeiliSearch will rebuild your index whenever you update filterableAttributes. Depending on the size of your dataset, this might take time. You can track the process using the update status.
Then, you can perform the search:
--- Add an example corresponding to the current repository. See this example in JS:
await index.search(
'wonder',
{
filter: ['id > 1 AND genres = Action']
}
)--- end of example
{
"hits": [
{
"id": 2,
"title": "Wonder Woman",
"genres": ["Action","Adventure"]
}
],
"offset": 0,
"limit": 20,
"nbHits": 1,
"processingTimeMs": 0,
"query": "wonder"
}------------- end of the content
📣 Example of PR: https://github.com/meilisearch/meilisearch-js/pull/1059/files