本节介绍用于管理图中各类属性索引及LTE状态的方法。
索引
ShowIndex()
获取图中全部索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
indexList, _ := driver.ShowIndex(requestConfig)
for _, index := range indexList {
fmt.Println(index)
}
&{1 age_index year account DONE DBNODE}
&{2 test_index year,float account DONE DBNODE}
&{1 targetPostInd targetPost disagree DONE DBEDGE}
ShowNodeIndex()
获取图中全部点索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves node indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
indexList, _ := driver.ShowNodeIndex(requestConfig)
for _, index := range indexList {
fmt.Println(index)
}
&{1 age_index year account DONE DBNODE}
&{2 test_index year,float account DONE DBNODE}
ShowEdgeIndex()
获取图中全部边索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves edge indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
indexList, _ := driver.ShowEdgeIndex(requestConfig)
for _, index := range indexList {
fmt.Println(index)
}
&{1 targetPostInd targetPost disagree DONE DBEDGE}
DropIndex()
从图中删除一个指定的索引。
参数
dbType: ultipa.DBType
:索引类型(点或边)。indexName: string
:索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Drops the node index 'test_index' from the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.DropIndex(ultipa.DBType_DBNODE, "test_index", requestConfig)
fmt.Println(response.Status.Code)
SUCCESS
DropNodeIndex()
从图中删除一个指定的点索引。
参数
indexName: string
:索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Drops the node index 'test_index' from the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.DropNodeIndex("test_index", requestConfig)
fmt.Println(response.Status.Code)
SUCCESS
DropEdgeIndex()
从图中删除一个指定的边索引。
参数
indexName: string
:索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Drops the edge index 'targetPostInd' from the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.DropEdgeIndex("targetPostInd", requestConfig)
fmt.Println(response.Status.Code)
SUCCESS
全文索引
ShowFullText()
获取图中全部全文索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的全文索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves full-text indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
fulltextList, _ := driver.ShowFullText(requestConfig)
for _, fulltext := range fulltextList {
fmt.Println(fulltext)
}
&{ name name account DONE DBNODE}
&{ Content content review DONE DBEDGE}
ShowNodeFullText()
获取图中全部点的全文索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的全文索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves node full-text indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
fulltextList, _ := driver.ShowNodeFullText(requestConfig)
for _, fulltext := range fulltextList {
fmt.Println(fulltext)
}
&{ name name account DONE DBNODE}
ShowEdgeFullText()
获取图中全部边的全文索引。
参数
config: *configuration.RequestConfig
(可选):请求配置。
返回值
[]*structs.Index
:获取的全文索引的指针切片。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Retrieves edge full-text indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
fulltextList, _ := driver.ShowEdgeFullText(requestConfig)
for _, fulltext := range fulltextList {
fmt.Println(fulltext)
}
&{ Content content review DONE DBEDGE}
CreateFullText()
在图中创建一个全文索引。
参数
dbType: ultipa.DBType
:全文索引类型(点或边)。schemaName: string
:schema名称propertyName: string
:属性名称。fulltextName: string
:全文索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.CreateFullText(ultipa.DBType_DBNODE, "movie", "plot", "moviePlot", requestConfig)
jobID := response.JobId
time.Sleep(3 * time.Second)
jobs, _ := driver.ShowJob(jobID, requestConfig)
for _, job := range jobs {
fmt.Println(job.Id, "-", job.Status)
}
22 - FINISHED
22_1 - FINISHED
22_2 - FINISHED
22_3 - FINISHED
CreateNodeFullText()
在图中创建一个点的全文索引。
参数
schemaName: string
:schema名称propertyName: string
:属性名称。fulltextName: string
:全文索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.CreateNodeFullText("movie", "plot", "moviePlot", requestConfig)
jobID := response.JobId
time.Sleep(3 * time.Second)
jobs, _ := driver.ShowJob(jobID, requestConfig)
for _, job := range jobs {
fmt.Println(job.Id, "-", job.Status)
}
23 - FINISHED
23_1 - FINISHED
23_2 - FINISHED
23_3 - FINISHED
CreateEdgeFullText()
在图中创建一个边的全文索引。
参数
schemaName: string
:schema名称propertyName: string
:属性名称。fulltextName: string
:全文索引名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Creates a full-text index 'agreeNotes' for the property 'notes' of the 'agree' edges
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.CreateEdgeFullText("agree", "notes", "agreeNotes", requestConfig)
jobID := response.JobId
time.Sleep(3 * time.Second)
jobs, _ := driver.ShowJob(jobID, requestConfig)
for _, job := range jobs {
fmt.Println(job.Id, "-", job.Status)
}
24 - FINISHED
24_1 - FINISHED
24_2 - FINISHED
24_3 - FINISHED
DropFullText()
从图中删除一个指定的全文索引。
参数
fulltextName: string
:全文索引名称。dbType: ultipa.DBType
:全文索引类型(点或边)。config: *configuration.RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Drops the node full-index 'moviePlot' from the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.DropFullText("moviePlot", ultipa.DBType_DBNODE, requestConfig)
fmt.Println(response.Status.Code)
SUCCESS
LTE
Lte()
将一个属性加载到计算引擎。
参数
dbType: ultipa.DBType
:属性类型(点或边)。schemaName: string
:schema名称propertyName: string
:属性名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Loads the property 'year' of 'account' nodes to the computing engine
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.Lte(ultipa.DBType_DBNODE, "account", "year", requestConfig)
jobID := response.JobId
time.Sleep(3 * time.Second)
jobs, _ := driver.ShowJob(jobID, requestConfig)
for _, job := range jobs {
fmt.Println(job.Id, "-", job.Status)
}
25 - FINISHED
25_1 - FINISHED
25_2 - FINISHED
25_3 - FINISHED
Ufe()
将一个属性从计算引擎卸载。
参数
dbType: ultipa.DBType
:属性类型(点或边)。schemaName: string
:schema名称propertyName: string
:属性名称。config: *configuration.RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。error
:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil
。
// Unloads the property 'year' of 'account' nodes from the computing engine
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
response, _ := driver.Ufe(ultipa.DBType_DBNODE, "account", "year", requestConfig)
fmt.Println(response.Status.Code)
SUCCESS
完整示例
package main
import (
"fmt"
"log"
"github.com/ultipa/ultipa-go-driver/v5/sdk"
"github.com/ultipa/ultipa-go-driver/v5/sdk/configuration"
)
func main() {
config := &configuration.UltipaConfig{
// URI example: Hosts: []string{"mqj4zouys.us-east-1.cloud.ultipa.com:60010"},
Hosts: []string{"192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"},
Username: "<usernmae>",
Password: "<password>",
}
driver, err := sdk.NewUltipaDriver(config)
if err != nil {
log.Fatalln("Failed to connect to Ultipa:", err)
}
// Retrieves indexes in the graph 'miniCircle'
requestConfig := &configuration.RequestConfig{
Graph: "miniCircle",
}
indexList, _ := driver.ShowIndex(requestConfig)
for _, index := range indexList {
fmt.Println(index)
}
}