全部产品
开放搜索

v3版API

更新时间:2017-09-06 16:40:00   分享:   

更新历史


  • API版本:V3
  • 最近更新时间:2017-07-11

2017-07-11


  • app 相关接口的 group[type] 属性迁移为 type;
  • 创建高级版使用 enhanced 类型;

版本 development


属性

名称 类型 描述 示例
auto_switch boolean 标准版应用导入后是否自动切换 true
cluster_name string cluster "example"
description string 应用描述
模式: .{0,60}
"App description"
fetch_fields array 搜索结果展示字段 ["id","name"]
group[name] string 应用名称
模式: ^(?!ops_)[a-zA-z]\w*$
"my_app_name"
group[versions] array 分组的所有版本 ["10001","10002"]
id string 应用id
模式: ^\d{1,10}$
"10001"
index_task[progress] integer 任务进行进度 42
quota[doc_size] number 文档大小(单位:GB)
范围: 0.2 <= value
0.3
quota[qps] integer 搜索请求(单位:次/秒)
范围: 5 <= value
6
quota_reviewing_task[data][doc_size] number 文档大小(单位:GB)
范围: 0.2 <= value
0.3
quota_reviewing_task[data][qps] integer 搜索请求(单位:次/秒)
范围: 5 <= value
6
quota_reviewing_task[id] string 任务 ID "1001"
quota_reviewing_task[message] string 审批结果备注 "审批内容符合或不符合产品实际需求,同意或拒绝"
realtime_shared boolean 是否共享实时流,标准版是rds或Mysql数据源时不支持该字段 true
schema[indexes][filter_fields] array 属性字段集合 ["field"]
schema[indexes][search_fields] object 索引字段集合 {"default":{"fields":["text_field"],"analyzer":"chn_standard"}}
schema[route_field] nullable string 路由字段与分组cluster配合使用 "test_field"
schema[tables] object 表结构 {"main":{"fields":{"id":{"type":"INT","name":"id","primary_key":true}}}}
status integer 应用状态:
1:正常
5:暂停
6:冻结
8:应用初始化中
9:失效
11:等待数据初始化
12:数据初始化中
取值: 1 5 6 7 8 9
1
type string 应用类型,enhanced-高级版,standard-标准版,默认为高级版
取值: "enhanced" "standard" "advance"
"enhanced"
virtual_cluster string cluster "example"

应用 创建

