-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add federated search parameters #1689
Add federated search parameters #1689
Conversation
multiSearch<T extends Record<string, unknown> = Record<string, any>>( | ||
queries: MultiSearchParams, | ||
config?: Partial<Request>, | ||
): Promise<MultiSearchResponse<T>>; | ||
multiSearch<T extends Record<string, unknown> = Record<string, any>>( | ||
queries: FederatedMultiSearchParams, | ||
config?: Partial<Request>, | ||
): Promise<SearchResponse<T>>; | ||
async multiSearch<T extends Record<string, unknown> = Record<string, any>>( | ||
queries: MultiSearchParams | FederatedMultiSearchParams, | ||
config?: Partial<Request>, | ||
): Promise<MultiSearchResponse<T>> { | ||
): Promise<MultiSearchResponse<T> | SearchResponse<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems really overkill to me (and hardly maintainable). I think we can just keep it as it was, and find a way to type MultiSearchResponse
differently in the types.ts
file :) (see my other comment below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look into http-request.ts
we have a ton of overloads there too, I am planning on addressing these eventually.
I have tried typing queries
with generics so that multiSearch
would be smaller and simpler, but the problem with that is that we have an optional generic already T extends Record<string, unknown> = Record<string, any>
, and when you have an optional generic all the following generics have to be optional as well, and optional generics don't have type inference, and if we make the queries
generic the first one and required we cannot specify the type of hits without also explicitly specify the shape of the queries
, thus typing it with generics doesn't really work as it is now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks for the explanation 👍
Let's keep your suggestion then. That would be amazing if you could open an issue about addressing those overloads, though, to keep in mind that it's something we might want to change in the future 🙌
This reverts commit 899d2a7.
49f1026
to
b218f1f
Compare
1695: Update version for the next release (v0.42.0) r=brunoocasali a=meili-bot _This PR is auto-generated._ The automated script updates the version of meilisearch-js to a new version: "v0.42.0" CHANGELOGS 👇 This version introduces features released on Meilisearch v1.10.0 🎉 Check out the changelog of [Meilisearch v1.10.0](https://github.com/meilisearch/meilisearch/releases/tag/v1.10.0) for more information on the changes. ##⚠️ Breaking changes * Improve errors (#1656) `@/flevi29` More details [here](#1656 (comment)) * Changes related to Hybrid search (experimental) for the REST embedder (#1692) `@/mdubus` - Removed parameters: `query`, `inputField`, `inputType`, `pathToEmbeddings` and `embeddingObject`. - Replaced by `request` and `response` - New parameter: `headers` ## 🚀 Enhancements * Hybrid search improvements (#1692) `@/mdubus` - Add `url` parameter to the OpenAI embedder - `dimensions` is now available as an optional parameter for `ollama` embedders. * Add federated search parameters (#1689) `@/flevi29` ```js client.multiSearch({ federation: {}, queries: [ { indexUid: 'movies', q: 'batman', limit: 5, }, { indexUid: 'comics', q: 'batman', limit: 5, }, ] }) ``` * Add capabilities to update documents by function (#1691) `@/flevi29` ```js index.updateDocumentsByFunction({ context: { ctx: 'Harry' }, filter: 'id = 4', function: 'doc.comment = `Yer a wizard, ${context.ctx}!`', }) ) ``` * Add language settings (#1693) `@/flevi29` ```js client.index('INDEX_NAME').updateLocalizedAttributes([ { attributePatterns: ['jpn'], locales: ['*_ja'] }, ];) ``` * Add `locale` search parameter (#1693) `@/flevi29` ```js client.index('INDEX_NAME').search('進撃の巨人', { locales: ['jpn'] }) ``` ## ⚙️ Maintenance/misc * Add JS hosted documentation (#1678) `@/amit-ksh` Co-authored-by: meili-bot <[email protected]>
Pull Request
Related issue
Fixes #1683
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!