Use multimodal retrieval
After you create a multi-modal search scenario from a scenario template, you can import the official sample data to try out the scenario and use the built-in search test to verify semantic search, hybrid search, and cross-modal search results.
Prerequisites
Before you begin, make sure that the following requirements are met:
An Alibaba Cloud Elasticsearch instance is created. In this tutorial, the scenario is displayed as Multimodal Search in the console UI.
You can access the Kibana console of the instance to run Elasticsearch requests.
Step 1: Create a multi-modal search scenario
Log on to the console of your Alibaba Cloud Elasticsearch instance. In the left-side navigation pane, choose AI Service Center > Multimodal Search.
Click Create Multimodal Scene and complete the configuration steps in the wizard:
Scenario Information: Select a scenario template and enter the basic information of the scenario. For the applicable scenario of each template, see the scenario template reference after this procedure.
Scenario Name must be 3 to 32 characters in length and start with a letter. It can contain letters, digits, hyphens (-), and underscores (_). The description is optional and can be up to 128 characters in length.
Data Synchronization: The data source of the scenario is API. After the scenario is created, full and incremental data is pushed by using the API.
Mapping Semantics Configuration: The preset fields of the template are displayed.
For a text field, you can turn on the semantic search upgrade to derive a semantic field, or click Cancel Semantic Configuration. A semantic field is bound to a vector model and is automatically generated. It cannot be edited. You can click Create Field to add business fields.
The first time you use this feature, activate AI Search Open Platform to provide model services such as vectorization. The preset fields of each template are described in the following field tables.
Index and Settings: View the vector index fields and other fields that are automatically generated from the mapping, and configure the number of shards and the number of replicas for the index. (Recommended) Set the number of shards to the number of data nodes. The default number of replicas is 1.
Confirm Scene: Check the scenario name, template, index name, model, and index fields. The system previews the complete index creation request (
PUT /{scenario name}). You can click Copy Request and run the request in the Kibana console. After you confirm that the configurations are correct, click Confirm Creation.
After the scenario is created, it appears in the multi-modal search list. The index name is the same as the scenario name.
Scenario template and preset field reference
The following table describes the applicable scenarios of each scenario template. This tutorial covers the Semantic Text Search and Image-Text Retrieval templates. The Video Search template is not covered in this tutorial.
| Scenario template | Description |
| Semantic Text Search | Suitable for text search scenarios such as documents, FAQs, and product descriptions. |
| Image-Text Retrieval | Suitable for image-and-text search scenarios such as illustrated products and media libraries. Text-to-image search and image-to-image search are supported. |
| Video Search | Suitable for video libraries. |
Semantic Text Search template preset fields:
| Field | Type | Description |
title | text | The title. |
content | text | The body text. Enabling a semantic search upgrade derives the field content_semantic. |
category | keyword | The category, which is used for filtering. |
doc_id | keyword | The business primary key. |
content_semantic | semantic_text | A semantic search field derived by the system. It is automatically generated by the text-embedding-v4 vector model. |
Image-Text Retrieval template preset fields:
| Field | Type | Description |
mm_content | semantic_text | An image-and-text semantic field generated by the qwen3-vl-embedding vector model. It carries text and image URLs. |
image_url | keyword | The image URL. |
description | text | The description. |
title | text | The title, including a keyword subfield. |
category | keyword | The category. |
doc_id | keyword | The business primary key. |
tags | keyword | The tags. |
Step 2: Import sample data
Import the official sample data that matches the scenario template to test the complete vectorization and search process without preparing your own data. Sample data is written only to fields that already exist in the index.
In the scenario list, click Manage for the target scenario to go to the scenario details page.
On the Basic Information tab, click Import Sample Data in the sample dataset trial card.
The system writes the data in batches and displays the progress. A success message appears after the import is complete. A text semantic search scenario imports 60 entries, and an image-and-text search scenario imports 40 entries.
Click Preview Data to view the sample data. Click Go to Search to open the search test.
Step 3: Test search
On the Search Test tab of the scenario details page, select a query template, enter the query text and the number of results to return, and then click Run Search. The system automatically generates a search request (POST /{index}/_search) based on the template. You can click Copy Request and run the request in the Kibana console. Search results are sorted by _score. You can switch to the source preview to view the original response. Search uses the access credentials authorized for the scenario.
Text semantic search scenarios support the following query templates:
Traditional Retrieval (BM25): Performs keyword-based full-text search on the
contentfield. A document is recalled when its analyzed terms match the query. Use this template when query terms match the document text directly.{ "size": 10, "query": { "match": { "content": "How do I register a demo account?" } } }Semantic Search: Performs semantic retrieval on the
content_semanticfield. Elasticsearch uses its built-in capability to vectorize the query text. Use this template to match documents by meaning rather than exact keywords.{ "size": 10, "query": { "semantic": { "field": "content_semantic", "query": "How do I register a demo account?" } } }Hybrid Search (RRF): Uses Reciprocal Rank Fusion (RRF) to combine the results of the keyword search path and the semantic search path. Use this template when you need both keyword and semantic matching.
{ "size": 10, "retriever": { "rrf": { "retrievers": [ { "standard": { "query": { "match": { "content": "How do I register a demo account?" } } } }, { "standard": { "query": { "semantic": { "field": "content_semantic", "query": "How do I register a demo account?" } } } } ] } } }
Image-and-text search scenarios support the following query templates:
For Image-to-Image Search, the image URL must meet the image domain whitelist requirements. In the following examples, replace https://img.example.com/xxx.jpg with an image URL that meets the whitelist requirements.
Text-to-Image Search: Maps the text query to the cross-modal semantic space through
mm_content(qwen3-vl-embedding) and recalls matching results. Use this template to search images by text.{ "size": 10, "query": { "semantic": { "field": "mm_content", "query": "Nighttime diapers with a leak-proof design" } } }Image-to-Image Search: Takes an image URL as input, vectorizes the image through
query_vector_builder, and then performs k-nearest neighbor (kNN) search onmm_content. Use this template to search for images similar to a given image.{ "size": 10, "query": { "knn": { "field": "mm_content", "k": 10, "num_candidates": 100, "query_vector_builder": { "embedding": { "input": { "type": "image", "format": "url", "value": "https://img.example.com/xxx.jpg" } } } } } }Text and Image Dual-Path (RRF): Combines the results of the text search path and the image search path. Use this template when you need both text-to-image and image-to-image matching.
To verify that the search works, compare the results of the templates. For example, run Traditional Retrieval (BM25) and Semantic Search with the same query text and compare the returned documents. The results are sorted by _score.
Manage a scenario
You can manage a scenario on the following tabs of the scenario details page:
| Tab | Description |
| Basic Information | View the scenario name, scenario type, index name, data source type, and status, and import sample data. |
| Index Information | View the index fields, field types, associated models, and field sources. Click the field configuration entry to manage fields. |
| Search Test | Enter a query to verify the search results. |
Delete a scenario
To delete a scenario, click Delete for the target scenario in the scenario list, and then click OK in the confirmation message.
A deleted scenario cannot be recovered.
Write data by using APIs
After you create a scenario, use standard Elasticsearch APIs to write full and incremental data to the scenario index. The fields to which you write data must be the same as the fields already defined in the index mapping. The text or image-and-text content that you write is automatically vectorized by the bound vector model. You do not need to generate vectors manually. After the data is written, you can use the search requests in Step 3 to search the data.