Combine two queries to perform only one

can someone help me figureout how I can combine those two queries? groups = f"g.V().hasLabel('Groups').as('group_data').elementMap().range({start_index}, {end_index}).toList()" users = f"g.V().hasLabel('Groups').as('group_data').bothE('memberOf').otherV().as('members').select('members').by(elementMap()).range({start_index}, {end_index}).toList()"
VK
Valentyn Kahamlyk11d ago
Simple solution is to use union step https://tinkerpop.apache.org/docs/current/reference/#union-step something like g.union( V().hasLabel('Groups').range({start_index}, {end_index}).elementMap(), V().hasLabel('Groups').out().range({start_index}, {end_index}).elementMap())) other possible way is like g.V().as('V0').out().as('V1').range({start_index}, {end_index}).select('V0','V1').by(elementMap()) I'm not sure which is more appropriate in this case...
AP
Andre Pinto10d ago
Hello there, I am using AWS neptune and tried the informed queries you mentioned. The second one is a very similar we did before but it still has the structure:
groupdata1
player1
groupdata1
player2
groupdata1
player3

groupdata2
player1
groupdata2
player2
groupdata2
player3
groupdata1
player1
groupdata1
player2
groupdata1
player3

groupdata2
player1
groupdata2
player2
groupdata2
player3
and we wanted to have
groupdata1
player1
player2
player3
groupdata2
player1
player2
player3
groupdata1
player1
player2
player3
groupdata2
player1
player2
player3
the first query we couldn't make it work at all receiving 'GraphTraversal' object is not callable even adding __.V()
VK
Valentyn Kahamlyk10d ago
Looks like Neptune does not support starting union step, but it's better to check with Neptune guys. for such a result structure is more suitable group step g.V().hasLabel('Groups').group().by(out()) with pagination a bit more complex g.V().filter(out().count().is(gt(0))).range({start_index}, {end_index}).group().by(out())
S
spmallette9d ago
prior to there being a union() start step you had to cheat. g.inject(0).union(...) which should work on Neptune but I don't think it will perform well depending on the amount of data involved. Neptune will have support for the union() start step soon enough though when it supports TinkerPop 3.7.x. That said, i'm not sure a union() start step is what you want here. Based on the output you asked for, you really just want groups and their players, right? Isn't this just a case for a simple group()?
g.V().hasLabel('Groups').
group().
by(elementMap()).
by(bothE('memberof').
otherV().
elementMap().fold())
g.V().hasLabel('Groups').
group().
by(elementMap()).
by(bothE('memberof').
otherV().
elementMap().fold())
Want results from more Discord servers?
Add your server
More Posts
compatibility with Apache Jena FusekiHello! I am new in the community and trying to figure out whether TinkerPop and Gremlin is supportedIs the first traversal pattern evaluated by Match well definedHi, It seems to me that if the match step is able to dynamically select the first traversal pattern.mergeV() with Javascript not workingHi, I have a nodeJS 18 lambda which is closely modeled after this documentation: https://docs.aws.amUnable to deserialize results with Gremlin-go client + JanusGraphHi all - I'm trying to set up a JanusGraph database and use the Gremlin-go client to run some gremliFulltext-search-like features without ElasticSearch, OpenSearch, Solr and such?I've read in multiple sources that Apache TinkerPop isn't optimized for text search operations like Conditionally updating a variable with choose()How do I create and update a variable with a conditional? I need a number to be calculated based on Systems Analysis Report on Apache TinkerPop - Where to Start?Hey all, I'm currently writing an alaysis on Apache TinkerPop for grad school and was just hoping thLambda example in TypeScriptDoes anyone know where I can find example code that demonstrates up-to-date best practices for writimergeE(): increment counter on matchHi, is there an easy way to increment an existing edge property based on its current value using `meSerialization IssueI have a weird error, when I am connecting with JanusGraph gremlin client using `conf/remote-graph-Design decision related to multiple heterogenous relational graphsI'm working with over 100k instances of heterogeneous, relational node-and-edge attributed graphs, eStackoverflow when adding a larger list of property values using traverser.property()Hey, we encounter a stack overflow: ``` Exception during Transaction, rolling back ... org.apache.tijava: package org.apache.tinkerpop.shaded.jackson.core does not existWhile trying to `mvn clean install` with jdk11, I ran into the above error using the master branch. Performance issue in large graphsWhen performing changes in large graph (ca. 100K nodes, 500K edges) which is stored in one kryo fileConcurrent queries to authentication required sever resulted in 401 errorHey guys, playing around with gremlin & encountered this very odd error where concurrent queries wilDiscrepancy between console server id conventions and NeptuneSo I'm working with my test server and on Neptune--and I'm noticing a difference in the type of the how to connect the amothic/neptune container to the volume?I need to know which directory needs to attach to containeer. so that the data is stored safely. eveDocker yaml authentication settings (gremlinserver.authentication) questionDoes anyone have any experience setting up authentication on Docker by using the supplied .yaml fileGremlin Injection Attacks?Is anyone talking about or looking into attacks and mitigations for Gremlin Injection Attacks? That Returned vertex properties (JS client)Hi, I've got a question regarding the returned vertex value when using the JS client. How come non-a