We can get all the data we want from a query with gremlin.
For example,
g.V(1234)
.project("identifier", "associations")
.by(valueMap(true)).by(unfold())
.by(bothE().local(elementMap()).fold())
This query takes a long time to execute because vertex 1234 has 10k+ edges.
After some experimentation, we see limiting the amount of data coming back; the result can return faster. I cannot get it to work altogether, though.
Instead of showing you what I've created so far, I'd like to frame my question about what I want.
Given that I have a vertex with 10k+ edges, how can I minimize the amount of data returned in the result payload, so the query returns faster?
An example payload I was thinking of would be a hash map of:
{
// edge direction
"IN": {
// edge label
"MEMBER": [
"4567" // vertex identifier going to (this would not be 1234 as we know that already)
]
},
// edge direction
"OUT": {
// edge label
"BICYCLE": [
"7890" // vertex identifier going to (this would not be 1234 as we know that already)
]
}
}
When I started to approach the above, my query started to have group().by(...)
. I was unable to resolve how to get the by(...)
values to only be a single key, rather than the whole edge representation, though.
For example,
g
.V("1234")
.outE()
.limit(10)
.local(union(
label(),
inV().id()
).fold())
.group().by(0)
I have scoured docs (book and tutorial). They are useful, but I think I'm getting stuck trying to ask for something with the wrong vocabulary or not possible to do.
Open to different approaches. This is just how I was thinking about it. If there are more efficient ways to get data from here.