Skip to content

Commit af746f3

Browse files
committed
feat: make facets and filters overridable
1 parent 7c40e6e commit af746f3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export function MeiliParamsCreator(searchContext: SearchContext) {
9696
meiliSearchParams.q = query
9797
},
9898
addFacets() {
99-
const value = <Mutable<typeof facets>>facets
99+
const value =
100+
overrideParams?.indexesOverrides?.[indexUid]?.facets ??
101+
overrideParams?.facets ??
102+
<Mutable<typeof facets>>facets
100103
if (value !== undefined) {
101104
// despite Instantsearch.js typing it as `string[]`,
102105
// it still can send `string`
@@ -131,7 +134,10 @@ export function MeiliParamsCreator(searchContext: SearchContext) {
131134
},
132135
addFilters() {
133136
if (meilisearchFilters.length) {
134-
meiliSearchParams.filter = meilisearchFilters
137+
meiliSearchParams.filter =
138+
overrideParams?.indexesOverrides?.[indexUid]?.filter ??
139+
overrideParams?.filter ??
140+
meilisearchFilters
135141
}
136142
},
137143
addAttributesToRetrieve() {

packages/instant-meilisearch/src/types/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export type InstantSearchParams = NonNullable<
4343

4444
type BaseOverridableMeiliSearchSearchParameters = Pick<
4545
MeiliSearchMultiSearchParams,
46+
| 'sort'
47+
| 'hitsPerPage'
48+
| 'filter'
49+
| 'facets'
4650
| 'attributesToCrop'
4751
| 'attributesToRetrieve'
4852
| 'attributesToSearchOn'

0 commit comments

Comments
 (0)