I want to get a ResultSet of Objects that consist of a user and a list of all users that are not yet related to this user. The result should look like this:
[[user: [USEROBJECT], usersThatAreNotFriends: [[USEROBJECT]...]]...]
I am using the Cosmos DB Gremlin Endpoint and struggle with filtering/combining the users that are already related and all users.
My idea was:
g.V().hasLabel('user').as('user').flatMap(g.V().hasLabel('user').where(__.eq(select('user').out('isFriend')).fold()).as('usersThatAreNotFriends').select('user', 'usersThatAreNotFriends')
To set up my example use:
g.addV('user').property('id','user_1').property('partition_key','1')
g.addV('user').property('id','user_2').property('partition_key','2')
g.addV('user').property('id','user_3').property('partition_key','3')
g.addV('user').property('id','user_4').property('partition_key','4')
g.V('user_1').addE('has_relation').to(g.V('user_2'))
g.V('user_2').addE('has_relation').to(g.V('user_1'))
g.V('user_2').addE('has_relation').to(g.V('user_4'))
g.V('user_4').addE('has_relation').to(g.V('user_2'))
The expected result should be represented in simple way:
[user_1: [user_3, user_4], user_2:[user_3],
user_3:[user_1, user_2, user_3], user_4:[user_1, user_3]]