# 普通数据集

# 获取普通数据集列表

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/list

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符,如为 * 则表示不过滤帐户

# 请求参数:

参数名称 类型 是否必须 默认值 说明
search String - 搜索的文本
offset Number 0 返回结果的偏移量,用于分页
limit Number 11 返回结果的数量,用于分页
sortField String createdAt 用于排序的字段
sortType String desc 排序的类型

# 请求示例

GET http://host:port/heycloud/api/data/cdataset/list?search=&offset=0&limit=11

# 正确响应示例:

{
  "result": [
    {
      "id": "e0e3b36d-bbc5-49ec-8a6f-0b7e150d8787",
      "accountId": "",
      "title": "六出祁山8",
      "count": "7",
      "createdAt": "2021-05-14T08:09:18.624Z"
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 获取 cdataset 的元数据

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/meta

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID

# 请求示例

GET http://host:port/heycloud/api/data/cdataset/xxxxx/meta

# 正确响应示例:

{
  "result": {
    "id": "e0e3b36d-bbc5-49ec-8a6f-0b7e150d8787",
    "accountId": null,
    "title": "gdp_table",
    "count": "34",
    "createdAt": "2021-05-14T08:09:18.624Z",
    "idField": "_id",
    "attrFields": [
      { "name": "city", "type": "text" },
      { "name": "gdp", "type": "float8" }
    ],
    "indexes": []
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件查询记录

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/query

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
cdatasetId - String - 数据集 ID
where - String - 查询的条件,SQL格式,注意非小写字段名需要以双引号包围
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略
sortField - String createdAt 排序的字段
sortType desc | asc String desc 排序的类型
offset - Number 0 返回结果的偏移量,用于分页
limit - Number 11 返回结果的数量,用于分页,如小于等于零则表明不作限制,此时需注意数据集大小是否会引起性能问题
returnFields - Array [] 返回的属性字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/query

{
  "where": "\"VAL\">10",
  "search": "北",
  "searchFields": ["name"],
  "returnFields": ["name", "VAL"],
  "offset": 0,
  "limit": 11
}

# 正确响应示例:

{
  "result": [
    {
      "_id": "79870b9a-469b-4f00-a118-f10bcb9009c4",
      "VAL": 11,
      "name": "a"
    }, 
    {
      "_id": "6b7a8ba9-4d77-43b2-8f33-761f65872b46",
      "VAL": 12,
      "name": "b"
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 分组聚合统计

请注意在大数据集上通过查询条件过滤不需要的数据,以免引起性能问题

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/group

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
cdatasetId - String - 数据集 ID
groupByFields - Array - 用于分组的字段列表,至少包含一个字段
groupField - String - 需要聚合的字段,如聚合方法为 count 可不指定聚合字段
groupMethod sum | mean | median | mode | min | max | std | count String sum 聚合的方法
where - String - 查询的条件,SQL格式,注意非小写字段名需要以双引号包围
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/group

{
  "groupByFields": ["name"],
  "groupMethod": "count",
  "where": "\"VAL\">10",
  "search": "北",
  "searchFields": ["name"]
}

# 正确响应示例:

{
  "result": [
    {
      "count": 66,
      "name": "北京"
    }, 
    {
      "count": 8,
      "name": "北海"
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据查询条件获取结果总数

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/count

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
cdatasetId - String - 数据集 ID
where - String - 查询的条件,SQL格式,注意非小写字段名需要以双引号包围
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略

# 请求示例

POST http://localhost/heycloud/api/data/cdataset/xxxxx/count

{
  "where": "id>10",
  "search": "北",
  "searchFields": ["name"]
}

# 正确响应示例:

{
  "result": 132
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据唯一条件查询一条记录,通常用于根据 ID 直接获取对象

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/get

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
returnFields Array [] 返回的属性字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/get

{
  "findField": "id",
  "findValue": 24536,
  "returnFields": ["city"]
}

# 正确响应示例:

{
  "result": {
    "id": 24536,
    "city": "153"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件删除记录,通常用于根据 ID 直接删除对象,注意对于某些条件有可能存在多条记录匹配

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/delete

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
returnFields Array [] 返回的属性字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/delete

{
  "findField": "id",
  "findValue": 24536,
  "returnFields": ["city"]
}

# 正确响应示例:

{
  "result": [{
    "id": 24536,
    "city": "153"
  }]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 插入一条记录

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/insert

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/insert

{
  "id": 1, 
  "createdAt": {"$exp" : "now()"}
}

# 正确响应示例:

{
  "result": {
    "id": 1,
    "createdAt": "xxxxx"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件更新记录,注意对于某些条件有可能存在多条记录匹配

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/update

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
attrs Object - 更新的数据

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/update

{
  "findField": "id",
  "findValue": 1,
  "attrs": {"createdAt": {"$exp" : "now()"}}
}

# 正确响应示例:

{
  "result": {
    "id": 1,
    "createdAt": "xxxxx"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 更新标题

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/updateTitle

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
title String - 更新的标题

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/updateTitle

{
  title: "xxx"
}

# 正确响应示例:

{
  "result": {
    "title": "..."
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 重命名一个字段的名称

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/renameField

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
field String - 旧的的字段名
newName String - 更新的字段名

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/renameField

{
  field: "x",
  newName: "lon"
}

# 正确响应示例:

{
  "result": {
    "x": "lon"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 创建索引

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/createIndex

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
field String - 需要创建索引的字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/createIndex

{
  field: "name",
}

# 正确响应示例:

{
  "result": {
    "cdatasetId": "xxxxx",
    "field": "name",
    "notifyAt": "2021-05-14T08:09:18.624Z"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 删除索引

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/dropIndex

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
field String - 需要删除索引的字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/xxxxx/dropIndex

{
  field: "name",
}

# 正确响应示例:

{
  "result": {
    "cdatasetId": "xxxxx",
    "field": "name",
    "notifyAt": "2021-05-14T08:09:18.624Z"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 等间隔分段法

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/breaks/equal-interval

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
breakCount Number 4 分段的数量
where String - 查询的条件
limit Number 100 计算使用的记录数量,如为 <=0 的值则对数量不作限制
field String - 用于分段的字段

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/:cdatasetId/breaks/equal-interval

{
  "field": "id",
  "breakCount": 8,
  "where": "count>10"
}

# 正确响应示例:

{
  "result": [0, 10, ..., 80]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 列举字段的不同值

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/stats/distinct

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
field String - 用于计算的字段
where String - 查询的条件
limit Number 10 计算使用的记录数量,如为 <=0 的值则对数量不作限制

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/:cdatasetId/stats/distinct

{
  "field": "pop",
  "where": "pop>0"
}

# 正确响应示例:

{
  "result": [1.2, 2.4, 7.2]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 对字段进行聚合计算

# 请求 URL:

  • http://host:port/heycloud/api/data/cdataset/:cdatasetId/stats/aggregation

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
cdatasetId String - 数据集 ID
field String - 用于计算的字段
where String - 查询的条件
method String mean 统计的方法,取值可以为 sum/mean/median/mode/min/max/std/count

# 请求示例

POST http://host:port/heycloud/api/data/cdataset/:cdatasetId/stats/aggregation

{
  "field": "pop",
  "where": "pop>0",
  "method": "sum"
}

# 正确响应示例:

{
  "result": 10.8
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}