This section introduces methods for managing various indexes and LTE status for properties in graphs.
Index
ShowIndex()
Retrieves all indexes of node and edge properties from the current graphset.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Retrieves all node indexes from the graph.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Retrieves all edge indexes from the graph.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Drops a specified index from the graph.
Parameters
dbType: ultipa.DBType
: Type of the index (node or edge).indexName: string
: Name of the index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Drops a specified node index from the graph.
Parameters
indexName: string
: Name of the index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Drops a specified edge index from the graph.
Parameters
indexName: string
: Name of the index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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
Full-text
ShowFullText()
Retrieves all full-text indexes from the graph.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved full-text indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Retrieves all node full-text indexes from the graph.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved full-text indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Retrieves all edge full-text indexes from the graph.
Parameters
config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
[]*structs.Index
: A slice of pointers to the retrieved full-text indexes.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Creates a full-text index in the graph.
Parameters
dbType: ultipa.DBType
: Type of the full-text index (node or edge).schemaName: string
: Name of the schema.propertyName: string
: Name of the property.fulltextName: string
: Name of the full-text index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Creates a node full-text index in the graph.
Parameters
schemaName: string
: Name of the schema.propertyName: string
: Name of the property.fulltextName: string
: Name of the full-text index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Creates an edge full-text index in the graph.
Parameters
schemaName: string
: Name of the schema.propertyName: string
: Name of the property.fulltextName: string
: Name of the full-text index.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Drops a full-text index from the graph.
Parameters
fulltextName: string
: Name of the full-text index.dbType: ultipa.DBType
: Type of the full-text index (node or edge).config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// 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()
Loads a property to the computing engine.
Parameters
dbType: ultipa.DBType
: Type of the property (node or edge).schemaName: string
: Name of the schema; write*
to specify all schemas.propertyName: string
: Name of the property.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// Loads the property 'year' of 'account' nodes to the computing engine
requestConfig := &configuration.RequestConfig{
UseMaster: true,
GraphName: "UltipaTeam",
}
resp, _ := conn.Lte(ultipa.DBType_DBEDGE, "relatesTo", "type", requestConfig)
print("Operation succeeds:", resp.Status.IsSuccess())
Operation succeeds:true
Ufe()
Unloads one custom property of nodes or edges from the computing engine to save the memory.
Parameters
DBType
: Type of the property (node or edge).string
: Name of the schema, write*
to specify all schemas.string
: Name of the property.config: *configuration.InsertRequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.error
: An error object that contains details about any issues encountered during the operation. If the operation succeeds,nil
is returned.
// Unloads the edge property @relatesTo.type from engine in graphset 'UltipaTeam' and prints error code
requestConfig := &configuration.RequestConfig{
UseMaster: true,
GraphName: "UltipaTeam",
}
resp, _ := conn.Ufe(ultipa.DBType_DBEDGE, "relatesTo", "type", requestConfig)
print("Operation succeeds:", resp.Status.IsSuccess())
Operation succeeds:true
Full Example
package main
import (
ultipa "github.com/ultipa/ultipa-go-sdk/rpc"
"github.com/ultipa/ultipa-go-sdk/sdk"
"github.com/ultipa/ultipa-go-sdk/sdk/configuration"
"github.com/ultipa/ultipa-go-sdk/sdk/structs"
"github.com/ultipa/ultipa-go-sdk/utils"
)
func main() {
// Connection configurations
//URI example: hosts="mqj4zouys.us-east-1.cloud.ultipa.com:60010"
config, _ := configuration.NewUltipaConfig(&configuration.UltipaConfig{
Hosts: []string{"192.168.1.85:60061", "192.168.1.86:60061", "192.168.1.87:60061"},
Username: "***",
Password: "***",
})
// Establishes connection to the database
conn, _ := sdk.NewUltipa(config)
// Request configurations
requestConfig := &configuration.RequestConfig{
UseMaster: true,
GraphName: "Ad_Click",
}
// Retrieves all indexes in graphset 'Ad_Click' and prints their information
indexList, err := conn.ShowIndex(requestConfig)
if err != nil {
println(err)
}
for i := 0; i < len(indexList); i++ {
println(utils.JSONString(indexList[i]))
}
};