加载对象数据
更新时间:2026-09-24
接口描述
按 ObjectSet 定义加载对象数据,支持过滤、关联(searchAround)、集合运算(intersect/union/subtract)、排序、字段选择与分页。
权限说明
需具备对应工作空间及本体(ontology)的数据查看权限。
注意事项
- workspaceId、ontology 不存在或无权限时,请求会失败。
请求结构
Plain Text
1POST /v1/workspaces/{workspaceId}/ontologies/{ontology}/objectSets/loadObjectSet HTTP/1.1
2Host: databuilder.bd.baidubce.com
3Authorization: authorization string
4
5{
6 "objectSet": { "type": "base", "objectType": "Employee" },
7 "select": ["name", "age"],
8 "pageSize": 100,
9 "withTotal": false
10}
请求头域
除公共头域(含 Authorization 鉴权)外,无其它特殊头域。
请求参数
Path 参数
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| workspaceId | String | 是 | 工作空间 ID |
| ontology | String | 是 | 本体名称 |
Body 参数
加载 ObjectSet 数据请求体。
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| objectSet | Object | 是 | ObjectSet 定义,支持递归嵌套结构,见下 |
| orderBy | Object | 否 | 排序配置。注意:distinct=true 时必须指定 orderBy,否则返回错误 |
| select | Array<String> | 否 | 要返回的属性名称列表 |
| distinct | Boolean | 否 | 是否对返回结果去重(DISTINCT),默认 false。distinct=true 时必须指定 orderBy |
| withTotal | Boolean | 否 | 是否返回满足条件的记录总数,默认不返回 |
| marker | String | 否 | 分页 marker |
| pageSize | integer | 否 | 每页大小(最大 10000) |
objectSet 定义
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| type | String | 是 | ObjectSet 类型:base、filter、searchAround、intersect、union、subtract、parameter。注意:parameter 类型仅 ActionType 内部使用,直接调用 loadObjectSet 不应使用此类型 |
| objectType | String | 否 | 当 type = base 时指定 objectType 名称;当 type = searchAround 时指定目标 objectType 名称 |
| parameterId | String | 否 | 当 type = parameter 时指定参数 ID(仅供 ActionType 内部使用) |
| objectSet | Object | 否 | 当 type = filter 或 searchAround 时,指定嵌套的 objectSet |
| where | Object | 否 | 当 type = filter 时,指定过滤条件,见下 |
| link | String | 否 | 当 type = searchAround 时,指定关联的 link 名称 |
| objectSets | Array | 否 | 当 type = intersect、union、subtract 时,指定多个 objectSet |
where 定义
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| type | String | 否 | 条件类型,支持的运算符见下表 |
| field | String | 否 | 叶子条件使用,属性名 |
| value | - | 否 | 叶子条件使用,属性值;类型根据条件类型而定:比较类为字符串/数值,in/not_in 为数组,contains 为向量数组 |
| filter | Array<Object> | 否 | 组合条件(and/or/not)使用,元素结构同 where(type/field/value/filter) |
where.type 支持的运算符:
| 类别 | 运算符 |
|---|---|
| 比较类 | eq(等于)、ne(不等于)、lt(小于)、le/lte(小于等于)、gt(大于)、ge/gte(大于等于) |
| 集合类 | in(包含于)、not_in(不包含于) |
| 字符串类 | like(模糊匹配)、not_like(不匹配)、starts_with(前缀匹配)、ends_with(后缀匹配) |
| 空值类 | is_null(为空)、is_not_null(非空) |
| 向量类 | contains(向量搜索)、match_any、match_all、match_phrase、match_phrase_prefix、match_regexp、match_phrase_edge |
| 逻辑类 | and、or、not |
orderBy 定义
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| fields | Array<Object> | 否 | 排序字段列表,元素见下 |
orderBy.fields 元素
| 参数名 | 类型 | 是否必须 | 含义 |
|---|---|---|---|
| field | String | 是 | 排序字段名 |
| direction | String | 是 | 排序方向:asc 或 desc |
响应头域
除公共头域外,无其它特殊头域。
响应参数
加载 ObjectSet 数据响应体。
| 参数名 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| requestId | String | 是 | 请求 ID |
| code | String | 是 | 业务响应状态码 |
| message | String | 否 | 失败时返回错误信息 |
| result | Object | 是 | 响应结果主体,见下 |
result
| 参数名 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| data | Array<Object> | 否 | 返回的数据列表,key 为属性名 |
| nextMarker | String | 否 | 下一页 marker,为 null 时表示已到最后一页 |
| sql | String | 否 | 本次执行的 SQL 语句(调试用,仅特定配置下返回),用户侧不要使用 |
| pageSize | integer | 否 | 本次查询的每页大小 |
| total | integer | 否 | 满足条件的记录总数;withTotal=true 时返回实际总数,否则为 null |
错误码
通用错误码可参考如下(本体接口专属错误码待确认,以最新实现为准):
| 错误码 | 错误描述 | HTTP 状态码 | 中文解释 |
|---|---|---|---|
| AccessDenied | 无操作权限 | 403 | 暂无操作权限 |
| IllegalArgument | 参数非法 | 400 | 用户提供参数错误 |
请求示例
Plain Text
1{
2 "objectSet": {
3 "type": "base",
4 "objectType": "string",
5 "parameterId": "string",
6 "objectSet": {},
7 "where": {
8 "type": "string",
9 "field": "string",
10 "value": {},
11 "filter": [
12 {
13 "type": "string",
14 "field": "string",
15 "value": {},
16 "filter": [
17 {}
18 ]
19 }
20 ]
21 },
22 "link": "string",
23 "objectSets": [
24 {}
25 ]
26 },
27 "orderBy": {
28 "fields": [
29 {
30 "field": "string",
31 "direction": "asc"
32 }
33 ]
34 },
35 "select": [
36 "string"
37 ],
38 "distinct": true,
39 "withTotal": true,
40 "marker": "string",
41 "pageSize": 0
42}
响应示例
JSON
1{
2 "requestId": "string",
3 "code": "string",
4 "message": "string",
5 "result": {
6 "data": [
7 {}
8 ],
9 "nextMarker": "string",
10 "sql": "string",
11 "pageSize": 0,
12 "total": 0
13 }
14}
评价此篇文章
