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 TypeScript interface for the new PipelineStage - Vector Search - solving issue #14428 #14429

Merged
merged 5 commits into from Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/types/PipelineStage.test.ts
Expand Up @@ -520,3 +520,20 @@
}
};
}
const vectorSearchStages: PipelineStage[] = [
{
$vectorSearch: {
index: 'title_vector_index',

Check warning on line 526 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 526 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
path: 'embedding',

Check warning on line 527 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 527 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
queryVector: [0.522,0.123,0.487],

Check warning on line 528 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 528 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 528 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

A space is required after ','

Check failure on line 528 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

A space is required after ','
limit: 5,

Check warning on line 529 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 529 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
numCandidates: 100

Check warning on line 530 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 530 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
vkarpov15 marked this conversation as resolved.
Show resolved Hide resolved
}
},
{
$project: {
title: 1,

Check warning on line 535 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 535 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
score: { $meta: 'searchScore' }

Check warning on line 536 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4

Check failure on line 536 in test/types/PipelineStage.test.ts

View workflow job for this annotation

GitHub Actions / Lint TS-Files

Expected indentation of 6 spaces but found 4
vkarpov15 marked this conversation as resolved.
Show resolved Hide resolved
}
}
];
15 changes: 14 additions & 1 deletion types/pipelinestage.d.ts
Expand Up @@ -36,7 +36,8 @@ declare module 'mongoose' {
| PipelineStage.SortByCount
| PipelineStage.UnionWith
| PipelineStage.Unset
| PipelineStage.Unwind;
| PipelineStage.Unwind
| PipelineStage.VectorSearch;

export namespace PipelineStage {
export interface AddFields {
Expand Down Expand Up @@ -308,5 +309,17 @@ declare module 'mongoose' {
/** [`$unwind` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/) */
$unwind: string | { path: string; includeArrayIndex?: string; preserveNullAndEmptyArrays?: boolean }
}
export interface VectorSearch {
/** [`$vectorSearch` reference](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/) */
$vectorSearch: {
index: string,
path: string,
queryVector: number[],
numCandidates: number,
limit: number,
filter?: Expression,
}
}

}
}