Multi-path search
The multi-path search API allows a single request to run up to N independent queries in parallel, then merge and rank their results. You can customize the retrieval quota and priority of each path and trace the source of the final results. This is suitable for complex searches that combine text, vectors, indexes, or query strategies.
Key concepts
Multi-path search: A single search request runs multiple independent queries in parallel. Each query is a
path. Documents returned by allpathpaths are deduplicated, merged, and ranked to produce one result list.Query group: If the
priority(priority) values are equal, thepathentries form a query group. Eachpathin the group shares retrieval quotas (quota). For example, a group contains paths A and B, each with aquotaof 100. If A retrieves only 70 documents, the remaining 30 units ofquotacan be used by B, allowing B to retrieve up to 130 documents.Derived vector search: When a text query matches a text embedding rule configured in query analysis in the console, the system automatically derives a new vector query. Its
priorityis the same as that of the parent text path, andquotadefaults to 0, which means that it shares the parent text path quota (quota).
Request
POST
URL
/v3/openapi/apps/$app_name/multi-path-search$app_name: the application name. Advanced and Standard editions support multiple application versions, so specify the application name. Requests normally access the serving version; an offline application ID accesses the offline application search service.
The preceding URL omits request headers, encoding, and similar details.
The preceding URL omits the application host address.
Request parameters
The request body is a JSON object containing a queries array that defines each query path and other global request parameters.
Global request parameters
Parameter | Type | Required | Default value | Description |
raw_query | String | No | "" | The original user query, used for query analysis or logging. |
start | Integer | No | 0 | The pagination start position. Results start from document |
hit | Integer | No | 10 | The maximum number of documents to return in this request. Valid range: |
format | String | No |
| The result format. |
fetch_fields | String | No | All fields | The document fields to return, separated by semicolons (;). |
unified_rank_size | Integer | No | 2000 | The total number of documents for unified ranking. The system selects up to |
unified_rank_type | String | No | none | The unified ranking type. Valid values: Text relevance scoring is unavailable in Cava scripts for unified ranking. You can use models such as CTR for scoring. |
unified_rank_name | String | No | "" | The ranking script name. Required when |
vector_search | Object | No | {} | Vector retrieval configuration,For parameter details, see Vector retrieval. |
user_id | String | No | "" | The unique identifier of the end user, used for UV statistics or model training. |
trace | String | No | "" | The search log level, used for troubleshooting. |
rank_trace | String | No | "" | The ranking log level, used for troubleshooting. |
Objects in the queries array
Each JSON object in the queries array represents an independent query path.
Parameter | Type | Required | Default value | Description |
path | String | Yes | - | The unique identifier of the current query path. It can be traced in ranking logs. |
query | String | Yes | - | The query clause, which defines the retrieval conditions for this path. For syntax, see Index retrieval - query clause. |
priority | Integer | Yes | - | The retrieval priority. A non-negative integer. |
quota | Integer | Yes | - | The maximum number of documents retrieved by this path. A non-negative integer. |
qp | String | No | Default console rule | The query analysis configuration names, separated by commas (,). |
first_rank_name | String | No | Default console configuration | The basic ranking configuration name. |
second_rank_name | String | No | Default console configuration | The business ranking configuration name. |
total_rank_size | Integer | No | Engine default | The total number of documents for basic ranking. Valid range: |
total_rerank_size | Integer | No | Engine default | The total number of documents for business ranking. Valid range: |
sort | String | No |
| The sort clause. For syntax, see Global sorting: sort clause. |
filter | String | No | "" | The filter clause. For syntax, see Result filtering: filter clause. |
kvpairs | Map | No | {} | Custom key-value pairs. For usage details, see Custom parameter passing - kvpair clause. |
Sample code
Sample request
The following example shows a request with three query paths:
mainpath: highest priority, uses thesys_titlequery analysis rule.subpath: second-highest priority, with no query analysis rule.main/vector path: A vector query is derived because text embedding is configured in the query analysis rule for the main path.
{
"queries": [
{
"query": "title:'AI'",
"path": "sub",
"priority": 2,
"quota": 100,
"qp": ""
},
{
"query": "title:'OpenSearch'",
"path": "main",
"priority": 1,
"quota": 100,
"qp": "sys_title"
}
],
"raw_query": "OpenSearch",
"start": 0,
"hit": 10,
"format": "fulljson",
"trace": "debug",
"rank_trace": "info",
"unified_rank_type": "rrf",
"unified_rank_size": 1000,
"fetch_fields": "title",
"user_id": "123",
"vector_search": {
"vector": {
"top_n": 100,
"namespaces": [],
"threshold": 0.5,
"search_params": {
"qc_scan_ratio": 0.01
}
}
}
}Sample response
{
"errors": [
{
"code": 2112,
"message": "Specified index not in query:text_relevance(title,default,true)"
}
],
"ops_request_misc": "%7B%22request%5Fid%22%3A%22176129335716862423300005%22%2C%22scm%22%3A%2220140713.120141928..%22%7D",
"request_id": "176129335716862423300005",
"result": {
"compute_cost": [
{
"index_name": "test",
"value": 13.73
}
],
"facet": [],
"items": [
{
"attribute": {
"pk": [
"120142134_1"
]
},
"fields": {
"title": "OpenSearch Industry Algorithm Edition"
},
"property": {},
"sortExprValues": [
"0.0327869"
],
"tracerInfo": "begin search path[main] rank trace:\nend search path[main] rank trace.\n\nbegin search path[main/vector] rank trace:\nend search path[main/vector] rank trace.\n",
"variableValue": {}
},
{
"attribute": {
"pk": [
"120142134_2"
]
},
"fields": {
"title": "OpenSearch Retrieval Engine Edition"
},
"property": {},
"sortExprValues": [
"0.0322581"
],
"tracerInfo": "begin search path[main] rank trace:\nend search path[main] rank trace.\n\nbegin search path[main/vector] rank trace:\nend search path[main/vector] rank trace.\n",
"variableValue": {}
},
{
"attribute": {
"pk": [
"120142134_3"
]
},
"fields": {
"title": "AI Search Open Platform"
},
"property": {},
"sortExprValues": [
"0.0163934"
],
"tracerInfo": "begin search path[sub] rank trace:\nend search path[sub] rank trace.\n",
"variableValue": {}
}
],
"num": 3,
"searchtime": 0.085292,
"total": 3,
"viewtotal": 3
},
"status": "OK",
"tracer": ""
}Response parameters
|
Parameter |
Type |
Description |
|
status |
string |
The execution result. OK indicates success and FAIL indicates failure. Troubleshoot based on the returned error code. |
|
request_id |
string |
The query record ID, primarily used for troubleshooting. |
|
result |
string |
The actual returned results, including the query time searchtime, total number of engine results total, number of results returned by this request num, maximum number of results returned by this query viewtotal, query results items, aggregation results facet, and scorllid. |
|
errors |
string |
The error details. error_message represents the error message. For the meaning of error_code, see the Error codes topic. |
-
searchtime:The engine processing time, in seconds.
-
Differences between total, viewtotal, and num:total is the number of engine results that match the query, without considering the config clause. This value is optimized for large result sets. For performance and relevance, the engine returns at most viewtotal results. For pagination,
start+hit must beless than viewtotal. total is generally used for display. num is the number of entries actually returned by this query request, subject to start and hit in the config clause, and does not exceed hit. -
compute_cost: An array with one map element. index_name is the application ID and value is the LCU consumed by this query.
-
items:Contains the retrieved query data. fields contains the retrieved search content.
-
variableValue:The returned value of a custom parameter, such as distance. The variableValue node is displayed only when config clause format is
xmlorfulljson; it is not displayed by default injsonformat. -
sortExprValues: The ranking score of the corresponding document.
-
facet:Stores information returned by the Aggregate clause.
-
ARRAY field type: Returned in JSON and fulljson formats with values separated by \t; in xml format, values are separated by spaces.
Multi-path query processing
Parallel queries: Process every query in parallel. Determine the number of documents for each path from its quota, using the quota by default and no more than 5000. Send the queries to the engine to obtain candidate document IDs from each path.
Candidate selection: Select up to quota documents from each path in priority order. Stop if the selected total exceeds unified_rank_size.
Candidate ranking:
If unified_rank_type=cava_script, send all document IDs to the engine for ranking.
If unified_rank_type=rrf, rank directly with RRF.
If unified_rank_type=none, skip reranking.
Return results:
If reranking was performed, select the document range defined by start and hit. If reranking was skipped (unified_rank_type=none), return the complete candidate set and ignore start and hit.
ImportantWhen
unified_rank_typeisnone, the system skips unified sorting, ignores thestartandhitpagination parameters, and returns the complete candidate set. This mode may return a large volume of data. We recommend it only if you need to implement ranking outside OpenSearch.Send the result document IDs to the engine to retrieve the complete documents and return them to the user.
Limits
The aggregation, distinct, and highlighting features are not supported.
Path limit: A request supports up to five retrieval paths. Derived vector queries are not counted separately.
Application restriction: This feature supports only exclusive applications.
Retrieval limit: Each path can retrieve at most 5000 candidate documents from the engine.