AI Search-Agentic Search (agent-based search)
This topic describes how to use the Agentic Search capability of a PolarDB-X Intelligent Search instance. You ask questions in natural language, and the system uses a Search Pipeline to automatically call an AI agent to translate the question into an OpenSearch DSL and execute it, returning results in the standard _search format.
Capability positioning and applicable scenarios
Agentic Search focuses on automatic generation of the query DSL of the _search API.
Supported | Not supported |
| Index creation/modification ( |
Aggregation queries ( | Search Pipeline configuration |
Sorting ( | ML Model registration/deployment |
Multi-turn conversations combined with | Connector configuration |
Automatic discovery of indexes and | Cluster management APIs |
Applicable scenarios
The business application layer receives natural language and returns responses in the standard
_searchformatInternal operations/analysis personnel explore index data with natural language
An AI agent autonomously queries OpenSearch data as the basis for decisions.
Two agent modes
Agent type | Characteristics |
| Multiple tools (automatic index discovery + mapping viewing + DSL generation), conversational memory, multi-turn conversations, and a detailed reasoning process |
| QueryPlanningTool only. Faster and cheaper. No conversational memory |
Prerequisites
First, complete Set up AI Search and make sure that:
You have completed Step 1: Confirm the auto-created resources. Agentic Search does not require the Embedding model. You only need the Agentic Search dedicated LLM Connector and Model, named
polardbx_agentic_search_<instance_name>, to be automatically created by the platform and deployed to theDEPLOYEDstate. The required cluster parameters are also turned on by default. You do not need to manually create a Connector, register a model, or configure cluster parameters.Query and record the
polardbx_agentic_search_<instance_name>model's corresponding_id. It is the<LLM_MODEL_ID>used in the steps of this topic.
Method 1 (recommended): Conversational Agent
The Conversational Agent supports multiple tools, conversational memory, and a detailed reasoning process. It is suitable for scenarios that require automatic index discovery and understanding of complex questions.
How it works
The agent works by autonomously calling tools: ListIndexTool discovers indexes → IndexMappingTool views fields → QueryPlanningTool generates the DSL → the query is executed and search results are returned.
Natural language question
│ GET /<index>/_search?search_pipeline=agentic-pipeline
│ { "query": { "agentic": { "query_text": "..." } } }
▼
┌─────────────────────────────────────────────┐
│ Search Pipeline │
│ ┌──────────────────────────────────────┐ │
│ │ request_processor: │ │
│ │ agentic_query_translator │ │
│ │ └→ Conversational Agent (function │ │
│ │ calling) + LLM + tools │ │
│ └──────────────────────────────────────┘ │
│ ┌──────────────────────────────────────┐ │
│ │ response_processor: │ │
│ │ agentic_context │ │
│ │ └→ appends ext: dsl_query / │ │
│ │ agent_steps_summary / memory_id│ │
│ └──────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
│
▼
Standard _search response(Optional) Turn on the memory_feature_enabled switch
The multi-turn conversation of the Conversational Agent depends on the conversational memory switch. If it is not turned on, run the following once:
curl -XPUT "http://<API_endpoint>:<port>/_cluster/settings" \
-u "<username>:<password>" \
-H "Content-Type: application/json" \
-d '{
"persistent": {
"plugins.ml_commons.memory_feature_enabled": true
}
}'Step 1: Create a test index and write data
curl -XPUT "http://<API_endpoint>:<port>/agentic-products" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"settings": { "number_of_shards": 1, "number_of_replicas": 1 },
"mappings": {
"properties": {
"name": { "type": "text" },
"category": { "type": "keyword" },
"price": { "type": "float" },
"stock": { "type": "integer" },
"tags": { "type": "keyword" }
}
}
}'
curl -XPOST "http://<API_endpoint>:<port>/agentic-products/_bulk?refresh=true" \
-u "<username>:<password>" -H "Content-Type: application/x-ndjson" \
--data-binary @- <<'EOF'
{"index":{}}
{"name":"Wireless Noise-Cancelling Headphones Pro","category":"Audio","price":1299,"stock":120,"tags":["Bluetooth","noise cancelling"]}
{"index":{}}
{"name":"87-Key Mechanical Keyboard","category":"Peripherals","price":499,"stock":56,"tags":["keyboard","mechanical"]}
{"index":{}}
{"name":"Ultra-Wide-Angle Drone","category":"Photography","price":4999,"stock":8,"tags":["drone","aerial photography"]}
{"index":{}}
{"name":"Smart Band Lite","category":"Wearables","price":199,"stock":300,"tags":["band","health"]}
{"index":{}}
{"name":"Portable Projector","category":"Audio & Video","price":2599,"stock":15,"tags":["projection","portable"]}
EOFStep 2: Register the Conversational Agent
Record the returned agent_id (CONV_AGENT_ID).
curl -XPOST "http://<API_endpoint>:<port>/_plugins/_ml/agents/_register" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"name": "Agentic Product Search Agent",
"type": "conversational",
"description": "Conversational agent for agentic search with product discovery",
"llm": {
"model_id": "<LLM_MODEL_ID>",
"parameters": { "max_iteration": 15 }
},
"memory": { "type": "conversation_index" },
"parameters": { "_llm_interface": "openai/v1/chat/completions" },
"tools": [
{ "type": "ListIndexTool", "name": "ListIndexTool" },
{ "type": "IndexMappingTool", "name": "IndexMappingTool" },
{ "type": "QueryPlanningTool" }
],
"app_type": "os_chat"
}'Description of key parameters
Field | Meaning |
| Supports function calling + multiple tools + conversational memory |
| Enables OpenAI compatibility |
| A maximum of 15 rounds of tool calls |
| Automatically creates a conversation index to store multi-turn conversations |
| ListIndexTool + IndexMappingTool provide index discovery, and QueryPlanningTool is responsible for DSL generation |
Step 3: Create a Search Pipeline
curl -XPUT "http://<API_endpoint>:<port>/_search/pipeline/agentic-pipeline" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"request_processors": [{
"agentic_query_translator": { "agent_id": "<CONV_AGENT_ID>" }
}],
"response_processors": [{
"agentic_context": {
"agent_steps_summary": true,
"dsl_query": true
}
}]
}'Step 4: Initiate an Agentic Search
curl -XGET "http://<API_endpoint>:<port>/agentic-products/_search?search_pipeline=agentic-pipeline" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"query": {
"agentic": {
"query_text": "What products are priced below 1000 yuan",
"query_fields": ["name", "category", "price", "stock", "tags"]
}
}
}'The response contains ext.dsl_query (the DSL generated by the LLM) and ext.memory_id (used for subsequent multi-turn conversations).
Step 5: Multi-turn conversations
Continue asking follow-up questions with the memory_id. The agent understands that "among them" refers to the results of the previous round.
Method 2: Flow Agent (lightweight and fast)
The Flow Agent has only one QueryPlanningTool attached. It is suitable for scenarios where the target index is known and low latency is required. It has no multi-turn memory and no automatic index discovery, but it is faster and cheaper.
Step 1: Register the Flow Agent
Record the returned agent_id (FLOW_AGENT_ID).
curl -XPOST "http://<API_endpoint>:<port>/_plugins/_ml/agents/_register" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"name": "Agentic Flow Agent",
"type": "flow",
"description": "Lightweight flow agent with QueryPlanningTool only",
"tools": [{
"type": "QueryPlanningTool",
"parameters": {
"model_id": "<LLM_MODEL_ID>",
"response_filter": "$.choices[0].message.content"
}
}]
}'For the Flow Agent, you must specify response_filter: "$.choices[0].message.content" in the QueryPlanningTool to tell the framework how to extract the generated DSL text from the Alibaba Cloud Model Studio response. Missing this field causes parsing errors.
Step 2: Create a Search Pipeline and initiate a search
curl -XPUT "http://<API_endpoint>:<port>/_search/pipeline/agentic-flow-pipeline" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"request_processors": [{ "agentic_query_translator": { "agent_id": "<FLOW_AGENT_ID>" } }],
"response_processors": [{ "agentic_context": { "dsl_query": true } }]
}'
curl -XGET "http://<API_endpoint>:<port>/agentic-products/_search?search_pipeline=agentic-flow-pipeline" \
-u "<username>:<password>" -H "Content-Type: application/json" \
-d '{
"query": {
"agentic": {
"query_text": "Products with stock over 100, sorted by price from high to low",
"query_fields": ["name", "category", "price", "stock", "tags"]
}
}
}'When to choose Flow Agent vs. Conversational Agent
Scenario | Recommendation |
Known target index + simple queries | Flow Agent |
Cross-index discovery + complex reasoning required | Conversational Agent |
Multi-turn conversations required | Conversational Agent |
Latency-sensitive (< 3s) | Flow Agent |
Token cost sensitive | Flow Agent |
Resource cleanup
The Connector and Model of the Agentic Search dedicated LLM are hosted by the platform. Do not delete them. Here you only clean up the agents, pipelines, and test indexes that you created.
# 1. Delete the search pipelines
curl -XDELETE "http://<API_endpoint>:<port>/_search/pipeline/agentic-pipeline" -u "<username>:<password>"
curl -XDELETE "http://<API_endpoint>:<port>/_search/pipeline/agentic-flow-pipeline" -u "<username>:<password>"
# 2. Delete the agents
curl -XDELETE "http://<API_endpoint>:<port>/_plugins/_ml/agents/<CONV_AGENT_ID>" -u "<username>:<password>"
curl -XDELETE "http://<API_endpoint>:<port>/_plugins/_ml/agents/<FLOW_AGENT_ID>" -u "<username>:<password>"
# 3. Delete the test index
curl -XDELETE "http://<API_endpoint>:<port>/agentic-products" -u "<username>:<password>"Quick troubleshooting channel
Symptom | Cause | Solution |
| The QueryPlanningTool of the Flow Agent is missing | Add |
The agent response is empty or times out | The LLM model is not deployed | Run |
| The agent registration parameters are incorrect | Check whether |
No context in multi-turn conversations | The | Obtain it from |
The Flow Agent cannot discover other indexes | The Flow Agent has only the QueryPlanningTool | Switch to the Conversational Agent |
Poor DSL generation quality |
| List the key fields in |
Known limitations
Uncertainty of DSL generation: The DSL generated by the LLM may vary slightly due to model randomness. 100% stability is not guaranteed.
Limited to
_searchqueries: DSL for write operations such as index management and pipeline configuration cannot be generated.Synchronous calls: An agentic query waits synchronously for the LLM response. The Conversational Agent usually takes 2-5s and the Flow Agent usually takes 1-3s.
query_fieldsaffects quality: Providing accuratequery_fieldssignificantly improves the quality of DSL generation.