Cypher custom query for people and places over time


(Bellaqua) #1

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


(Michael Hunger) #2

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.


(Bellaqua) #3

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