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 vector search param #1353

Merged
merged 4 commits into from
Jan 10, 2025
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