Neo4j密码时间间隔直方图查询时间树 [英] Neo4j cypher time interval histogram query of time tree

查看:110
本文介绍了Neo4j密码时间间隔直方图查询时间树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对存储在neo4j中作为时间树的时间序列建立直方图. 数据结构是由用户完成的事件,每个用户都有时间戳,例如用户购买类别. 我需要的是每个用户在开始时间和结束时间之间在每个类别上的浏览次数,间隔为(1秒到几天) 我的模型非常擅长为db图形化,因为我阅读了 neo4j文档我无法在一个查询中找到任何方法来完成此操作,而且恐怕呼叫每个用户的速度都会很慢.

I would like to build an histogram on time series stored as time tree in neo4j. The data structures are event done by a user each has timestamp, say user purchases category. What I need to have is the number of browsing on each category by each user between start and end time, with interval of (1 second to days) My model feats graph db very nicely, as I read neo4j documentation I could not find any way to do it in one query, and I'm afraid that calling for each user would be very slow.

我知道密码功能,但是我不知道如何创建这样的查询. 我正在寻找类似的东西(不起作用)

I am aware to cypher capabilities, but I have no idea how to create such query. I am looking for something like this (not working)

MATCH startPath=(root)-[:`2010`]->()-[:`12`]->()-[:`31`]->(startLeaf),
endPath=(root)-[:`2011`]->()-[:`01`]->()-[:`03`]->(endLeaf),
valuePath=(startLeaf)-[:NEXT*0..]->(middle)-[:NEXT*0..]->(endLeaf),
vals=(middle)-[:VALUE]->(event)
WHERE root.name = 'Root'
RETURN event.name, count(*)
ORDER BY event.name ASC
GROUP BY event.timestamp % 1000*60*10 // 10 minutes histogram bar 

然后,我想要一份报告,以了解有多少用户浏览到每个网站类别:

Then I'd like to have a report, for how many users browse to each site category:

0-9条新闻5,商业3; 10-19条新闻6,商务19条; 1 20-29个新闻2,商业8;

0-9 news 5, commerce 3 ; 10-19 news 6, commerce 19; 1 20-29 news 2, commerce 8;

是否知道neo4j时间树模型是否可选? 如果是这样怎么办? :-)

Any idea if it is optional with neo4j time tree model? if so how? :-)

推荐答案

这项工作有效吗?

MATCH
  startPath=(root)-[:`2010`]->()-[:`12`]->()-[:`31`]->(startLeaf),
  endPath=(root)-[:`2011`]->()-[:`01`]->()-[:`03`]->(endLeaf),
  valuePath=(startLeaf)-[:NEXT*0..]->(middle)-[:NEXT*0..]->(endLeaf),
  vals=(middle)-[:VALUE]->(event)
WHERE root.name = 'Root'
RETURN event.name, event.timestamp % 1000*60*10 AS slice, count(*)
ORDER BY slice ASC

基本上,我只是将event.timestamp % 1000*60*10添加到了返回值中,以便Neo4j将其用作分组条件

Basically I just added the event.timestamp % 1000*60*10 into the return so that Neo4j will use that as a grouping criteria

这篇关于Neo4j密码时间间隔直方图查询时间树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