It is the standard type of friends of friends query and iirc I was given this query here, or copied from the SDN Guide. it always returns 0 results even though I know it should return some values.
Here is my repo method.
Here is my User object with mapping up to friends.Code:@Query("start user=node({0}) " + "match user-[:FRIEND]->friends-[:FRIEND]->friendsOfFriends, " + "user-[r?:FRIEND]->friendOfFriends " + "where r IS NULL " + "return friendsOfFriends " + "order by count(*) desc, friendsOfFriends.lastName asc") public Page<User> findFriendsOfFriends(User user, Pageable pageable);
Here is some data code that sets up some relationships between Users. All Users have been added to the dbCode:@NodeEntity public class User implements Serializable, SocialMessageArg { @GraphId Long nodeId; public static final String FRIEND = "FRIEND"; public static final String HOSTING = "Hosting"; public static final String INVITED = "Invited"; public static final String ATTENDING = "Attending"; @NotNull @Column(unique = true) @Size(min = 6) @Indexed String login; //@JsonIgnore String password; @NotNull @Indexed(indexName = "firstName", indexType = IndexType.SIMPLE) private String firstName; @NotNull @Indexed(indexName = "lastName", indexType = IndexType.SIMPLE) private String lastName; private String twitterAccountName; @RelatedTo(type = FRIEND) @JsonIgnore Set<User> friends;
userRepository.addFriend("auser", cUser);
userRepository.addFriend("cuser", bUser);
userRepository.addFriend("guser", bUser);
userRepository.addFriend("guser", cUser);
userRepository.addFriend("guser", dUser);
userRepository.addFriend("guser", eUser);
userRepository.addFriend("guser", fUser);
userRepository.addFriend("guser", hUser);
userRepository.addFriend("guser", iUser);
userRepository.addFriend("guser", jUser);
Here is my addFriend repo method.
That method is there only for the temporaryData inserting for testing purposes.Code:@Transactional public void addFriend(String friendLogin, final User user) { User friend = findByLogin(friendLogin); if (!user.equals(friend)) { user.addFriend(friend); friend.addFriend(user); template.save(user); template.save(friend); } }
I am already running queries that return friends of a User and that works perfectly. I get exactly the friends of a user. I just can't go one more level deeper in a Cypher query.
Thanks
Mark


Reply With Quote