# Cypher custom query for people and places over time

**URL:** <https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819>\
**Category:** Cypher\
**Created:** [February 3, 2019, 1:39am UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819 "2019-02-03T01:39:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bellaqua](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bellaqua/32/3129_2.png) [@bellaqua](https://community.neo4j.com/u/bellaqua)\
**Post date:** [February 3, 2019, 1:39am UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819/1 "2019-02-03T01:39:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [February 3, 2019, 9:58am UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819/2 "2019-02-03T09:58:05Z")

</div>

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

in general the query would look like:

```auto
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

```auto
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.

---

<div class="post-metadata">

**Author:** ![bellaqua](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bellaqua/32/3129_2.png) [@bellaqua](https://community.neo4j.com/u/bellaqua)\
**Post date:** [February 10, 2019, 10:35pm UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819/3 "2019-02-10T22:35:59Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [February 25, 2019, 7:32am UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819/4 "2019-02-25T07:32:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![123ofkme](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/123ofkme/32/3257_2.png) [@123ofkme](https://community.neo4j.com/u/123ofkme)\
**Post date:** [February 25, 2019, 4:25pm UTC](https://community.neo4j.com/t/cypher-custom-query-for-people-and-places-over-time/4819/5 "2019-02-25T16:25:17Z")

</div>

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