-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: handle per index meilisearch params #1364
base: main
Are you sure you want to change the base?
feature: handle per index meilisearch params #1364
Conversation
|
My initial proposal in #1364 was to be able to override directly like : const client = instantMeiliSearch(
"host",
"key",
{
meiliSearchParams: {
products: { matchingStrategy: MatchingStrategies.ALL },
categories: { matchingStrategy: MatchingStrategies.LAST },
},
},
).searchClient; Unfortunately as far as I've seen it's not possible using typescript This one works fine for accessing the valuesexport type OverridableMeiliSearchSearchParameters = BaseMeiliSearchSearchParameters & {
[K in Exclude<string, keyof BaseMeiliSearchSearchParameters>]?: BaseMeiliSearchSearchParameters;
}; // No TS errors
const res = myobject[indexName].attributesToRetrieve;
// TS error
const meiliSearchParams: OverridableMeiliSearchSearchParameters = {
attributesToHighlight: ['movies', 'genres'],
highlightPreTag: '<em>',
highlightPostTag: '</em>',
matchingStrategy: MatchingStrategies.ALL,
} This one works fine for declaring valuesexport type OverridableMeiliSearchSearchParameters =
| BaseMeiliSearchSearchParameters
| (BaseMeiliSearchSearchParameters & {
[K in Exclude<
string,
keyof BaseMeiliSearchSearchParameters
>]?: BaseMeiliSearchSearchParameters
}) // TS errors
const res = myobject[indexName].attributesToRetrieve;
// No TS errors
const meiliSearchParams: OverridableMeiliSearchSearchParameters = {
attributesToHighlight: ['movies', 'genres'],
highlightPreTag: '<em>',
highlightPostTag: '</em>',
matchingStrategy: MatchingStrategies.ALL,
} Open to discuss it if anyone has another approach in mind |
Pull Request
Related issue
Fixes #1361
What does this PR do?
From :
To :
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!