I have a neo4j instance with roughly 4.2 million edges and I'm running into performance issues on the NeoEloquent side of things.
Structure
I have a few 100k users which trigger events. I'm currently saving the number of times they've triggered an event on a connection likes this
(u:User)-[r:triggered]->(e:Event)
with an attribute
r.val = number of times the event has been triggered
Use case
I want to do some data crunching on the website (for administrators) showing some values like number of users triggering an event, average event count per user, etc.
Actual code
From Event.php
public function usersTriggeredBy(){
return $this->belongsTo('App\User', 'triggered');
}
public function numberOfUsersTriggeredBy(){
return $this-> usersTriggeredBy()->count();
}
This works just fine. Now I'd like to get the in degree of an event, which means that I'd need to use the val on every edge r:triggered.
The cipher query for that would look like
MATCH ()-[r:triggered]->(e:Event)
WITH e, count(r) as userCount, sum(toInteger(r.val)) as inDegree
RETURN e.name, userCount, inDegree, inDegree/userCount as average
ORDER BY userCount DESC
Now I'd like to do exactly that in NeoEloquent. Can I do this? If so, how do I do this? If not: What do you think how I would need to change NeoEloquent, to build this into the project and give back to the community?
Suggested Behavior
I'd like to use something like this, so I wouldn't need to query everything
public function inDegree(){
return $this-> usersTriggeredBy()->edge()->sum('val');
}
or otherwise just get all edges of a certain type to that node.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hey,
I have a neo4j instance with roughly 4.2 million edges and I'm running into performance issues on the NeoEloquent side of things.
Structure
I have a few 100k users which trigger events. I'm currently saving the number of times they've triggered an event on a connection likes this
(u:User)-[r:triggered]->(e:Event)
with an attribute
r.val = number of times the event has been triggered
Use case
I want to do some data crunching on the website (for administrators) showing some values like number of users triggering an event, average event count per user, etc.
Actual code
From Event.php
This works just fine. Now I'd like to get the in degree of an event, which means that I'd need to use the
val
on every edger:triggered
. The cipher query for that would look likeNow I'd like to do exactly that in NeoEloquent. Can I do this? If so, how do I do this? If not: What do you think how I would need to change NeoEloquent, to build this into the project and give back to the community?
Suggested Behavior
I'd like to use something like this, so I wouldn't need to query everything
or otherwise just get all edges of a certain type to that node.