You could also do:
MATCH (n:User { id:'1'}) - [r:TEXTED]-> (m) WITH n,collect(r.year) as years
WHERE '2013' in years and not '2014' in years return n
Michael
Am 16.04.2014 um 21:30 schrieb Christopher Hendrix <[email protected]>:
> Why not a
>
> (u1:User { name: "Alice"} )-[:WROTE]->(t1:TextMessage { year: 2013
> })<-[:RECEIVED]-(u2:User { name: "Bob" })
>
> ?
>
> Then your query becomes
>
> MATCH (u1:User { name: "Alice" })-[:WROTE]->(t:TextMessage { year: 2013 })
> RETURN count(DISTINCT t)
>
>
> On Wednesday, April 16, 2014 11:35:47 AM UTC-7, Alx wrote:
> I have a Neo4j graph database containing: a) user nodes (U1, U2, etc) and b)
> a relationship [:TEXTED] with properties: i)year (2013, 2014), ii)
> message_count.
>
> I am trying to retrieve all the users that U1 texted in 2013 and not in 2014
> and vice versa. So far I have come up with the following query:
>
> MATCH (n:User { id:'1'}) - [r:TEXTED]-> (m) WHERE r.year = '2013' WITH n,m
> MATCH (n)-[k:TEXTED]->(m) WHERE k.year <> '2014' RETURN n.id AS User1, m.id
> AS User2
>
> However this query returns all the user U1 texted in 2013 regardless if they
> texted them in 2014. I can query to find the common user pairs in 2013 and
> 2014 and then import to some spreadsheet program but defeats efficiency.
>
> Any suggestions for creating the query would be much appreciated.
>
>
>
> Also as a general question, how should time-based relationships like the one
> above should they be stored in the graph database? For the above problem I
> think it would be easier to create 2 separate relationship ( [TEXTED_IN_2013]
> and [TEXTED_IN_2014]) . But I wonder if that's the way to go.
>
>
> --
> 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/d/optout.
--
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/d/optout.