GartnerMongoDB named a Leader in the 2026 Gartner® Magic Quadrant™ for Cloud Databases. Read the Gartner report > >>

MongoDB Mastra Integration Adds Hybrid Search, Auto Embedding, and Reranking

November 24, 2026 ・ 5 min read

Builders use Mastra, an open-source TypeScript framework, to create increasingly capable agents with MongoDB. But preparing retrieval for those agents can mean copying operational data into a separate collection, generating and syncing embeddings, merging semantic and keyword results, reranking, and fetching full records: a lot of code to maintain, and a lot of places for data to drift.

Today, we're bringing all of it into a single query in Mastra: Hybrid Search now works together with Automated Embedding, BYOC, pre-filtering, and Native Reranking to return the most relevant full documents from your existing collection, with no separate copy or sync job.

Here's what each piece does:

Together, they simplify retrieval from ingestion through query. In this article, we’ll show you how these features can improve your existing load and retrieval workflows.

What did retrieval setup in Mastra require before this release?

Before this release, for an agent to search a product catalog or transaction history by meaning, a Mastra application typically had to prepare the data for vector search like this:

  1. Create a separate managed vector collection to store embeddings and retrieval metadata.

  2. Call an embedding service to vectorize source text, then store the embeddings with retrieval metadata.

  3. Track the source IDs so the application can fetch the full product records for the final recommendations.

  4. Monitor changes to the source data and re-embed and sync any indexed text fields.

Figure 1. Your application handles: embedding queries and documents, merging results from semantic and text searches, retrieving full documents from winning hits, and re-embedding data.

Diagram illustrating the traditional 'Before' retrieval architecture with separate services to connect and maintain. A Mastra agent sends a question and receives results through custom application code. The custom application code manages monitoring data changes and re-embedding, and merges and filter candidates. It coordinates across five external services: an external embedding API, a dedicated vector database for semantic search, an operational database for keyword search and fetching full records, and an external reranker API for reranking candidates.

Keeping the retrieval copy up to date is still your responsibility, whether you use change streams, a cron job, or another approach.

How do Automated Embedding and Bring Your Own Collection simplify setup?

MongoDB and Mastra simplify both sides of retrieval prep. Automated Embedding lets you configure a text field and a Voyage AI model, so MongoDB handles embeddings for you; and when your operational data already lives in MongoDB, you can Bring Your Own Collection so Mastra searches that collection directly.

Tip: BYOC works with Automated Embedding or manual embeddings if you prefer to use a model outside the Voyage AI family. Check out Mastra’s documentation on managing embeddings yourself.

This example uses both to prepare the collection that Hybrid Search will query: Automated Embedding keeps vectors current, while BYOC lets Mastra search the original documents:

TypeScript

And that’s all it takes to configure both indexes.

How does hybrid search answer questions that mix intent and constraints?

One hybrid search query can match what a buyer means while enforcing hard limits on price and availability. Imagine someone asks an e-commerce agent: “What’s the best laptop for video editing under $1,500?” A useful answer needs more than a text match. The agent should find products whose descriptions are relevant to video editing, honor constraints such as “under $1,500” or “in stock,” and prioritize the strongest matches.

In a traditional retrieval flow, an application may need to run semantic search and keyword search separately, combine and deduplicate their results, apply price and availability rules, send candidates through another ranking step to boost relevance, and fetch the full product records for the winners.

How do hybrid search, pre-filtering, and reranking work together in one query?

Hybrid search is the search-time glue: one query combines semantic and keyword matching, applies pre-filters such as price and availability, and uses Native Reranking to prioritize the most relevant results. Automated Embedding keeps the indexed vectors up to date, and BYOC lets Mastra query the original collection. So the agent can interpret “best for video editing” while respecting the buyer’s concrete constraints and prioritizing the most relevant results, without requiring your application to coordinate separate retrieval steps.

Figure 2. Atlas manages for you: Embeddings, Reranking, and Vector and Text Search (Hybrid Search). BYOC queries your operational data directly.

Diagram illustrating the streamlined 'After' retrieval architecture where a Mastra agent makes a single call to MongoDB Atlas. MongoDB Atlas manages automated embeddings, hybrid search combining vector search and MongoDB search, and native reranking. An operational database using Bring Your Own Collection (BYOC) handles filtered search in place, returning top full records directly to the Mastra agent without separate application coordination.

Unlike the traditional flow described before, you can now pass the search text directly as the vector query. MongoDB generates its embedding, so the application doesn’t need a separate query-embedding call.

A hybrid search call combining all these features looks like this:

TypeScript

Get started with hybrid search and Automated Embedding in Mastra

Install the latest MongoDB integration for Mastra to start using these features today:

Shell

Have a look at the Automated Embedding docs to check the requirements.

To try the new Native Reranking, you will need a MongoDB Atlas cluster running version 9.0 with reranking enabled (see the instructions).

Linked resources:

MongoDB Resources