Skip to content

Commit 203fd63

Browse files
authored
Add vector search param
1 parent bf6cf6b commit 203fd63

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

.changeset/strong-dodos-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@meilisearch/instant-meilisearch": minor
3+
---
4+
5+
Add vector search param to support vector search with user-provided embedding

packages/instant-meilisearch/src/adapter/search-request-adapter/__tests__/search-params.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ describe('Parameters adapter', () => {
9595
expect(searchParams.hybrid).toBe(hybridSearchConfig)
9696
})
9797

98+
test('vector can be set via search parameters', () => {
99+
const vector = [0, 1, 2]
100+
101+
const searchParams = adaptSearchParams({
102+
...DEFAULT_CONTEXT,
103+
meiliSearchParams: {
104+
vector: vector,
105+
},
106+
})
107+
108+
expect(searchParams.vector).toBe(vector)
109+
})
110+
98111
test('ranking score threshold can be set via search parameters', () => {
99112
const rankingScoreThreshold = 0.974
100113

packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ export function MeiliParamsCreator(searchContext: SearchContext) {
238238
meiliSearchParams.hybrid = value
239239
}
240240
},
241+
addVector() {
242+
const value = overrideParams?.vector
243+
if (value !== undefined) {
244+
meiliSearchParams.vector = value
245+
}
246+
},
241247
addDistinct() {
242248
const value = overrideParams?.distinct
243249
if (value !== undefined) {
@@ -282,6 +288,7 @@ export function adaptSearchParams(
282288
meilisearchParams.addShowRankingScore()
283289
meilisearchParams.addAttributesToSearchOn()
284290
meilisearchParams.addHybridSearch()
291+
meilisearchParams.addVector()
285292
meilisearchParams.addDistinct()
286293
meilisearchParams.addRankingScoreThreshold()
287294

0 commit comments

Comments
 (0)