TermsEnum
Updated at:2025-11-03
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
Text
1POST /<name>/_terms_enum HTTP/1.1
2Host: <Endpoint>
3Authorization: <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
Text
1POST /my-index/_terms_enum HTTP/1.1
2Host: bls-log.bj.baidubce.com
3Authorization:bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304
4Content-Type: application/json; charset=utf-8
5{
6 // Required: Index field name
7 "field": "user",
8 // Optional: A string used for prefix matching. For example, "ki" will match terms starting with "ki".
9 "string": "ki",
10 // Optional: The number of terms to return, default is 10
11 "size": 5,
12 // Limit the documents from which terms are enumerated, the syntax is the same as ordinary query DSL.
13 "index_filter": {
14 // Exist a certain field
15 "exists": {
16 // Only query terms in logs that have the "response" field
17 "field": "response"
18 }
19 }
20}
- Response example
Text
1HTTP/1.1 204
2Content-Type: application/json; charset=utf-8
3X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
4Date: Fri, 10 Apr 2020 04:42:37 GMT
5// Success example
6{
7 // Return an array of matched term values.
8 "terms": [
9 "kimchy",
10 "kirk",
11 "kitten"
12 ],
13 // true indicates the result is complete, false indicates there may be more truncated terms
14 "complete": true
15}
16// Exception example
17{
18 "error": {
19 "root_cause": [
20 {
21 "type": "illegal_argument_exception",
22 "reason": "illegal_argument_exception",
23 }
24 ],
25 "type": "illegal_argument_exception",
26 "reason": "illegal_argument_exception"
27 },
28 "status": 500
29}
