Hello,
I've been playing with Gremlin over the weekend - thanks to all the help
provided already on other threads, it has been really useful.
I'm trying to optimize a query that currently takes three HTTP requests
(index fetch, traverse, batch get for node data) by writing a Gremlin script
and executing that over the REST API. I have it working, but it's somewhat
clunky in the way it gets the data out:
t = [];
start = g.v(3);
for (i in 1..5) {
start = start.
outE.except(t).sideEffect { t.add(it) }.inV.
inE.except(t).sideEffect { t.add(it) }.outV;
};
start >> -1;
t = t.collect {
outN = it.outV.toList().get(0);
inN = it.inV.toList().get(0);
[outN.type, outN.key, inN.type, inN.key].join(",");
};
t.join(":")
(The sideEffect bit is to ensure breadth first ordering - trying to copy
the behavior of traverse/relationships)
I feel I should be able to use the Table object, but couldn't figure it out
(is there explicit API documentation for it anywhere?)
Ideally, I'd like to return a custom JSON object, something like:
[{"type": outN.type, "key": outN.key}, {"type": inN.type, "key", inN.key}]
...but I couldn't see an easy way of constructing that.
What I have already is trivial to parse, so it's not a big deal, but it's a
bit messy.
Cheers,
Xavier
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user