推荐字段取值 TermsEnum
更新时间:2026-06-23
- 推荐字段取值。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /{name}/_terms_enum HTTP/1.1
2Host: xxx.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "field": <field>,
7 "string": <string>,
8 "size": <size>,
9 "index_filter": <index_filter>
10}
请求头域
除公共头域外,无其他特殊头域
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| name | String | 是 | URL参数 | 索引名称,不支持模糊匹配 |
| field | String | 是 | RequestBody参数 | 索引字段名称,不支持模糊匹配 |
| string | String | 否 | RequestBody参数 | 用于前缀匹配的字符串。比如 "ki" 会匹配以 ki 开头的 terms |
| size | Int | 否 | RequestBody参数 | 返回多少个terms 默认 10 |
| index_filter | Object | 否 | RequestBody参数 | 限制从哪些文档里枚举 terms,语法同普通query DSL |
返回状态码
成功返回200,失败返回见错误码
返回头域
除公共头域外,无其他特殊头域
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| terms | List<String> | 返回匹配到的term值数组 |
| error | Error | 错误原因 |
| status | Int | http状态码,比如:500 |
请求示例
Plain Text
1POST /my-index/_terms_enum HTTP/1.1
2Host: bls-log.bj.baidubce.com
3Authorization bce-auth-v1/5e5a8adf11ae475ba95f1bd38228b44f/2016-04-10T08:26:52Z/1800/host;x-bce-date/ec3c0069f9abb1e247773a62707224124b2b31b4c171133677f9042969791f02
4
5{
6 // 必填 索引字段名称
7 "field": "user",
8 // 可选 用于前缀匹配的字符串。比如 "ki" 会匹配以 ki 开头的 terms。
9 "string": "ki",
10 // 可选,返回多少个terms 默认 10
11 "size": 5,
12 // 限制从哪些文档里枚举 terms,语法同普通query DSL。
13 "index_filter": {
14 // 存在某个字段
15 "exists": {
16 // 只在存在response这个字段的日志中查询term
17 "field": "response"
18 }
19 }
20}
响应示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 946002ee-cb4f-4aad-b686-5be55df27f09
3Date: Wed, 10 Apr 2016 08:26:52 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Server: BWS
7
8// 成功示例
9{
10 // 返回匹配到的term值数组。
11 "terms": [
12 "kimchy",
13 "kirk",
14 "kitten"
15 ],
16 // true 表示结果完整,false 表示可能有更多terms被截断
17 "complete": true
18}
19
20// 异常示例
21{
22 "error": {
23 "root_cause": [
24 {
25 "type": "illegal_argument_exception",
26 "reason": "illegal_argument_exception",
27 }
28 ],
29 "type": "illegal_argument_exception",
30 "reason": "illegal_argument_exception"
31 },
32 "status": 500
33}
评价此篇文章
