Hi,

I'm somewhat in a pickle. Last night, I was trying to figure out an 
intelligent and most of all performant system to do time-sorted 
recommendations. 

*An example : Give me the last 100 messages posted by people I follow.*

Note that I do not want the last 100 messages by each person, which would 
be easier. No, I want the last 100 messages in total. And I don't quite 
know how many of each person that I'll end up with. 

So I was thinking about building a time-index in the graph, like suggested 
many times already but there are some issues with that. There are two 
options I could think of:

1. You create a relationship between each time unit individually and then 
you sort. You don't really build a tree, just 60 nodes for the minutes and 
seconds, 24 nodes for the hours and you reuse them over and over. The only 
ones you can't reuse are basicaly the year nodes. But there are some 
concerns I have here: The time nodes potentially become very highly 
connected nodes. I'm not sure if this is an issue though since they are 
always at the end of the matching pattern. And then there's the sorting of 
every single message which IMO sounds a bit ridiculous.

*MATCH 
(personA:USER)-[:FOLLOWS]->(personB:USER)-[:POSTS]->(message:MESSAGE),*
*(message)-[:POSTYEAR]->(year),*

*(message)-[:POSTMONTH]->(month),*

*(message)-[:POSTDAY]->(day),*

*(message)-[:POSTHOUR]->(hour),*

*(message)-[:POSTMINUTE]->(minute),*

*(message)-[:POSTSECOND]->(second),*
*WHERE personA.email = "lala$at$lolo.com"*

*RETURN messageORDER BY year.value, month.value, day.value, hour.value, 
minute.value, second.value*
*LIMIT 100*

2. You use the NEXT relationships between the time units. (here you do 
build a tree!)

*MATCH 
(timelineEnding:TIME_END)<-[:ENDS]-(lastTimeLeafNode:TIMELEAF)<-[:NEXT*]-(previousTimeLeafNode:TIMELEAF)<-[:POSTTIME]-(message:MESSAGE)<-[:POSTS]-(personB:USER)<-[:FOLLOWS]-(personA:USER)*
*RETURN message LIMIT 100;*

But again, I have some concerns here. First of all, the last message posted 
is never returned like this, even if you do follow the poster of that 
message. Secondly, if a billion messages are posted and only 5 by the 
people you follow, you'd end up going over a billion messages. And thirdly, 
to keep track of what the last posted message is, you have to remove the 
ends relationship every time a message is created, and connect it to the 
new "lastTimeLeafNode".

Is there no better way than one of the above?


-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to