批量新建索引
功能介绍
支持一次性新建多个索引,相较于逐个建立索引,批量新建多个索引会减少数据扫描的次数,可降低整体耗时。支持创建的索引类型与新建索引接口相同,请参见新建索引。
索引创建后需要等待30秒索引同步时间,同步完成后Cypher查询才可以利用索引进行加速。
URI
|
参数 |
是否必选 |
类型 |
说明 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID。获取方法请参见获取项目ID。 |
|
graph_name |
是 |
String |
图名称。 |
请求参数
|
参数 |
是否必选 |
类型 |
说明 |
|
indices |
是 |
Array |
索引数组。新建索引数不可超过最大支持索引数减去已存在索引数。当前最多支持新建10个索引。索引参数详情参见表2 |
|
参数 |
是否必选 |
类型 |
说明 |
|---|---|---|---|
|
indexName |
是 |
String |
索引名称。只能包含字母,数字,-和_。不能包含其他字符。索引名称的长度需在63字符以内。 |
|
indexType |
是 |
String |
索引的类型,区分大小写。
|
|
indexProperty |
否(若hasLabel为false或null,则该项为必选) |
String |
索引的属性列表。 可以创建索引的属性类型有: integer、 float、 double、 long、 enum、 char array、 string、 date。 |
- 如果属性类型为string或者char array,属性长度建议不要超过40个字节,超出的部分会被截断。
- Cypher查询可以借助hasLabel为True的索引来加速。
- indexProperty为空时,建立的索引为label索引,可以加速label过滤。
- indexProperty不为空时,建立的索引为属性索引,可以加速对应的属性过滤。
响应参数
|
参数 |
类型 |
说明 |
|---|---|---|
|
errorMessage |
String |
系统提示信息。
|
|
errorCode |
String |
系统提示信息。
|
|
jobId |
String |
执行该异步任务的jobId。
说明:
|
|
jobType |
Integer |
执行该异步任务的jobType。 |
|
result |
String |
成功时result值为success。 |
请求示例
一次性新建多个复合索引,索引名称分别为vertexIndex,edgeIndex,useridIndex。
POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/indices/action?action_id=batch-build
{
"indices": [
{
"indexName": "vertexIndex",
"indexType": "GlobalCompositeVertexIndex",
"hasLabel": true,
"indexProperty": []
},
{
"indexName": "edgeIndex",
"indexType": "GlobalCompositeEdgeIndex",
"hasLabel": true,
"indexProperty": []
},
{
"indexName": "useridIndex",
"indexType": "GlobalCompositeEdgeIndex",
"hasLabel": false,
"indexProperty": [
"userid"
]
}
]
}
响应示例
状态码: 200
成功响应示例
Http Status Code: 200
{
"jobId": "f99f60f1-bba6-4cde-bd1a-ff4bdd1fd500000168232",
"jobType": 8
}
状态码: 400
失败响应示例
Http Status Code: 400
{
"errorMessage": "graph [demo] is not found",
"errorCode": "GES.8603"
}
状态码
|
返回值 |
说明 |
|---|---|
|
400 Bad Request |
请求错误。 |
|
401 Unauthorized |
鉴权失败。 |
|
403 Forbidden |
没有操作权限。 |
|
404 Not Found |
找不到资源。 |
|
500 Internal Server Error |
服务内部错误。 |
|
503 Service Unavailable |
服务不可用。 |
错误码
请参见错误码。