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

Enhance Mongoose Typings with SearchMeta Interface for Atlas Search #13792

Merged
merged 2 commits into from Aug 28, 2023

Conversation

mreouven
Copy link
Contributor

Add search meta
Summary:
This pull request extends the Mongoose module typings by incorporating the SearchMeta interface. This addition offers better type definitions for developers leveraging MongoDB Atlas Search, ensuring that their implementations are more type-safe and adhere to the expected structure.

Motivation:
With MongoDB Atlas Search gaining traction, many developers are harnessing its full-text search capabilities within their Mongoose-based applications. By providing detailed type definitions, we can simplify their development process, prevent type-related errors, and encourage best practices.

Key Features:

Introduced the SearchMeta interface that encapsulates the $searchMeta aggregation pipeline stage.
Included annotations for the possible properties within this stage, such as index, highlight, and their respective sub-properties.
Provided direct links to official MongoDB documentation for easy reference.

Examples:
For a developer implementing the Atlas Search with Mongoose, they can now expect type suggestions and checks for the $searchMeta stage:

const searchAggregation = [
    {
        $searchMeta: {
            index: 'myIndex',
            highlight: {
                path: ['field1', 'field2'],
                maxCharsToExamine: 150
            }
        }
    }
];

With these typings in place, incorrect implementations, such as an invalid property in $searchMeta, will be flagged by TypeScript, offering a more reliable development experience.

Note: For contributors, while updating documentation, please refer to the corresponding .pug files rather than directly editing .html files.

@vkarpov15 vkarpov15 added this to the 7.5 milestone Aug 28, 2023
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 merged commit 90fc4d2 into Automattic:master Aug 28, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants