0
votes

I am new to graphdb's and gremlin and struggling with a query I need to come up with I have users(vertex) who can be members of(edge: memberOf) a group a group(vertex), uses in that group can also like (edge: 'likes') certain foods(vertex) that belong to(edge: belongTo) various categories(vertex).

I essentially need a query to return all like edges that fit into a selected category.

For example, a user wants to see who all in his group likes Italian food. I am interested in the like as it has additional properties that will be displayed.

1

1 Answers

3
votes

It's easier to give you a tested answer if you can provide a few addV and addE steps that create a sample graph. However based on what you stated in the question I believe something like this is what you are looking for. I used id to represent the ID of the user doing the search.

g.V(id).
  out('memberOf').
  where(out('likes').has('food','type','Italian'))

You can add to the query if you need to factor in the categories. I was not 100% clear from your question how to factor those in. If you can update the question I will try to update the answer as well.