Skip to content
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

Merged

Conversation

flevi29
Copy link
Collaborator

@flevi29 flevi29 commented Aug 16, 2024

Pull Request

Related issue

Fixes #1683

What does this PR do?

  • adds types and test for federation feature

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@flevi29 flevi29 linked an issue Aug 19, 2024 that may be closed by this pull request
3 tasks
@flevi29 flevi29 changed the title Feature federated search feat(v1.10): Federated search Aug 19, 2024
@curquiza curquiza requested review from mdubus and removed request for brunoocasali August 20, 2024 13:21
@curquiza curquiza changed the title feat(v1.10): Federated search Add federated search parameters Aug 20, 2024
@curquiza curquiza added the enhancement New feature or request label Aug 20, 2024
src/clients/client.ts Show resolved Hide resolved
Comment on lines +219 to +230
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>> {
Copy link
Member

@mdubus mdubus Aug 21, 2024

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)

Copy link
Collaborator Author

@flevi29 flevi29 Aug 22, 2024

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.

Copy link
Member

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 🙌

tests/__snapshots__/settings.test.ts.snap Outdated Show resolved Hide resolved
src/types/types.ts Show resolved Hide resolved
tests/utils/meilisearch-test-utils.ts Outdated Show resolved Hide resolved
@mdubus mdubus merged commit 3a8608b into meilisearch:bump-meilisearch-v1.10.0 Aug 22, 2024
6 checks passed
@curquiza curquiza mentioned this pull request Aug 22, 2024
3 tasks
@flevi29 flevi29 deleted the feature-federated-search branch August 22, 2024 12:56
meili-bors bot added a commit that referenced this pull request Aug 26, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1.10.0] Federated search
3 participants