Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add edge error #20

Open
UncleBig opened this issue May 15, 2020 · 3 comments
Open

add edge error #20

UncleBig opened this issue May 15, 2020 · 3 comments

Comments

@UncleBig
Copy link

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)

}`

@damienfamed75
Copy link
Contributor

What database are you using for this example

@UncleBig
Copy link
Author

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

@arjantop-cai
Copy link

@UncleBig The current solution is the same as here: #18

Downgrade to v1.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants