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
6 changes: 6 additions & 0 deletions .changeset/strong-dodos-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@meilisearch/instant-meilisearch": minor
---

Add `vector` field to the search params object to support user-provided embeddings

Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ describe('Parameters adapter', () => {
expect(searchParams.hybrid).toBe(hybridSearchConfig)
})

test('vector can be set via search parameters', () => {
const vector = [0, 1, 2]

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

expect(searchParams.vector).toBe(vector)
})

test('ranking score threshold can be set via search parameters', () => {
const rankingScoreThreshold = 0.974

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export function MeiliParamsCreator(searchContext: SearchContext) {
meiliSearchParams.hybrid = value
}
},
addVector() {
const value = overrideParams?.vector
if (value !== undefined) {
meiliSearchParams.vector = value
}
},
addDistinct() {
const value = overrideParams?.distinct
if (value !== undefined) {
Expand Down Expand Up @@ -282,6 +288,7 @@ export function adaptSearchParams(
meilisearchParams.addShowRankingScore()
meilisearchParams.addAttributesToSearchOn()
meilisearchParams.addHybridSearch()
meilisearchParams.addVector()
meilisearchParams.addDistinct()
meilisearchParams.addRankingScoreThreshold()

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 @@ -57,6 +57,7 @@ export type OverridableMeiliSearchSearchParameters = Pick<
| 'rankingScoreThreshold'
| 'showMatchesPosition'
| 'showRankingScore'
| 'vector'
>

type BaseInstantMeiliSearchOptions = {
Expand Down
Loading