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

Conversation

jkorach
Copy link
Contributor

@jkorach jkorach commented Mar 10, 2024

Summary
With MongoDB releasing the new vector search index & pipeline stage, Mongoose is missing this PiplineStage, which creates a compilation error in TypeScript. The proposal is to add support for this new PipelineStage - VecrorSearch

The motivation is to maintain & support the typesafe aggregation pipeline in Mongoose.

This PR is aiming to solve this issue

Examples

const mongoose = require("mongoose");
const contentsSchema = new mongoose.Schema({
  embedding: {
    type: [Number],
  },
  title: String,
});
export const Contents = mongoose.model(
  "Contents",
  contentsSchema,
  "contents",
);

 const result = await Contents.aggregate([
    {
      $vectorSearch: {
        index: "title_vector_index",
        path: "embedding",
        filter: {someField: "value",}
        queryVector:[0.3455,......,0.123],
        numCandidates: 200,
        limit: 10,
      },
    },
  ]);

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Mar 14, 2024
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from some indentation, it looks good to me

test/types/PipelineStage.test.ts Outdated Show resolved Hide resolved
test/types/PipelineStage.test.ts Outdated Show resolved Hide resolved
vkarpov15 and others added 3 commits March 14, 2024 14:44
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 added this to the 8.2.2 milestone Mar 14, 2024
@vkarpov15 vkarpov15 merged commit 06067de into Automattic:master Mar 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants