$rankFusion and $scoreFusion stages are available as Preview features. To learn more, see Preview Features.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.
About the Tutorial
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:
Create a MongoDB Vector Search index on the
plot_embedding_voyage_3_largefield. This field contains vector embeddings that represent the summary of a movie's plot.Create a MongoDB Search index on the
titlefield in thesample_mflix.embedded_moviescollection. This field contains the movie's name as a text string.Run a query that uses
$rankFusionor$scoreFusionto combine the results from a$vectorSearchquery against theplot_embedding_voyage_3_largefield and a$searchquery against thetitlefield.
Prerequisites
Before you begin, complete the prerequisites.
Procedures
Create the MongoDB Vector Search and MongoDB Search Indexes
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_largefield for running vector queries against that field.A MongoDB Search index on the
titlefield for running full-text search against that field.