Skip to content

Commit c7fb215

Browse files
bors[bot]bidoubiwa
andauthored
Merge #372
372: Communicate filters and numeric filters properly to instantsearch r=bidoubiwa a=bidoubiwa See: meilisearch/meilisearch-vue#21 Numeric filters were not added to instantsearch's filters field. Demo: https://codesandbox.io/s/meilisearch-boardgames-uj2tr?file=/src/App.vue Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents a8ddf78 + f126d8e commit c7fb215

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,24 @@ export function instantMeiliSearch(
3030
attributesToSnippet: attributesToCrop,
3131
attributesToRetrieve,
3232
attributesToHighlight,
33-
filters,
33+
filters = '',
34+
numericFilters = [],
3435
}) {
3536
const limit = this.paginationTotalHits
3637

38+
const filter = [numericFilters.join(' AND '), filters.trim()]
39+
.filter((x) => x)
40+
.join(' AND ')
41+
.trim()
42+
3743
// Creates search params object compliant with MeiliSearch
3844
return {
3945
q: query,
4046
...(facets?.length && { facetsDistribution: facets }),
4147
...(facetFilters && { facetFilters }),
4248
...(attributesToCrop && { attributesToCrop }),
4349
...(attributesToRetrieve && { attributesToRetrieve }),
44-
...(filters && { filters }),
50+
...(filter && { filters: filter }),
4551
attributesToHighlight: attributesToHighlight || ['*'],
4652
limit: (!this.placeholderSearch && query === '') || !limit ? 0 : limit,
4753
}

0 commit comments

Comments
 (0)