Docs Menu
Docs Home
/ /

Perform Hybrid Search with MongoDB Vector Search and MongoDB Search

This tutorial demonstrates a hybrid search that is an aggregation of full-text and semantic search for the same query criteria. While full-text is effective in finding exact matches for query terms, semantic search provides the added benefit of identifying semantically similar documents even if the documents don't contain the exact query term. This ensures that synonymous and contextually similar matches are also included in the combined results of both methods of search.

Conversely, if you have tokens for proper nouns or specific keywords in your dataset that you don't expect to be considered in the training of an embedding model in the same context that they are used in your dataset, your vector search might benefit from being combined with a full-text search.

You can also set weights for each method of search per query. Based on whether full-text or semantic search results are most relevant and appropriate for a query, you can increase the weight for that search method per query.

This tutorial demonstrates how to run a hybrid search combining MongoDB Vector Search and MongoDB Search queries on the sample_mflix.embedded_movies collection, which contains details about movies, for unified search results. Specifically, this tutorial takes you through the following steps:

  1. Create a MongoDB Vector Search index on the plot_embedding_voyage_3_large field. This field contains vector embeddings that represent the summary of a movie's plot.

  2. Create a MongoDB Search index on the title field in the sample_mflix.embedded_movies collection. This field contains the movie's name as a text string.

  3. Run a query that uses $rankFusion or $scoreFusion to combine the results from a $vectorSearch query against the plot_embedding_voyage_3_large field and a $search query against the title field.

Before you begin, complete the prerequisites.

This section demonstrates how to create the following indexes on the fields in the sample_mflix.embedded_movies collection:

  • A MongoDB Vector Search index on the plot_embedding_voyage_3_large field for running vector queries against that field.

  • A MongoDB Search index on the title field for running full-text search against that field.

Back

Hybrid Search

On this page