cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher custom query for people and places over time

I would like to query a dataset to reveal a variety of connections between 1000+ nodes. More specifically, I would like to isolate the literal "crossings of paths" of various people as they are posted at different locations at different times.

Everything I've tried so far has gotten me nowhere. I am new to this.

My nodes are of individual's names and building names. Relationships have date, geo-coding, and additional properties - though they are not all directly graphically connected as I would like to leave that up to the user to custom query. Any help? Is neo4j good for this?

Also, I am in Chicago. The community intro suggests I "Connect with others in your local region." ??? Thanks, thanks, thanks

4 REPLIES 4

Depends if you modeled your data with a "visit" node or not.

in general the query would look like:

MATCH (p1:Person)-[vis1:VISITED]->(b:Building)<-[vis2:VISITED]-(p2:Person)
WHERE p1 <> p2 and vis1.date = vis2.date
RETURN b.name, vis1.date as date, p1.name, p2.name

or generically

MATCH (b:Building)<-[vis:VISITED]-(p:Person)
WITH b, vis.date as date, collect(p) as people
WHERE size(people) > 1
RETURN b.name, date, people

there are some optimizations here but that's the basics.

Thanks for your response, but I've been side lined with this:
neo4j - can't create NEW relationships between existing nodes

https://stackoverflow.com/q/54621762/7331185?sem=2

when I -

CREATE (c:Church{name: "Sts. Peter and Paul", address: "3745 S Paulina St Chicago IL 60609"})
and then I -

MATCH (p:Priest{name: "Fr. Thomas J OGorman" }), (c:Church {name: "Sts. Peter and Paul"}) MERGE (p)-[:POSTED {posting:1982-83}]->(c) It works fine,

however, when I enter the identical statement, but change variables, like church, I then get (no changes, no records) Tried creating indexes and variations which didn't help.

For instance: MATCH (p:Priest {name:'Fr. Thomas J OGorman'}), (c:Church {name:'St Barnabas'}) MERGE (p)-[:POSTED {posting:1977-82}]->(c) I then get (no changes, no records)

Suggestions please? Thanks

Perhaps the church doesn't exist yet?
You have to create it before.

123ofkme
Node Link

Michael,
Church existed, My queries lacked identical letter word spacings as my church nodes. Simple. Learning here. Thanks for the help.