I have a traditional social media graph where a user makes a post, other users comment on that post, and users can block other users. I'm trying to create a traversal that excludes comments where the commenting user has a block edge from the posting user (the posting user has blocked the commenting user, exclude their comments).
g.addV("user").as("poster")
.addV("post")
.addV("user").as("commenter")
.addV("comment")
.addE("post").from("poster").to("post")
.addE("comment").from("commenter").to("comment")
.addE("comment").from("comment").to("post")
.addE("block").from("poster").to("commenter")
This is as far as I got but doesn't compile:
g.V()
.hasLabel("comment")
.as("comment")
.not(
__.in_("comment")
.as("commenter")
.select("comment")
.where(
__.out("comment")
.in_("post")
.out("block")
.hasId(__.select("commentOwner").id()) // the poster is blocking the commenter
)
)
This doesn't work but is the general idea. Exclude comments where the owner of the post is blocking the commenter. How can I construct this traversal?