Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-waves-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@meilisearch/instant-meilisearch": minor
---

Enable experimental hybrid search
3 changes: 2 additions & 1 deletion packages/instant-meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ The following options can be overridden:
[`showMatchesPosition`](https://www.meilisearch.com/docs/reference/api/search#show-matches-position),
[`matchingStrategy`](https://www.meilisearch.com/docs/reference/api/search#matching-strategy),
[`showRankingScore`](https://www.meilisearch.com/docs/reference/api/search#ranking-score),
[`attributesToSearchOn`](https://www.meilisearch.com/docs/reference/api/search#customize-attributes-to-search-on-at-search-time).
[`attributesToSearchOn`](https://www.meilisearch.com/docs/reference/api/search#customize-attributes-to-search-on-at-search-time),
[`hybrid`](https://www.meilisearch.com/docs/learn/experimental/vector_search)

```js
instantMeiliSearch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ describe('Parameters adapter', () => {
meiliSearchParams.matchingStrategy
)
})

test('hybrid search configuration can be set via search parameters', () => {
const hybridSearchConfig = {
semanticRatio: 0,
embedder: 'default',
}

const searchParams = adaptSearchParams({
...DEFAULT_CONTEXT,
meiliSearchParams: {
hybrid: hybridSearchConfig,
},
})

expect(searchParams.hybrid).toBe(hybridSearchConfig)
})
})

describe('Geo filter adapter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export function MeiliParamsCreator(searchContext: SearchContext) {
meiliSearchParams.attributesToSearchOn = value
}
},
addHybridSearch() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test! It seems to work, but maybe there's a different way to approach this. Let me know!

const value = overrideParams?.hybrid
if (value !== undefined) {
meiliSearchParams.hybrid = value
}
},
}
}

Expand Down Expand Up @@ -263,6 +269,7 @@ export function adaptSearchParams(
meilisearchParams.addMatchingStrategy()
meilisearchParams.addShowRankingScore()
meilisearchParams.addAttributesToSearchOn()
meilisearchParams.addHybridSearch()

return meilisearchParams.getParams()
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export function instantMeiliSearch(
const instantMeilisearchConfig = getInstantMeilisearchConfig(
instantMeiliSearchOptions
)

return {
setMeiliSearchParams: (params): void => {
const { meiliSearchParams } = instantMeiliSearchOptions

instantMeiliSearchOptions.meiliSearchParams =
meiliSearchParams === undefined
? params
Expand Down
1 change: 1 addition & 0 deletions packages/instant-meilisearch/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type OverridableMeiliSearchSearchParameters = Pick<
| 'matchingStrategy'
| 'showRankingScore'
| 'attributesToSearchOn'
| 'hybrid'
>

type BaseInstantMeiliSearchOptions = {
Expand Down