Send search requests to OpenSearch using the search API. The API supports standard searches and scroll searches for retrieving large result sets.
Standard search
Endpoint
GET /v3/openapi/apps/{app_name}/search{app_name}: the name of the application. Advanced and standard editions each have an online version and an offline version. Specify the ID of the target version. Typically, use the online application ID.
Protocol: HTTP
Format: JSON
Signature: See Signature method of OpenSearch API V3
Request parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | — | The body of the search request. Combine multiple clauses with &&. Supported clauses: config, query, sort, filter, aggregate, distinct, and kvpairs. |
fetch_fields | string | No | All display fields | Fields to retrieve, separated by semicolons (;). Equivalent to Default Display Fields in the OpenSearch console. Overrides the console setting. Specify only the required fields to improve performance. Example: fetch_fields=title;price;id |
qp | string | No | Available rules | Query analysis rules to apply, separated by commas (,). Overrides the console setting. Validate rules on the Search Test page in the console — SDK and API calls do not return validation details. |
disable | string | No | — | Disables specific features. Format: disable=function[;function]. Supported features: qp, summary, first_rank, second_rank, re_search. Examples: disable=qp (disable query analysis), disable=qp:spell_check (disable spelling correction only; see QueryProcessor for processor names), disable=re_search |
first_rank_name | string | No | Default rough sort expression | The name of the rough sort expression. Accepts one value. Overrides the console setting. |
second_rank_name | string | No | Default fine sort expression | The name of the fine sort expression. Accepts one value. Overrides the console setting. |
user_id | string | No | — | The ID of the user sending the search request. Accepts a long member ID or the International Mobile Equipment Identity (IMEI) of the user's device; the member ID takes precedence. URL-encode this value. Used to track unique visitors (UVs) in data statistics. When using data collection, use the same user_id value in behavioral data reports as in the search request. |
abtest | string | No | — | Required for A/B test. Format: abtest=urlencode(scene_tag:urlencode($scene),flow_divider:urlencode($value)). Use the user ID as flow_divider (device ID or IP address also accepted). scene_tag identifies the test scene; omitting it runs the A/B test across all search requests. |
raw_query | string | No | — | The original search query entered by the user. Format: raw_query=content. Set this for all search requests — it enables category prediction model training. Search results are sorted based on category prediction only when the search query is the same as the value of the raw_query parameter. |
search_strategy | string | No | — | The name of the search policy for multimodal search. |
re_search | string | No | — | Re-search policy based on a total hits threshold. Format: re_search=strategy:threshold,params:total_hits#${COUNT}. COUNT is the minimum number of total hits required to skip re-search; if hits fall below this count, a re-search is triggered. Requires query analysis to be enabled. If term weights after analysis are equal, re-search is not triggered — configure category weights for named entity recognition (NER). Example: re_search=url_encode(strategy:threshold,params:total_hits#6) |
biz | string | No | — | Business metadata for the request, such as the source type. Format: biz=type:$TYPE. Customize the type value; it appears in request source statistics in reports. Example: biz=type:home_page |
vector_threshold | float | No | System default | Vector score threshold for document retrieval. Documents with a vector score below this value are retrieved. Format: vector_threshold=14.0. |
summary | string | No | Console settings | Settings for search result summaries. Overrides the console setting. Use summary_element_prefix and summary_element_postfix together as a pair. If both summary_element and the prefix/postfix pair are set, the later configuration takes effect. |
from_request_id | string | No | — | The ID of a previous search request. Set this when the current search uses a query from a recommendation feature (such as drop-down suggestions, top searches, or hints) to associate the recommendation with the search and collect performance statistics. |
Summary sub-parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
summary_field | string | Yes | — | The field to summarize. |
summary_element | string | No | em | HTML tag for term highlighting. Angle brackets (<>) are removed from the tag value. |
summary_ellipsis | string | No | ... | Ellipsis appended at the end of each summary segment. |
summary_snipped | int | No | 1 | Number of summary segments. |
summary_len | string | No | — | Length of each summary segment. |
summary_element_prefix | string | No | — | Full opening HTML tag for highlighting, such as <em>. Must be paired with summary_element_postfix. |
summary_element_postfix | string | No | — | Full closing HTML tag for highlighting, such as </em>. Must be paired with summary_element_prefix. |
Response parameters
A successful search returns the following top-level structure:
{
"status": "OK",
"request_id": "162642700916781929257960",
"result": {
"searchtime": 0.009554,
"total": 1,
"viewtotal": 1,
"num": 1,
"compute_cost": [
{ "index_name": "110247758", "value": 0.304 }
],
"items": [
{
"fields": { "pid": "950", "size": "XL", "discount_price": "9.9" },
"sortExprValues": ["10000"],
"variableValue": {},
"property": {},
"attribute": {}
}
],
"facet": []
},
"errors": []
}| Parameter | Type | Description |
|---|---|---|
status | string | OK if the search succeeded; FAIL if it failed. A FAIL status with no results means the request itself failed. An OK status may still include errors for partial failures (for example, error 1000 for timeout or error 2112 for an invalid fine sort index). |
request_id | string | The request ID. |
result | JSON | Search results. See result fields below. |
errors | list | Error details. Each entry contains code (error code) and message. See Error codes. |
Result fields:
| Field | Description |
|---|---|
searchtime | Time the engine took to complete the search, in seconds. |
total | Total matching documents in the engine, independent of paging. This value may be optimized for large result sets and is typically used for display purposes only. |
viewtotal | Maximum documents the engine returns, capped for performance and relevance. For paging, start + hit (from the config clause) must be less than viewtotal. |
num | Documents returned in this response. Capped by the start and hit values in the config clause; does not exceed the hit value. |
compute_cost | Array of logical computing unit (LCU) consumption. index_name is the application ID; value is the LCUs consumed. |
items | Search results. Each item's fields object contains the retrieved field values. For ARRAY-type fields: tab-separated (\t) in JSON/fullJSON format; space-separated in XML format. |
variableValue | Values of custom parameters (for example, distance). Returned only when the config clause format is xml or fulljson; not included in json format. |
sortExprValues | Sort scores for the document. |
facet | Aggregation statistics from the aggregate clause. |
Sample request and response
Sample request URL:
/v3/openapi/apps/my_app/search?fetch_fields=name&query=config=format:fulljson&&query=name:'zhangsan'&&sort=idThis URL omits the endpoint, request headers, and encoding details. For the complete signature and connection setup, see Signature method of OpenSearch API V3.
Sample success response (JSON format):
{
"result": {
"searchtime": 0.009554,
"total": 1,
"compute_cost": [{ "index_name": "110247758", "value": 0.304 }],
"num": 1,
"viewtotal": 1,
"items": [
{
"variableValue": {},
"sortExprValues": ["10000"],
"property": {},
"attribute": {},
"fields": {
"size": "XL",
"discount_price": "9.9",
"pid": "950",
"range_age": "18\t25",
"detail": "Male Jacket Lapel 2021 in Spring and Autumn New Style Youth Thin Casual Zip-up Jacket",
"index_name": "110247758"
}
}
],
"facet": []
},
"ops_request_misc": "%7B%22request%5Fid%22%3A%22162642700916781929257960%22%2C%22scm%22%3A%2220140713.110229359..%22%7D",
"tracer": "",
"request_id": "162642700916781929257960",
"errors": [],
"status": "OK"
}Sample error response:
{
"result": {
"searchtime": 0.003999,
"total": 0,
"compute_cost": [{ "index_name": "110247758", "value": 0.232 }],
"num": 0,
"viewtotal": 0,
"items": [],
"facet": []
},
"ops_request_misc": "%7B%22request%5Fid%22%3A%22162642716516781913069826%22%2C%22scm%22%3A%2220140713.110229359..%22%7D",
"tracer": "",
"request_id": "162642716516781913069826",
"errors": [{ "code": 6127, "message": "Attribute not exist." }],
"status": "FAIL"
}Scroll search
Standard searches return up to 5,000 documents. Use scroll search to retrieve larger result sets for analysis or export.
Scroll search has significant limitations compared to standard search. Review the Limitations section before implementing scroll search.
How it works
A scroll search runs in two phases:
First request: Send a request with
search_type=scanand ascrollvalidity period. The response returns only ascroll_id— no documents.Subsequent requests: Use the
scroll_idfrom the previous response to retrieve the next batch of documents. When the responseitemsarray is empty, the scroll is complete and no more results are available.
Endpoints
First request:
GET /v3/openapi/apps/{app_name}/search?search_type=scan&scroll=1m&{query_parameters}Subsequent requests:
GET /v3/openapi/apps/{app_name}/search?scroll_id={scroll_id}&scroll=1m&{query_parameters}Protocol: HTTP
Format: fullJSON or JSON only (XML is not supported)
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
scroll | string | Yes | Validity period of the scroll_id, in weeks (w), days (d), hours (h), minutes (m), or seconds (s). Example: 1m. Required for both first and subsequent requests. |
search_type | string | First request only | Must be scan. Required only on the first request. |
scroll_id | string | Subsequent requests | The scroll_id returned by the previous response. Required for all requests after the first. When items is empty in the response, the scroll is complete. |
query clause | string | Yes | Search conditions. |
config clause | string | Yes | Result format and number of documents per batch. The start parameter is ignored; use hit to set the batch size. |
filter clause | string | No | Filter conditions. |
sort clause | string | No | Sort by a single INT-type field. Requires OpenSearch API and SDK v3. |
fetch_fields | string | No | Fields to return in results. |
Response parameters
Same structure as the standard search response, with one additional field in result:
| Field | Description |
|---|---|
scroll_id | Use this ID in the next request to retrieve the following batch of results. When items is empty, the scroll is complete. |
Limitations
| Constraint | Detail |
|---|---|
| Response format | fullJSON and JSON only; XML is not supported |
start parameter | Ignored in the config clause; use hit to control batch size |
| Unsupported clauses | aggregate, distinct, rank |
| Sort | Single INT-type field only |
| Cross-application scroll | Not supported |
Invalid scroll_id | Returns an error |
| First request | Returns only a scroll_id; no documents are included |
Sample scroll search
The following requests omit request headers and encoding details.
First request:
http://{host}/v3/openapi/apps/app_schema_demo/search?query=config=start:0,hit:1,format:fulljson,rerank_size:200&&query=name:'Search'&&sort=+id&&filter=id>0&search_type=scan&scroll=1m&fetch_fields=id;name;phone;int_arr;literal_arr;float_arr;cate_idSample success response (first request):
{
"status": "OK",
"request_id": "150150574119953661605242",
"result": {
"searchtime": 0.005029,
"total": 1,
"num": 0,
"viewtotal": 1,
"scroll_id": "eJxtUMtuhDAM/BrvOYQC5cABdulvRFFIirsm2TpBavv1Ndut1EMlS36NZ0Y2ZHMxbueceAjIuWCMnrPjRITLyfzZm83y9VQVGT8x80U3PxQNUqieVZV1/an4ItbTUBPSx5wgXqKdvOSbmuKR8ZYjGWWirB4tvToAiX7u3G2eCNK77vnz8GlGPAV6suKBeqxAn0OiTd7NGEnesspyoyFLF6hecn4JUKjVgp0K3FnkfMfIyPoDuYWegX9GeYOpicY9TG8gwOSuBL04X1MMg3ROwCesLlG6X7a2o=",
"items": [],
"facet": []
},
"errors": [],
"tracer": ""
}Subsequent request (using `scroll_id` from the previous response):
http://{host}/v3/openapi/apps/app_schema_demo/search?fetch_fields=id;name;phone;int_arr;literal_arr;float_arr;cate_id&query=config=start:0,hit:1,format:fulljson,rerank_size:200&&query=name:'Search'&&sort=+id&&filter=id>0&scroll=1m&scroll_id=eJxtUMtuhDAM/BrvOYQC5cABdulvRFFIirsm2TpBavv1Ndut1EMlS36NZ0Y2ZHMxbueceAjIuWCMnrPjRITLyfzZm83y9V+QVGT8x80U3PxQNUqieVZV1/an4ItbTUBPSx5wgXqKdvOSbmuKR8ZYjGWWirB4tvToAiX7u3G2eCNK77vnz8GlGPAV6suKBeqxAn0OiTd7NGEnesspyoyFLF6hecn4JUKjVgp0K3FnkfMfIyPoDuYWegX9GeYOpicY9TG8gwOSuBL04X1+MMg3ROwCesLlG6X7a2o=Sample success response (subsequent request):
{
"status": "OK",
"request_id": "150150574119952551519970",
"result": {
"searchtime": 0.006293,
"total": 1,
"num": 1,
"viewtotal": 1,
"scroll_id": "eJxNT9tugzAM/RrznIRC4YEHaNlvRFFIhteQtE6Qtn39TNdJk2z5dnx8rIPJRdudcqKhl60Uir2Vp06ISv8b6s3QbZCVzpaCdp93XXBzg2wEW9MJ2dWq8q7YVXt0YckDLlBP0WyOw31N8YgYizZEnAUsjkx4VT4k8zexpjiNS/XYHX0NNkWP71BfVyxQjxLUxSfazFH4PYSPnCL3iMniDZq3jN98aFRCgGrZniy8/itkBHWGuYVeQH+B+QzTCUZ1NJ9gj4FVMfrQPr8Y+Hk+dgU14fIDVhtfTw==",
"items": [
{
"fields": {
"cate_id": "0",
"float_arr": "0",
"id": "1",
"int_arr": "0",
"literal_arr": "Search",
"name": "Search",
"phone": "123****5678",
"index_name": "app_schema_demo"
},
"property": {},
"attribute": {},
"variableValue": {},
"sortExprValues": ["1"]
}
],
"facet": []
},
"errors": [],
"tracer": ""
}