TermsEnum
Last Updated:2025-11-14
Description
Recommended field values
API restriction
- The input parameter does not support the timeout field, and BLS will keep querying until a timeout error occurs
- The returned result does not include the _shards field. Since it will not terminate due to timeout, the complete field is always true
Request
- Request syntax
POST /<name>/_terms_enum HTTP/1.1
Host: <Endpoint>
Authorization: <Authorization String>- Request headers
No additional headers are required beyond the standard request headers.
- Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| name | String | Yes | Path | Index name: Fuzzy matching is not supported |
| field | String | Yes | RequestBody | Index field name, does not support fuzzy matching |
| string | String | No | RequestBody | A string used for prefix matching. For example, "ki" will match terms starting with "ki" |
| size | Int | No | RequestBody | The number of terms to return, default is 10 |
| index_filter | Query | No | RequestBody | Limit the documents from which terms are enumerated, the syntax is the same as ordinary query DSL |
Note: Refer to the official website for Elasticsearch query syntax
Successful response
- Response headers
No additional headers are required beyond the standard response headers.
- Response parameters
| Field | Types | Description |
|---|---|---|
| terms | List<String> | Return an array of matched term values |
Anomaly response
- Response headers
No additional headers are required beyond the standard response headers.
- Response parameters
| Field | Types | Description |
|---|---|---|
| error | Error | Error reason |
| status | Int | HTTP status code: e.g., 500 |
The element structure of Error object in the above table is as follows:
| Field | Types | Description |
|---|---|---|
| root_cause | List<Error> | Root cause |
| type | String | Error type |
| reason | String | Error reason |
Example
- Request example
POST /my-index/_terms_enum HTTP/1.1
Host: bls-log.bj.baidubce.com
Authorization:bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304
Content-Type: application/json; charset=utf-8
{
// Required: Index field name
"field": "user",
// Optional: A string used for prefix matching. For example, "ki" will match terms starting with "ki".
"string": "ki",
// Optional: The number of terms to return, default is 10
"size": 5,
// Limit the documents from which terms are enumerated, the syntax is the same as ordinary query DSL.
"index_filter": {
// Exist a certain field
"exists": {
// Only query terms in logs that have the "response" field
"field": "response"
}
}
}- Response example
HTTP/1.1 204
Content-Type: application/json; charset=utf-8
X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
Date: Fri, 10 Apr 2020 04:42:37 GMT
// Success example
{
// Return an array of matched term values.
"terms": [
"kimchy",
"kirk",
"kitten"
],
// true indicates the result is complete, false indicates there may be more truncated terms
"complete": true
}
// Exception example
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "illegal_argument_exception",
}
],
"type": "illegal_argument_exception",
"reason": "illegal_argument_exception"
},
"status": 500
}