diff --git a/.changeset/strong-dodos-carry.md b/.changeset/strong-dodos-carry.md new file mode 100644 index 00000000..a37a95c2 --- /dev/null +++ b/.changeset/strong-dodos-carry.md @@ -0,0 +1,6 @@ +--- +"@meilisearch/instant-meilisearch": minor +--- + +Add `vector` field to the search params object to support user-provided embeddings + diff --git a/packages/instant-meilisearch/src/adapter/search-request-adapter/__tests__/search-params.test.ts b/packages/instant-meilisearch/src/adapter/search-request-adapter/__tests__/search-params.test.ts index 9c38825f..57eae476 100644 --- a/packages/instant-meilisearch/src/adapter/search-request-adapter/__tests__/search-params.test.ts +++ b/packages/instant-meilisearch/src/adapter/search-request-adapter/__tests__/search-params.test.ts @@ -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 diff --git a/packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts b/packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts index f6e971b7..0dc2930e 100644 --- a/packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts +++ b/packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts @@ -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) { @@ -282,6 +288,7 @@ export function adaptSearchParams( meilisearchParams.addShowRankingScore() meilisearchParams.addAttributesToSearchOn() meilisearchParams.addHybridSearch() + meilisearchParams.addVector() meilisearchParams.addDistinct() meilisearchParams.addRankingScoreThreshold() diff --git a/packages/instant-meilisearch/src/types/types.ts b/packages/instant-meilisearch/src/types/types.ts index 5d5c2c3e..26eba4cb 100644 --- a/packages/instant-meilisearch/src/types/types.ts +++ b/packages/instant-meilisearch/src/types/types.ts @@ -57,6 +57,7 @@ export type OverridableMeiliSearchSearchParameters = Pick< | 'rankingScoreThreshold' | 'showMatchesPosition' | 'showRankingScore' + | 'vector' > type BaseInstantMeiliSearchOptions = {