本节介绍用于管理图中各类属性索引及LTE状态的方法。
索引
showIndex()
获取图中全部索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的索引列表。
# Retrieves indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
indexList = Conn.showIndex(requestConfig)
for index in indexList:
print(index.toJSON())
{"id": "1", "name": "age_index", "properties": "year", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
{"id": "2", "name": "test_index", "properties": "year,float", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
{"id": "1", "name": "targetPostInd", "properties": "targetPost", "schema": "disagree", "status": "DONE", "size": null, "dbType": "DBEDGE"}
showNodeIndex()
获取图中全部点索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的索引列表。
# Retrieves node indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
indexList = Conn.showNodeIndex(requestConfig)
for index in indexList:
print(index.toJSON())
{"id": "1", "name": "age_index", "properties": "year", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
{"id": "2", "name": "test_index", "properties": "year,float", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
showEdgeIndex()
获取图中全部边索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的索引列表。
# Retrieves edge indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
indexList = Conn.showEdgeIndex(requestConfig)
for index in indexList:
print(index.toJSON())
{"id": "1", "name": "targetPostInd", "properties": "targetPost", "schema": "disagree", "status": "DONE", "size": null, "dbType": "DBEDGE"}
dropIndex()
从图中删除一个指定的索引。
参数
dbType: DBType
:索引类型(点或边)。indexName: str
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
# Drops the node index 'test_index' from the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.dropIndex(DBType.DBNODE, "test_index", requestConfig)
print(response.status.code.name)
SUCCESS
dropNodeIndex()
从图中删除一个指定的点索引。
参数
indexName: str
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
# Drops the node index 'test_index' from the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.dropNodeIndex("test_index", requestConfig)
print(response.status.code.name)
SUCCESS
dropEdgeIndex()
从图中删除一个指定的边索引。
参数
indexName: str
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
# Drops the edge index 'targetPostInd' from the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.dropEdgeIndex("targetPostInd", requestConfig)
print(response.status.code.name)
SUCCESS
全文索引
showFulltext()
获取图中全部全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的全文索引列表。
# Retrieves full-text indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
fulltextList = Conn.showFulltext(requestConfig)
for fulltext in fulltextList:
print(fulltext.toJSON())
{"id": null, "name": "name", "properties": "name", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
{"id": null, "name": "Content", "properties": "content", "schema": "review", "status": "DONE", "size": null, "dbType": "DBEDGE"}
showNodeFulltext()
获取图中全部点的全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的全文索引列表。
# Retrieves node full-text indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
fulltextList = Conn.showNodeFulltext(requestConfig)
for fulltext in fulltextList:
print(fulltext.toJSON())
{"id": null, "name": "name", "properties": "name", "schema": "account", "status": "DONE", "size": null, "dbType": "DBNODE"}
showEdgeFulltext()
获取图中全部边的全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List[Index]
:获取的全文索引列表。
# Retrieves edge full-text indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
fulltextList = Conn.showEdgeFulltext(requestConfig)
for fulltext in fulltextList:
print(fulltext.toJSON())
{"id": null, "name": "Content", "properties": "content", "schema": "review", "status": "DONE", "size": null, "dbType": "DBEDGE"}
createFulltext()
在图中创建一个全文索引。
参数
dbType: DBType
:全文索引类型(点或边)。schemaName: str
:Schema名称。propertyName: str
:属性名称。indexName: str
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
# Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.createFulltext(DBType.DBNODE, 'movie', 'plot', 'moviePlot', requestConfig)
jobID = response.jobId
time.sleep(3)
jobs = Conn.showJob(jobID, requestConfig)
for job in jobs:
print(job.status)
FINISHED
createNodeFulltext()
在图中创建一个点的全文索引。
参数
schemaName: str
:Schema名称。propertyName: str
:属性名称。indexName: str
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
# Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.createNodeFulltext('movie', 'plot', 'moviePlot', requestConfig)
jobID = response.jobId
time.sleep(3)
jobs = Conn.showJob(jobID, requestConfig)
for job in jobs:
print(job.status)
FINISHED
createEdgeFulltext()
在图中创建一个边的全文索引。
参数
schemaName: str
:Schema名称。propertyName: str
:属性名称。indexName: str
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
# Creates a full-text index 'agreeNotes' for the property 'notes' of the 'agree' edges
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.createEdgeFulltext('agree', 'notes', 'agreeNotes', requestConfig)
jobID = response.jobId
time.sleep(3)
jobs = Conn.showJob(jobID, requestConfig)
for job in jobs:
print(job.status)
FINISHED
dropFulltext()
从图中删除一个指定的全文索引。
参数
dbType: DBType
:全文索引类型(点或边)。fulltextName: str
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
# Drops the node full-index 'moviePlot' from the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.dropFulltext(DBType.DBNODE, 'moviePlot',requestConfig)
print(response.status.code.name)
SUCCESS
LTE
lte()
将一个属性加载到计算引擎。
参数
dbType: DBType
:属性类型(点或边)。propertyName: str
:属性名称。schemaName: str
(可选):schema名称;忽略时指定全部schema。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
# Loads the property 'year' of 'account' nodes to the computing engine
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.lte(DBType.DBNODE, "year", "account", requestConfig)
jobID = response.jobId
time.sleep(3)
jobs = Conn.showJob(jobID, requestConfig)
for job in jobs:
print(job.id, "-", job.status)
53 - FINISHED
53_1 - FINISHED
53_2 - FINISHED
53_3 - FINISHED
ufe()
将一个属性从计算引擎卸载。
参数
dbType: DBType
:属性类型(点或边)。propertyName: str
:属性名称。schemaName: str
(可选):schema名称;忽略时指定全部schema。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
# Unloads the property 'year' of 'account' nodes from the computing engine
requestConfig = RequestConfig(graph="miniCircle")
response = Conn.ufe(DBType.DBNODE, "year", "account", requestConfig)
print(response.status.code.name)
SUCCESS
完整示例
from ultipa import UltipaConfig, Connection, RequestConfig
ultipaConfig = UltipaConfig()
# URI example: ultipaConfig.hosts = ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
ultipaConfig.hosts = ["192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"]
ultipaConfig.username = "<username>"
ultipaConfig.password = "<password>"
Conn = Connection.NewConnection(defaultConfig=ultipaConfig)
# Retrieves indexes in the graph 'miniCircle'
requestConfig = RequestConfig(graph="miniCircle")
indexList = Conn.showIndex(requestConfig)
for index in indexList:
print(index.toJSON())