1

I have two gremlin queries. I want to filter out the output of one query based on the results of another query.

For example,

query 1: g.V().hasLabel('Person').values('name') gives the following output - John, Sam, Rocky

query 2: g.V().hasLabel('Friend').values('name') gives the following output - John

So, the final expected output I want is John

I have tried the following:

g.V().hasLabel('Person').where('names', g.V().hasLabel('Friend').values('name'))

But it doesn't seem to be working. Can anyone please help me here?

1 Answer 1

0

I'm curious why you are not using edges to determine a friend type relationship, but one way to re-write this is to just to reverse the parts.

g.V().hasLabel('Friend').values('name')).fold().as('friends').
  V().hasLabel('Person').
      where(within('friends')).by('name').by()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.