创建新应用

  • 若已存在同名标准版应用,则创建新版本;
  • 在新建版本情况下,auto_switchrealtime_shared 也是必填的;
  • 在新建版本情况下,quota 和 `virtual_cluster 是自动从上一个版本继承的;
  • 在新建版本情况下,修改 quota 是无效的。
  1. POST /apps

必选参数

名称 类型 描述 示例
group[name] string 应用名称
模式: ^(?!ops_)[a-zA-z]\w*$
"my_app_name"
quota[doc_size] number 文档大小(单位:GB)
范围: 0.2 <= value
0.3
quota[qps] integer 搜索请求(单位:次/秒)
范围: 5 <= value
6
schema[indexes][filter_fields] array 属性字段集合 ["field"]
schema[indexes][search_fields] object 索引字段集合 {"default":{"fields":["text_field"],"analyzer":"chn_standard"}}
schema[tables] object 表结构 {"main":{"fields":{"id":{"type":"INT","name":"id","primary_key":true}}}}

可选参数

名称 类型 描述 示例
auto_switch boolean 标准版应用导入后是否自动切换 true
data_sources array 数据源 [{"table_name":"main","type":"mysql","fields":[],"plugins":{},"key_field":"literal_pk","parameters":{"filter":"","db_table_name":"antispam_keyword","db_key":"","db_user":"","auto_sync":"true","db_password":""}}]
description string 应用描述
模式: .{0,60}
"App description"
fetch_fields array 搜索结果展示字段 ["id","name"]
first_ranks/active boolean 是否为默认表达式 true
first_ranks/description string 描述 "I am a firstRank"
first_ranks/meta/arg string 表达式函数参数
默认值: ""
"int_field"
first_ranks/meta/attribute string 属性 "timeliness()"
first_ranks/meta/weight number 权重
模式: ^[-+]?[0-9]*\.?[0-9]+$
42.0
first_ranks/name string 粗排表达式名字
模式: ^(?!ops_)(?!OPS_)[a-zA-Z][a-zA-Z0-9_]{0,29}$
"first_rank"
query_processors/active boolean 是否已上线 true
query_processors/indexes array 适用范围字段
* _ALL_INDEXES_ 代表整个应用,不可以与其他取值同时使用
["index_name"]
query_processors/name string 查询分析名字
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"query_processor"
query_processors/processors/name string 规则名
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"example"
realtime_shared boolean 是否共享实时流,标准版是rds或Mysql数据源时不支持该字段 true
schema[route_field] nullable string 路由字段与分组cluster配合使用 "test_field"
second_ranks/active boolean 是否是默认表达式 true
second_ranks/description string 描述 "example"
second_ranks/meta string 表达式配置 "example"
second_ranks/name string 精排表达式名字 "example"
suggests/black_list array 黑名单 [null]
suggests/fields array 下拉提示字段 [null]
suggests/name string 下拉提示名字 "example"
suggests/white_list array 白名单 [null]
summaries/active boolean 是否是默认搜索结果摘要 true
summaries/meta/element string 飘红标签 "em"
summaries/meta/ellipsis string 片段链接符 "..."
summaries/meta/field string 字段 "example"
summaries/meta/len integer 片段长度
范围: 1 <= value <= 300
42
summaries/meta/snippet integer 片段数量
范围: 1 <= value <= 5
1
summaries/name string 分组名,目前仅支持 default "example"
type string 应用类型,enhanced-高级版,standard-标准版,默认为高级版
取值: "enhanced" "standard" "advance"
"enhanced"
virtual_cluster string cluster "example"

Response 示例

  1. HTTP/1.1 201 Created
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }

应用 删除

删除一个应用或版本。对于标准版应用:

  • 只有一个版本时,可以删除
  • 有两个版本,则只能删除非在线版本
  1. DELETE /apps/{app_id_or_name}

Response 示例

  1. HTTP/1.1 200 OK
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }

应用 详情

获取应用详情。

  1. GET /apps/{app_id_or_name}

Response 示例

  1. HTTP/1.1 200 OK
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }

应用 列表

获取应用列表。

  • 参数支持 page、size
  1. GET /apps

可选参数

名称 类型 描述 示例
page string 页码
模式: ^\d+$
"1"
size string 每页条目数量
模式: ^\d+$
"10"

Response 示例

  1. HTTP/1.1 200 OK
  1. {
  2. "status": "OK",
  3. "headers": {
  4. "X-Total-Count": 100
  5. },
  6. "result": [
  7. {
  8. "id": "10001",
  9. "description": "App description",
  10. "type": "enhanced",
  11. "status": 1,
  12. "fetch_fields": [
  13. "id",
  14. "name"
  15. ],
  16. "index_task": {
  17. "progress": 42
  18. },
  19. "auto_switch": true,
  20. "realtime_shared": true,
  21. "quota": {
  22. "doc_size": 0.3,
  23. "qps": 6
  24. },
  25. "quota_reviewing_task": {
  26. "id": "1001",
  27. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  28. "data": {
  29. "doc_size": 0.3,
  30. "qps": 6
  31. }
  32. },
  33. "schema": {
  34. "tables": {
  35. "main": {
  36. "fields": {
  37. "id": {
  38. "type": "INT",
  39. "name": "id",
  40. "primary_key": true
  41. }
  42. }
  43. }
  44. },
  45. "indexes": {
  46. "search_fields": {
  47. "default": {
  48. "fields": [
  49. "text_field"
  50. ],
  51. "analyzer": "chn_standard"
  52. }
  53. },
  54. "filter_fields": [
  55. "field"
  56. ]
  57. },
  58. "route_field": "test_field"
  59. },
  60. "group": {
  61. "name": "my_app_name",
  62. "versions": [
  63. "10001",
  64. "10002"
  65. ]
  66. },
  67. "virtual_cluster": "example",
  68. "cluster_name": "example"
  69. }
  70. ]
  71. }

应用 更新

更新一个应用。

  • 标准版应用不能更新 schemadata_sources
  1. PATCH /apps/{app_id_or_name}

可选参数

名称 类型 描述 示例
data_sources array 数据源 [{"table_name":"main","type":"mysql","fields":[],"plugins":{},"key_field":"literal_pk","parameters":{"filter":"","db_table_name":"antispam_keyword","db_key":"","db_user":"","auto_sync":"true","db_password":""}}]
description string 应用描述
模式: .{0,60}
"App description"
fetch_fields array 搜索结果展示字段 ["id","name"]
first_ranks/active boolean 是否为默认表达式 true
first_ranks/description string 描述 "I am a firstRank"
first_ranks/meta/arg string 表达式函数参数
默认值: ""
"int_field"
first_ranks/meta/attribute string 属性 "timeliness()"
first_ranks/meta/weight number 权重
模式: ^[-+]?[0-9]*\.?[0-9]+$
42.0
first_ranks/name string 粗排表达式名字
模式: ^(?!ops_)(?!OPS_)[a-zA-Z][a-zA-Z0-9_]{0,29}$
"first_rank"
query_processors/active boolean 是否已上线 true
query_processors/indexes array 适用范围字段
* _ALL_INDEXES_ 代表整个应用,不可以与其他取值同时使用
["index_name"]
query_processors/name string 查询分析名字
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"query_processor"
query_processors/processors/name string 规则名
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"example"
quota[doc_size] number 文档大小(单位:GB)
范围: 0.2 <= value
0.3
quota[qps] integer 搜索请求(单位:次/秒)
范围: 5 <= value
6
schema[indexes][filter_fields] array 属性字段集合 ["field"]
schema[indexes][search_fields] object 索引字段集合 {"default":{"fields":["text_field"],"analyzer":"chn_standard"}}
schema[route_field] nullable string 路由字段与分组cluster配合使用 "test_field"
schema[tables] object 表结构 {"main":{"fields":{"id":{"type":"INT","name":"id","primary_key":true}}}}
second_ranks/active boolean 是否是默认表达式 true
second_ranks/description string 描述 "example"
second_ranks/meta string 表达式配置 "example"
second_ranks/name string 精排表达式名字 "example"
suggests/black_list array 黑名单 [null]
suggests/fields array 下拉提示字段 [null]
suggests/name string 下拉提示名字 "example"
suggests/white_list array 白名单 [null]
summaries/active boolean 是否是默认搜索结果摘要 true
summaries/meta/element string 飘红标签 "em"
summaries/meta/ellipsis string 片段链接符 "..."
summaries/meta/field string 字段 "example"
summaries/meta/len integer 片段长度
范围: 1 <= value <= 300
42
summaries/meta/snippet integer 片段数量
范围: 1 <= value <= 5
1
summaries/name string 分组名,目前仅支持 default "example"
type string 应用类型,enhanced-高级版,standard-标准版,默认为高级版
取值: "enhanced" "standard" "advance"
"enhanced"
virtual_cluster string cluster "example"

Response 示例

  1. HTTP/1.1 200 OK
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }

应用 创建新版本

从最新版本创建新版本,继承。

  1. POST /apps/{app_id_or_name}/actions/fork

可选参数

名称 类型 描述 示例
auto_switch boolean 标准版应用导入后是否自动切换 true
data_sources array 数据源 [{"table_name":"main","type":"mysql","fields":[],"plugins":{},"key_field":"literal_pk","parameters":{"filter":"","db_table_name":"antispam_keyword","db_key":"","db_user":"","auto_sync":"true","db_password":""}}]
description string 应用描述
模式: .{0,60}
"App description"
fetch_fields array 搜索结果展示字段 ["id","name"]
first_ranks/active boolean 是否为默认表达式 true
first_ranks/description string 描述 "I am a firstRank"
first_ranks/meta/arg string 表达式函数参数
默认值: ""
"int_field"
first_ranks/meta/attribute string 属性 "timeliness()"
first_ranks/meta/weight number 权重
模式: ^[-+]?[0-9]*\.?[0-9]+$
42.0
first_ranks/name string 粗排表达式名字
模式: ^(?!ops_)(?!OPS_)[a-zA-Z][a-zA-Z0-9_]{0,29}$
"first_rank"
query_processors/active boolean 是否已上线 true
query_processors/indexes array 适用范围字段
* _ALL_INDEXES_ 代表整个应用,不可以与其他取值同时使用
["index_name"]
query_processors/name string 查询分析名字
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"query_processor"
query_processors/processors/name string 规则名
模式: ^(?!ops_)(?!OPS_)[a-z][a-z0-9_]{0,15}$
"example"
realtime_shared boolean 是否共享实时流,标准版是rds或Mysql数据源时不支持该字段 true
schema[indexes][filter_fields] array 属性字段集合 ["field"]
schema[indexes][search_fields] object 索引字段集合 {"default":{"fields":["text_field"],"analyzer":"chn_standard"}}
schema[route_field] nullable string 路由字段与分组cluster配合使用 "test_field"
schema[tables] object 表结构 {"main":{"fields":{"id":{"type":"INT","name":"id","primary_key":true}}}}
second_ranks/active boolean 是否是默认表达式 true
second_ranks/description string 描述 "example"
second_ranks/meta string 表达式配置 "example"
second_ranks/name string 精排表达式名字 "example"
summaries/active boolean 是否是默认搜索结果摘要 true
summaries/meta/element string 飘红标签 "em"
summaries/meta/ellipsis string 片段链接符 "..."
summaries/meta/field string 字段 "example"
summaries/meta/len integer 片段长度
范围: 1 <= value <= 300
42
summaries/meta/snippet integer 片段数量
范围: 1 <= value <= 5
1
summaries/name string 分组名,目前仅支持 default "example"
type string 应用类型,enhanced-高级版,standard-标准版,默认为高级版
取值: "enhanced" "standard" "advance"
"enhanced"
virtual_cluster string cluster "example"

Response 示例

  1. HTTP/1.1 201 Created
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }

应用 设置当前版本

设置当前版本(仅标准版)

  1. POST /apps/{app_id_or_name}/actions/set-current

可选参数

名称 类型 描述 示例
id string 应用id
模式: ^\d{1,10}$
"10001"

Response 示例

  1. HTTP/1.1 200 OK
  1. {
  2. "status": "OK",
  3. "result": {
  4. "id": "10001",
  5. "description": "App description",
  6. "type": "enhanced",
  7. "status": 1,
  8. "fetch_fields": [
  9. "id",
  10. "name"
  11. ],
  12. "index_task": {
  13. "progress": 42
  14. },
  15. "auto_switch": true,
  16. "realtime_shared": true,
  17. "quota": {
  18. "doc_size": 0.3,
  19. "qps": 6
  20. },
  21. "quota_reviewing_task": {
  22. "id": "1001",
  23. "message": "审批内容符合或不符合产品实际需求,同意或拒绝",
  24. "data": {
  25. "doc_size": 0.3,
  26. "qps": 6
  27. }
  28. },
  29. "schema": {
  30. "tables": {
  31. "main": {
  32. "fields": {
  33. "id": {
  34. "type": "INT",
  35. "name": "id",
  36. "primary_key": true
  37. }
  38. }
  39. }
  40. },
  41. "indexes": {
  42. "search_fields": {
  43. "default": {
  44. "fields": [
  45. "text_field"
  46. ],
  47. "analyzer": "chn_standard"
  48. }
  49. },
  50. "filter_fields": [
  51. "field"
  52. ]
  53. },
  54. "route_field": "test_field"
  55. },
  56. "group": {
  57. "name": "my_app_name",
  58. "versions": [
  59. "10001",
  60. "10002"
  61. ]
  62. },
  63. "virtual_cluster": "example",
  64. "cluster_name": "example"
  65. }
  66. }
本文导读目录
本文导读目录
以上内容是否对您有帮助?