Setting the file. One moment.
Chapter 45 · Amazon Opensearch Service
Subchapter 45.23
references/provisioning-serverless-deploy-search.mdMarkdown5 KBView on GitHub
Deploy indices, ML models, and pipelines to a provisioned serverless collection.
Create index with automatic enrichment via AWS API:
POST /opensearchserverless/CreateIndex
{
"id": "<collection-id>",
"indexName": "<index-name>",
"indexSchema": {
"mappings": {
"properties": {
"<text-field>": {
"type": "text",
"semantic_enrichment": {
"status": "ENABLED",
"language_options": "english"
}
}
}
}
}
}Note: Use
aws opensearchserverless create-indexfor this operation (orcall_aws opensearchserverless create-indexif the AWS MCP server is available). Thesemantic_enrichmentconfiguration is specified in the index schema.
language_options: “english” or “multi-lingual”match queries are automatically rewritten to neural sparse queries# Both aws:SourceAccount and aws:SourceArn conditions are required to prevent
# confused-deputy: ArnLike narrows trust to a specific AOSS collection so
# other collections in the same account can't assume this role.
aws iam create-role --role-name opensearch-bedrock-role \
--assume-role-policy-document '{
"Version":"2012-10-17",
"Statement":[{
"Effect":"Allow",
"Principal":{"Service":"ml.opensearchservice.amazonaws.com"},
"Action":"sts:AssumeRole",
"Condition":{
"StringEquals":{"aws:SourceAccount":"<account>"},
"ArnLike": {"aws:SourceArn": "arn:aws:aoss:<region>:<account>:collection/<collection-id>"}
}
}]
}'
aws iam put-role-policy --role-name opensearch-bedrock-role \
--policy-name BedrockInvokePolicy \
--policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"bedrock:InvokeModel","Resource":"arn:aws:bedrock:<region>::foundation-model/amazon.titan-embed-text-v2:0"}]}'POST <collection-endpoint>/_plugins/_ml/connectors/_create
{
"name": "Amazon Bedrock Titan Embedding V2",
"version": 1,
"protocol": "aws_sigv4",
"parameters": { "region": "<aws-region>", "service_name": "bedrock" },
"credential": { "roleArn": "<iam_role_arn>" },
"actions": [{
"action_type": "predict",
"method": "POST",
"url": "https://bedrock-runtime.<aws-region>.amazonaws.com/model/amazon.titan-embed-text-v2:0/invoke",
"headers": { "content-type": "application/json", "x-amz-content-sha256": "required" },
"request_body": "{ \"inputText\": \"${parameters.inputText}\" }",
"pre_process_function": "connector.pre_process.bedrock.embedding",
"post_process_function": "connector.post_process.bedrock.embedding"
}]
}POST <collection-endpoint>/_plugins/_ml/model_groups/_register
{ "name": "bedrock_embedding_models", "description": "Bedrock embedding model group" }
POST <collection-endpoint>/_plugins/_ml/models/_register
{
"name": "bedrock-titan-embed-v2",
"function_name": "remote",
"model_group_id": "<model_group_id>",
"connector_id": "<connector_id>"
}
POST <collection-endpoint>/_plugins/_ml/models/<model-id>/_deployTest: POST /_plugins/_ml/models/<model-id>/_predict with {"parameters": {"inputText": "hello world"}}. Verify 1024-dim embeddings.
PUT <collection-endpoint>/_ingest/pipeline/bedrock-embedding-pipeline
{
"processors": [{
"text_embedding": {
"model_id": "<model_id>",
"field_map": { "<text-field>": "<vector-field>" }
}
}]
}PUT <collection-endpoint>/<index-name>
{
"settings": { "index": { "knn": true, "default_pipeline": "bedrock-embedding-pipeline" } },
"mappings": {
"properties": {
"<text-field>": { "type": "text" },
"<vector-field>": { "type": "knn_vector", "dimension": 1024, "method": { "name": "hnsw", "engine": "faiss" } }
}
}
}PUT <collection-endpoint>/_search/pipeline/hybrid-search-pipeline
{
"phase_results_processors": [{
"normalization-processor": {
"normalization": { "technique": "min_max" },
"combination": { "technique": "arithmetic_mean", "parameters": { "weights": [0.3, 0.7] } }
}
}]
}Create index with text mappings:
PUT <collection-endpoint>/<index-name>
{ "mappings": { "properties": { "<text-field>": { "type": "text" } } } }After index creation (all paths):
match queries (auto-rewritten)neural query with model_idmatch queries