You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,49 @@ JSON output:
152
152
}
153
153
```
154
154
155
+
#### Custom Search With Filters <!-- omit in toc -->
156
+
157
+
If you want to enable filtering, you must add your attributes to the `filterableAttributes` index setting.
158
+
159
+
```py
160
+
index.update_filterable_attributes([
161
+
'id',
162
+
'genres'
163
+
])
164
+
```
165
+
166
+
You only need to perform this operation once.
167
+
168
+
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](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
169
+
170
+
Then, you can perform the search:
171
+
172
+
```py
173
+
index.search(
174
+
'wonder',
175
+
{
176
+
filter: ['id > 1 AND genres = Action']
177
+
}
178
+
)
179
+
```
180
+
181
+
```json
182
+
{
183
+
"hits": [
184
+
{
185
+
"id": 2,
186
+
"title": "Wonder Woman",
187
+
"genres": ["Action","Adventure"]
188
+
}
189
+
],
190
+
"offset": 0,
191
+
"limit": 20,
192
+
"nbHits": 1,
193
+
"processingTimeMs": 0,
194
+
"query": "wonder"
195
+
}
196
+
```
197
+
155
198
## 🤖 Compatibility with MeiliSearch
156
199
157
200
This package only guarantees the compatibility with the [version v0.23.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.23.0).
0 commit comments