AWS Builder Center
Automatic Semantic Enrichment in OpenSearch Serverless

Automatic Semantic Enrichment in OpenSearch Serverless

In this article, you turn on Automatic Semantic Enrichment so a plain match query gains semantic understanding, with no model to host and no vectors to generate yourself.

Series: Search on OpenSearch (8 articles)

  1. …
  2. 7
    Automatic Semantic Enrichment in OpenSearch Serverless This article
OpenSearch Specialist Solutions Architect at AWS
 Part 6  showed search by meaning, but you had to supply the vectors. Generating and maintaining embeddings is the part that stops most teams. Automatic Semantic Enrichment, a feature of  Amazon OpenSearch Serverless , removes that step: it automatically generates sparse encodings for the text fields you designate, so a normal search understands intent without you hosting a model or calling an inference endpoint at query time.
This is Part 7 of a beginner series on search with Amazon OpenSearch Service. It uses a Search collection on OpenSearch Serverless.

What it does

Automatic Semantic Enrichment generates a sparse encoding for a designated text field at indexing time, using a pretrained sparse encoder model that AWS manages for you. A sparse encoding expands your text with related weighted terms, so a search for "durable rain jacket" can also surface waterproof shells and weatherproof coats without you writing synonym lists. Because the encoding happens during ingestion, you pay for it while indexing, and queries do not call a model.
Two properties make it approachable:
  • You do not host, deploy, or manage any machine learning model.
  • You do not change your queries. A plain  match  query on the enriched field is automatically rewritten to a  neural_sparse  query behind the scenes.

Turn it on at index creation

The one rule to internalize: Automatic Semantic Enrichment is configured when you create the index, and it cannot be enabled later by editing the mapping. You designate a text field for enrichment and choose a language option,  ENGLISH  or  MULTI-LINGUAL  (English is the default if you omit it).
Configure it on a designated field, for example the book  description :
"description": {
"type": "text",
"semantic_enrichment": {
"status": "ENABLED",
"language_option": "ENGLISH"
}
}
Because index creation with semantic enrichment uses AWS-managed models, you create the index through the OpenSearch Serverless console ("Configure automatic semantic enrichment" during collection setup) or the  aws opensearchserverless create-index  AWS CLI command, rather than a plain OpenSearch mapping request. After the index exists, you ingest and query with the standard OpenSearch APIs.

Ingest and search normally

Once the index exists, index documents the usual way. The sparse encoding is generated automatically for the enriched field.
POST books/_doc
{ "title": "A Wizard of Earthsea", "description": "A young mage learns to master his powers on an island world." }
Then search with a plain  match  query. You do not write a vector or a neural query.
GET books/_search
{
"query": {
"match": { "description": "coming-of-age magic story" }
}
}
OpenSearch automatically rewrites that  match  query into a  neural_sparse  query against the enriched field, so results include books whose descriptions convey the same idea, not only those containing the literal words.

Know the limits before you rely on it

  • Only  match  queries are auto-rewritten. A  multi_match  query is not converted, so plan enriched search around single-field  match  queries.
  • Index-creation-time only. You cannot enable enrichment by updating the mapping of an existing index. Decide up front.
  • Best on natural-language text. Product descriptions, titles, summaries, and reviews benefit. Do not enrich exact-match fields such as IDs, codes, or categories, or very long documents.
  • Cost is at indexing. Encoding runs during ingestion, so cost scales with how much you index, not how much you query.

Where this series goes next

You now have semantic understanding on top of ordinary search, with no model to operate. Keyword search and semantic search each catch cases the other misses. In Part 8, you combine them with hybrid search, using a search pipeline with a normalization processor to merge keyword and semantic scores into one ranked list.

Series: Search on OpenSearch (8 articles)

  1. …
  2. 7
    Automatic Semantic Enrichment in OpenSearch Serverless This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article