Docs Menu
Docs Home
/
Atlas
/ / /

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.

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.

1

If you haven't already, complete the steps to create an Atlas Vector Search index on your collection in the Atlas UI.

2
  1. Go to the Atlas Search page for your cluster.

    In the sidebar, click Atlas Search under the Services heading.

  2. Click Create Search Index.

  3. 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 database

      • test collection

    Configuration Method

    For a guided experience, select Visual Editor.

    To edit the raw index definition, select JSON Editor.
  4. 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.

    1. Review the index definition.

      Your index definition should look similar to the following:

      {
      "mappings": {
      "dynamic": true
      }
      }
    2. Click Next.

  5. Click Create Search Index.

  6. Close the You're All Set! modal window.

    A modal window displays to let you know your index is building. Click the Close button.

  7. 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 reads Active.

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.

1
  1. Log in to the AWS Console.

  2. In the upper-left corner, click the Services dropdown menu.

  3. Click Machine Learning, and then select Amazon Bedrock.

2

Either create a new knowledge base with Atlas as the vector store, or modify an existing knowledge base.

  1. 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.

    Screenshot of the vector store search index configuration section.
    click to enlarge
  2. Save the configuration.

3
  1. In the left navigation of the Amazon Bedrock console, click Knowledge Bases.

  2. Select your knowledge base.

  3. Click Test knowledge base.

  4. Click the configurations icon.

  5. 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:

1

In MongoDbAtlasConfiguration, set the textIndexName field to your Atlas Search index name for your knowledge base.

2

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.

Back

Amazon Bedrock

On this page