All Products
Search
Document Center

OpenSearch:Rich text feature

Last Updated:Apr 01, 2026

When you enable the rich text feature, answers from large language models (LLMs) can include images, tables, and code blocks extracted from your source documents—not just plain text.

How it works

During document indexing, the retrieval-augmented generation (RAG) pipeline extracts all rich text elements (images, tables, and code) from each document and saves them as rich text tags alongside the corresponding text chunk. When a query is submitted via the SearchKnowledge API:

  1. OpenSearch retrieves the relevant chunks, including any embedded rich text tags.

  2. The LLM generates an answer using the retrieved chunks. Rich text tags are preserved in the answer.

  3. Depending on the rich_text_strategy value you set, OpenSearch either renders the tags inline (Markdown) or returns the raw content separately for your app to render.

Enable the rich text feature

Set the rich_text_strategy parameter on the Other Parameters tab of the Q&A Test page. Leave the field blank to disable rich text.

image
The data array in the response may include items with "type": "IMAGE". These are image results from the retrieval phase—not output from the rich text feature. Rich-text-generated images appear in data.answer (for inside_response) or in data.rich_text_ref (for extend_response), and have better contextual relevance than retrieval-phase images.

Choose a strategy

The rich_text_strategy parameter accepts two values. Choose based on how your app renders content:

StrategyResponse formatRich text deliveryBest for
inside_responseMarkdownInline in data.answerApps that render Markdown natively
extend_responsePlain textSeparately in data.rich_text_refApps with custom rendering logic

Configure the parameter

Add rich_text_strategy to the options.chat object in your SearchKnowledge API request:

{
  "question": {
    "text": "How do I configure a sensitive data identification rule?",
    "type": "TEXT"
  },
  "options": {
    "chat": {
      "rich_text_strategy": "inside_response"
    }
  }
}

API parameter reference

The following parameter is added to the SearchKnowledge API operation.

ParameterTypeRequiredDescription
options.chat.rich_text_strategyStringNoThe rich text processing strategy. If absent or blank, rich text is disabled and the default processing method is used. Valid values: inside_response, extend_response.

Parse the response

inside_response

Parse data.answer as Markdown. Rich text tags are resolved inline—tables appear as HTML within the Markdown. Ignore the rich_text_ref field.

extend_response

Parse data.answer as plain text. The answer contains rich text tag placeholders in the format [^<id>^]. Rich text tags in data.rich_text_ref need to be automatically parsed, and logic for replacing the rich text tags in data.answer needs to be developed. Look up each tag ID in data.rich_text_ref and replace the placeholder with the corresponding content.