Looking at triggers, the events are related to create, update or delete on nodes, relations or properties. I would be looking for a "viewed" or "matched items returned" event.
Let's consider the following "manual" query, doing what I expect to get as a behavior:
MATCH (n1:NODE)-[r:RELATION]-(n2:NODE)
WHERE ...some conditions on n1, n2 or r...
WITH n1,n2, r
SET n1.watched = coalesce(n1.watched, 0) + 1, r.watched = coalesce(r.watched, 0) + 1, n2.watched = coalesce(n2.watched, 0) + 1
I was willing to get it done through triggers but I don't see how to get the SET being triggered on simple MATCH queries and I think that it would be more appropriate to get it directly from Neo4j query engine (even if impactful).
These are counters here but could be handled as a "popularity" / "watch" indicator (as a percentage or alike).
Let's assume the engine get it done or the triggers allow for this behavior:
So that, anyone issuing queries like:
MATCH p=(n1:NODE)-[r:RELATION]-(n2:NODE)
RETURN p
would, as a side effect in the background, let me be able to issue then queries like
MATCH (n:NODE) WHERE n.watched > 70% RETURN n ORDER BY n.watched DESC LIMIT 10
or
MATCH p=(n1:NODE)-[r:RELATION]-(n2:NODE) WHERE r.watched > 70% ORDER BY r.watched DESC LIMIT 10
Would you know if this is achievable and how to efficiently implement this ?
The scenario would be : end-users query the Neo4j database (like reading a doc over and over, focusing on some key aspects based on their queries) and this can be reflected as a "database usage / attention / focus" criteria on what it contains. Assuming that what is popular or what is looked for over time should focus attention (with appropriate weights).
When queries profiling takes place, we see the steps and the hits. I guess that it should take place at RETURN time somehow.
Thinking loud, not even sure that this is not a dead-end.
Any feedback appreciated
Xav