Hybrid Search with Amazon Bedrock and Atlas
Note
Amazon Bedrock supports hybrid search with Atlas currently for only US West (Oregon) and US East (N. Virginia) AWS regions.
The Amazon Bedrock Knowledge Base integration with MongoDB Atlas supports hybrid search. Hybrid search combines Atlas Vector Search and Atlas Search (full-text search) to help improve the relevancy of your search results.
To use hybrid search with Amazon Bedrock, you must create both an Atlas Vector Search index and an Atlas Search index on your data. Then, you can enable hybrid search through the Amazon Bedrock console or API.
Create the Indexes
To enable hybrid search for your knowledge base,
you must have both an Atlas Vector Search index and an Atlas Search index
on your collection in Atlas. In this example,
we assume that you have a database named
bedrock_db
with collection named test
.
Create the Atlas Vector Search index.
If you haven't already, complete the steps to create an Atlas Vector Search index on your collection in the Atlas UI.
Create the Atlas Search index.
Go to the Atlas Search page for your cluster.
In the sidebar, click Atlas Search under the Services heading.
Click Create Search Index.
Start your index configuration.
Make the following selections on the page and then click Next.
Search Type
Select the Atlas Search index type.
Index Name and Data Source
Specify the following information:
Index Name:
search_index
Database and Collection:
bedrock_db
databasetest
collection
Configuration Method
For a guided experience, select Visual Editor.To edit the raw index definition, select JSON Editor.Define the index.
The following index definition dynamically indexes the fields of supported types in the collection. You can use the Atlas Search Visual Editor or the Atlas Search JSON Editor in the Atlas user interface to create the index.
Review the default index definition for the collection.
Review the index definition.
Your index definition should look similar to the following:
{ "mappings": { "dynamic": true } } Click Next.
Click Create Search Index.
Close the You're All Set! modal window.
A modal window displays to let you know your index is building. Click the Close button.
Wait for the index to finish building.
The index should take about one minute to build. While it is building, the Status column reads
Build in Progress
. When it is finished building, the Status column readsActive
.
Configure Hybrid Search for your Knowledge Base
After you create both indexes, configure your knowledge base to use hybrid search. You can use either the Amazon Bedrock console or the Amazon Bedrock API to enable hybrid search.
Navigate to Amazon Bedrock management console.
Log in to the AWS Console.
In the upper-left corner, click the Services dropdown menu.
Click Machine Learning, and then select Amazon Bedrock.
Update your knowledge base configuration.
Either create a new knowledge base with Atlas as the vector store, or modify an existing knowledge base.
In the vector store configuration, set the Text search index name field to
search_index
, or the name of your Atlas Search index if you used a different name.click to enlargeSave the configuration.
Enable hybrid search for your knowledge base.
In the left navigation of the Amazon Bedrock console, click Knowledge Bases.
Select your knowledge base.
Click Test knowledge base.
Click the configurations icon.
For Search type, select Hybrid search (semantic & text).
By default, you can choose a foundation model to generate a response based on your query. To see only the retrieved documents, toggle Generate response to off.
If you have an existing knowledge base, complete the following steps:
Specify the Atlas Search index in your knowledge base configuration.
In MongoDbAtlasConfiguration,
set the textIndexName
field to your Atlas Search index name for your knowledge base.
Specify the search type in your knowledge base configuration.
In KnowledgeBaseVectorSearchConfiguration
for your knowledge base, set the overrideSearchType
field to HYBRID
.
You use this configuration to retrieve data in the following API requests:
After you enable hybrid search, you can test your knowledge base or create an agent.