grammes icon indicating copy to clipboard operation
grammes copied to clipboard

add edge error

Open UncleBig opened this issue 5 years ago • 3 comments

Hi, I refer to the example to add the edge operation, but the following error is returned,Could you please check where I made the mistake

{"error": "{"type":"QUERY_ERROR"},{"function":"AddEdge"},{"query":"g.V().hasId(map[@type:g:Int64 @value:16432]).addE("friendsWith").to(V().hasId(map[@type:g:Int64 @value:12408]))"},{"error":"{"type":"NETWORK_ERROR"},{"status code":"597"},{"error":"SCRIPT EVALUATION ERROR"},{"original error":"startup failed:\nScript19.groovy: 1: unexpected token: : @ line 1, column 22.\n g.V().hasId(map[@type:g:Int64 @value:16432]).addE("friendsWith").to(V().hasId(map[@type:g:Int64 @value:12408]))\n

func main() {
flag.StringVar(&addr, "h", "", "Connection IP")
flag.Parse()

logger = exampleutil.SetupLogger()
defer logger.Sync()

if addr == "" {
	addr="ws://127.0.0.1:8182"
}

// Create a new Grammes client with a standard websocket.
client, err := grammes.DialWithWebSocket(addr)
if err != nil {
	logger.Fatal("Couldn't create client", zap.Error(err))
}

// Drop all vertices on the graph currently.
client.DropAll()

// Drop the testing vertices when finished.
defer client.DropAll()

// Create a new graph traversal
g := grammes.Traversal()

// Add a vertex with label person and properties
vertex, err := client.AddVertexByQuery(g.AddV("person").Property("name", "damien"))
if err != nil {
	logger.Fatal("Couldn't add vertex", zap.Error(err))
}

// Print out the new vertex struct and its properties.
logger.Info("Added vertex",
	zap.Any("name", vertex.PropertyValue("name", 0)),
)
vertex2, err := client.AddVertexByQuery(g.AddV("person").Property("name", "test"))
if err != nil {
	logger.Fatal("Couldn't add vertex", zap.Error(err))
}
logger.Info("Added vertex",
	zap.Any("name", vertex2.PropertyValue("name", 0)),
)
// Count the vertices on the graph.
count, err := client.VertexCount()
if err != nil {
	logger.Fatal("Couldn't count vertices", zap.Error(err))
}

// Print out the number of vertices on the graph.
// This should be 1.
logger.Info("Counted Vertices", zap.Int64("count", count))

vertices, err := client.VerticesByQuery(g.V().HasLabel("person"))
if err != nil {
	logger.Fatal("Couldn't gather vertices", zap.Error(err))
}

// Print out all the received vertices.
for _, vertex := range vertices {
	logger.Info("gathered vertex",
		zap.String("label", vertex.Label()),
		zap.Any("id", vertex.ID()),
	)
}

// Use the traversal to gather all IDs from the graph.
ids, err := client.VertexIDsByQuery(g.V().ID())
if err != nil {
	logger.Fatal("Couldn't gather all IDs", zap.Error(err))
}

// Print out all the received vertex IDs.
for _, id := range ids {
	logger.Info("vertex id", zap.Any("value", id))
}

_,err=vertex.AddEdge(client, "friendsWith", vertex2.ID())

if err != nil {
	logger.Fatal("AddEdge error", zap.Error(err))
	return
}

// Get the edges based on vertex1's out edges.
edges, err := vertex.QueryOutEdges(client)
if err != nil {
	logger.Fatal("Error while querying for outer edges", zap.Error(err))
}

printEdges(client, edges)

}`

UncleBig avatar May 15 '20 03:05 UncleBig

What database are you using for this example

damienfamed75 avatar May 17 '20 19:05 damienfamed75

I use the janusgraph docker run --name janusgraph-default -p 8182:8182 janusgraph/janusgraph:latest

UncleBig avatar May 18 '20 02:05 UncleBig

@UncleBig The current solution is the same as here: https://github.com/northwesternmutual/grammes/issues/18

Downgrade to v1.1.2

arjantop-cai avatar Jun 12 '20 10:06 arjantop-cai