Reputation: 6954
I'm using:
In my neo4j instance I have:
In my code I want to search for friends of friends; in orde to do it I wrote this code:
@Query(value = "START n = node({userStartId}) "
+ "MATCH n-[:OPINION_LEADER_INFLUENCE*2..]->friend_of_friend "
+ "WHERE not(n-[:OPINION_LEADER_INFLUENCE]->friend_of_friend) "
+ "and id(n) <> id(friend_of_friend) "
+ "RETURN COUNT (distinct friend_of_friend)")
public int getFriendOfFriendNumber(@Param("userStartId") long userStartId)
When I executed it I got a SocketTimeoutException I tried to execute the query directly on neo4j dashboard; the executed query is the following one:
START n = node(111)
MATCH n-[:OPINION_LEADER_INFLUENCE*2..]->friend_of_friend
WHERE not(n-[:OPINION_LEADER_INFLUENCE]->friend_of_friend)
and id(n) <> id(friend_of_friend)
RETURN COUNT (distinct friend_of_friend)
Executing it on the neo4j dashboard I took around 10 minutes in order to be executed (this is the reason I got the error)
May you kindly tell me how I can prevent the error?
Is there any tuning I should do in neo4j?
Should I modify the query?
How can I set the timeout for the Jersey?
Thank you Angelo
Upvotes: 0
Views: 117
Reputation: 6954
I found the problem
It was the query; I modified it in this way:
START n = node(111)
MATCH n-[:OPINION_LEADER_INFLUENCE*2..2]-friend_of_friend
WHERE not(n-[:OPINION_LEADER_INFLUENCE]-friend_of_friend)
and id(n) <> id(friend_of_friend)
RETURN COUNT (distinct friend_of_friend), friend_of_friend.user_id
Angelo
Upvotes: 1