But you connected domain6 to domain3

not sure what your question is, the time tree and the domains live all in
the same graph

MERGE (d:Domain {name:'domain3.com'})
MERGE (z:Domain {name:'domain6.com'})
...
MERGE (d)-[:REFERRED_BY]->(z)


On Sat, Jun 11, 2016 at 2:59 PM, 'Dorian C' via Neo4j <
[email protected]> wrote:

> Hey I'm reposting this from
> http://stackoverflow.com/questions/37762385/time-based-data-query-with-neo4j-showing-more-relations-than-expected
>
> Any help or comments would be awesome:
>
>
> I'm trying to get my mind around Neo4J and time based data.
>
> So what I basically wanted to build is a data structure which is capable
> of giving me a tracking node (page view) with its referrer and its
> referrers-referrer on a certain time.
>
> My problem is, that if I save data with its relations to the timetree
> there are still appearing relations which shouldn't be visible when
> querying a certain time by hour.
>
> During research I found this article about modeling time series data with
> neo4j <https://www.graphgrid.com/modeling-time-series-data-with-neo4j/>.
>
> So far all was well going but the referrer and its child relations were
> not abstracted by time.
>
> To illustrate by problem better here comes first the data structure:
>
> I created an index:
>
> CREATE INDEX ON :Year(value);
> CREATE INDEX ON :Month(value);
> CREATE INDEX ON :Day(value);
> CREATE INDEX ON :Hour(value);
> CREATE INDEX ON :Minute(value);
> CREATE INDEX ON :Second(value);
>
> And put there the time nodes:
>
> //Create Time Tree with Day Depth
> WITH range(2015, 2017) AS years, range(1,12) AS months
> FOREACH(year IN years |
>    CREATE (y:Year {value: year})
>    FOREACH(month IN months |
>      CREATE (m:Month {value: month})
>     MERGE (y)-[:CONTAINS]->(m)
>     FOREACH(day IN (CASE
>                        WHEN month IN [1,3,5,7,8,10,12] THEN range(1,31)
>                       WHEN month = 2 THEN
>                         CASE
>                           WHEN year % 4 <> 0 THEN range(1,28)
>                            WHEN year % 100 = 0 AND year % 400 = 0 THEN 
> range(1,29)
>                            ELSE range(1,28)
>                          END
>                        ELSE range(1,30)
>                      END) |
>        CREATE (d:Day {value: day})
>        MERGE (m)-[:CONTAINS]->(d))))
>
> If i now save data:
>
> MERGE (a:tracking {ip:'someniceid', type:'page_view', timestamp:'2154645'})
> MERGE (f:Domain {name:'domain1.com'})
> MERGE (e:Domain {name:'domain2.com'})
> MERGE (d:Domain {name:'domain3.com'})
> MERGE (z:Domain {name:'domain4.com'})
> MERGE (a)-[:CAME_FROM]->(f)
> MERGE (f)-[:REFERRED_BY]->(e)
> MERGE (e)-[:REFERRED_BY]->(d)
> MERGE (d)-[:REFERRED_BY]->(z)
> WITH a, 2016 AS y
> MATCH (year:Year {value: y})
> WITH a, year, 5 AS m
> MATCH (year)-[:CONTAINS]->(month:Month {value: m})
> WITH a, month, 9 AS d
> MATCH (month)-[:CONTAINS]->(day:Day {value: d})
> WITH a, day, 14 AS h
> MERGE (day)-[:CONTAINS]->(hour:Hour {value: h})
> MERGE (a)-[:HAPPENED_ON]->(hour)
>
> I get the following graph with query:
>
> MATCH (y)-[:CONTAINS]->(m:Month {value: 5}) WITH y, m
> MATCH (m)-[:CONTAINS]->(d {value: 9}) WITH y, m, d
> MATCH (d)-[:CONTAINS]->(h {value: 14}) WITH y, m, d, h
> MATCH (a:tracking)-[:HAPPENED_ON]->(h),(a)-[:CAME_FROM|:REFERRED_BY*]->(dom) 
> RETURN dom AS D, a AS A
>
> [image: enter image description here] <http://i.stack.imgur.com/wcS6m.jpg>
>
> When I now save one more dataset with the only difference of changing the
> hour and domain (instead of domain4 we have now domain6) like:
>
> MERGE (a:tracking {ip:'someniceid', type:'page_view', timestamp:'2154645'})"
> MERGE (f:Domain {name:'domain1.com'})
> MERGE (e:Domain {name:'domain2.com'})
> MERGE (d:Domain {name:'domain3.com'})
> MERGE (z:Domain {name:'domain6.com'})
> MERGE (a)-[:CAME_FROM]->(f)
> MERGE (f)-[:REFERRED_BY]->(e)
> MERGE (e)-[:REFERRED_BY]->(d)
> MERGE (d)-[:REFERRED_BY]->(z)
> WITH a, 2016 AS y
> MATCH (year:Year {value: y})
> WITH a, year, 5 AS m
> MATCH (year)-[:CONTAINS]->(month:Month {value: m})
> WITH a, month, 9 AS d
> MATCH (month)-[:CONTAINS]->(day:Day {value: d})
> WITH a, day, 10 AS h
> MERGE (day)-[:CONTAINS]->(hour:Hour {value: h})
> MERGE (a)-[:HAPPENED_ON]->(hour)
>
> So with the same query above one more referrer was added which to my
> opinion shouldnd happen because of the different time (hour) node related
> to the tracking node:
>
> [image: enter image description here] <http://i.stack.imgur.com/CrlP9.jpg>
>
> Referrer relations are shown in spite the tracking was connected to a
> different hour node! What did i do wrong? For me domain 6 shouldn't be
> visible because the related tracking was not connected with that time
> node... Someone has an idea?
>
> --
> 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.

Reply via email to