Introduction
This guide will walk you through the process of setting up Meilisearch with AWS Bedrock embeddings to enable semantic search capabilities. By leveraging Meilisearch’s AI features and AWS Bedrock’s embedding API, you can enhance your search experience and retrieve more relevant results.Requirements
To follow this guide, you’ll need:- A Meilisearch Cloud project running version >=1.13
- An AWS account with Bedrock access and an API key for embedding generation. You can sign up for an AWS account at AWS.
Setting up Meilisearch
To set up an embedder in Meilisearch, you need to configure it to your settings. You can refer to the Meilisearch documentation for more details on updating the embedder settings.Text embeddings
AWS Bedrock offers multiple text embedding models:amazon.titan-embed-text-v2:0: 256, 512, or 1024 dimensions (Amazon Titan Text Embeddings V2)amazon.nova-2-multimodal-embeddings-v1:0: 256, 384, 1024, or 3072 dimensions (Amazon Nova Multimodal Embeddings - also supports images, video, and audio)cohere.embed-multilingual-v3: 1024 dimensions (Cohere Embed Multilingual v3)cohere.embed-v4:0: 256, 512, 1024, or 1536 dimensions (Cohere Embed v4 - also supports images)
embeddingPurpose and truncationMode, refer to the Nova Embeddings schema documentation.
source: Specifies the source of the embedder, which is set to “rest” for using a REST API.url: The Bedrock Runtime API endpoint. Replace<region>with your AWS region (e.g.,us-east-1,us-west-2,eu-west-3). Note: Nova is currently only available inus-east-1.apiKey: Replace<Your Bedrock API Key>with your actual Bedrock API key.dimensions: Specifies the dimensions of the embeddings. Titan V2 supports 256, 512, or 1024. Nova supports 256, 384, 1024, or 3072. Cohere v3 outputs 1024 dimensions. Cohere v4 defaults to 1536 dimensions (also supports 256, 512, or 1024 viaoutput_dimensionparameter).documentTemplate: Optionally, you can provide a custom template for generating embeddings from your documents.request: Defines the request structure for the Bedrock API. Titan V2 usesinputTextwith optionaldimensionsandnormalizeparameters. Nova usestaskType,singleEmbeddingParamswithembeddingPurpose,embeddingDimension, andtextobject. Cohere v3 usestextsarray andinput_type.response: Defines the expected response structure from the Bedrock API.
Multimodal embeddings
AWS Bedrock offers multimodal embedding models for image search capabilities:amazon.titan-embed-image-v1: 256, 384, or 1024 dimensions (Amazon Titan Multimodal Embeddings G1)amazon.nova-2-multimodal-embeddings-v1:0: 256, 384, 1024, or 3072 dimensions (Amazon Nova Multimodal Embeddings - supports text, images, video, and audio)cohere.embed-v4:0: 256, 512, 1024, or 1536 dimensions (Cohere Embed v4 - supports text, images, and interleaved texts and images)
indexingFragments and searchFragments because they embed images during indexing and text queries during search.
Amazon Titan Multimodal Embeddings G1
embeddingPurpose, detailLevel, and supported formats, refer to the Nova Embeddings schema documentation.
source: Specifies the source of the embedder, which is set to “rest” for using a REST API.url: The Bedrock Runtime API endpoint. Replace<region>with your AWS region (e.g.,us-east-1,us-west-2,eu-west-3).apiKey: Replace<Your Bedrock API Key>with your actual Bedrock API key.dimensions: Specifies the dimensions of the embeddings. Titan Multimodal supports 256, 384, or 1024. Nova supports 256, 384, 1024, or 3072. Cohere v4 supports 256, 512, 1024, or 1536.indexingFragments: Defines how to embed images during document indexing. Uses{{doc.FIELD_NAME}}to reference the base64-encoded image field in your documents (e.g.,{{doc.image_base64}}).searchFragments: Defines how to embed text during search queries. Uses{{q}}to reference the search query.request: Set to{{fragment}}to use the appropriate fragment based on the operation.response: Defines the expected response structure from the Bedrock API.
Testing semantic search
With the embedder set up, you can now perform semantic searches using Meilisearch. When you send a search query, Meilisearch will generate an embedding for the query using the configured embedder and then use it to find the most semantically similar documents in the vector store. To perform a semantic search, you simply need to make a normal search request but include the hybrid parameter:q: Represents the user’s search query.hybrid: Specifies the configuration for the hybrid search.semanticRatio: Allows you to control the balance between semantic search and traditional search. A value of 1 indicates pure semantic search, while a value of 0 represents full-text search. You can adjust this parameter to achieve a hybrid search experience.embedder: The name of the embedder used for generating embeddings. Make sure to use the same name as specified in the embedder configuration, which in this case is “bedrock”.