neo4j中基于时间的数据 [英] Time-based data in neo4j

查看:614
本文介绍了neo4j中基于时间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对图形数据库有疑问,请问有人可以帮我吗?我是 在mysql中处理大量的数据,每天大约有5M条记录由a发送 路由器,例如设备,接入点,无线网桥.数据是 通常是健康数据,gps等...这些是车辆上的设备.怎么做 您在图形数据库中处理基于时间的数据?有没有人申请 neo4j用于基于时间的数据?知道如何查询真是太好了 间隔以及如何进行建模.

have a question on graph databases, can some one help me please? I'm handling quite a lot of data in mysql about 5M records a day sent by a router like device, access points, wireless bridges. The data is usually health data, gps etc... these are devices on vehicles. How do you handle time based data in graph databases? Has anyone applied neo4j for time-based data? It would be great to know how you query intervals and how you'd go about modelling.

我想我可以在每次接收数据时创建一个节点 每次更改gps时设置的属性,健康吗?那会是时候 基于图表-听起来正确吗? 对于5M行,MySQL的性能还不错-但随着路由器的更新, 功能新数据通过,我需要创建新模型 同样,这还不错,但也不是很好. 我想要一些半结构化的东西,使相关的内容有所不同 诸如为什么用户被踢出的原因是由于访问点 与路由器关联的路由器已关闭.我通常的疑问是提出 发出警报,告知其中一台设备已关闭或设备数量减少 吞吐量等.neo4j是否可以帮助我建立起这些关系 比mysql更好?

I guess I can create a node for every single time i receive data with properties set each time like changed gps, health? It would be a time based graph - does that sound right? well with 5M rows mysql isn't performing bad - but as router gets new functionality new data comes through and I need to create new models again which isn't bad but not great. i want something which is semi structured and makes relating different things like why the user got kicked out is because of an access point associated to the router is down. My usual queries would be to raise alerts to say one of the device is down or if there is a reduced throughput etc. Would neo4j help me in marrying up these relationships better than mysql?

很想知道你们的想法,任何评论和想法 赞赏.

Would love to know what you guys think, any comments + thoughts appreciated.

推荐答案

请参考以下GraphGist,以获取有关如何使用时间标度进行基于时间的图存储的教程.

Please refer to the following GraphGist for a tutorial on how to do time-based graph storage using time scales.

http://gist.neo4j.org/? github-kbastani%2Fgists%2F%2Fmeta%2FTimeScaleEventMetaModel.adoc

在上面建模的时间刻度图中,从蓝色节点到透明节点的最短路径遍历以位为单位构成唯一的时间标识.

In the time scale graph that is modeled above, a shortest path traversal from a blue colored node to the transparent colored node constitutes a unique time identity in bits.

红色路径跟踪的标识为0→1→0→1→0→0.反向路径为0→0→1→0→1→0或简称为001010,即唯一的位标识.

The identity traced by the red path is 0→1→0→1→0→0. The reverse path is 0→0→1→0→1→0 or simply 001010, a unique identity in bits.

MATCH p=shortestPath((n1:d)-[:child_of*]->(n2:y))
WHERE n1.key = 'd10'
RETURN DISTINCT reduce(s = '' , n IN nodes(p)| n.tempo + s) AS TimeIdentity
ORDER BY TimeIdentity

上面的Cypher查询对从蓝色节点到透明节点的最短路径遍历进行建模.这是一个比特串,表示时间标识,可以根据事件在时间标度事件子图上的位置,按事件对其进行排序.

The Cypher query above models a shortest path traversal from blue colored node to transparent colored node. This is a bit string that represents a time identity that can be ordered by event depending on its position on the time scale event subgraph.

请参见下面的时间标度事件子图:

Please see the time scale event subgraph below:

上面的图像表示连接到一系列事件(met)的时间标度.事件(在图像中表示为三角形节点)也与要素的层次结构(John,Sally,Pam,Anne)相关,然后进一步归纳为类(Person).

The image above represents a time scale connected to a series of events (met). Events, represented as triangular nodes in the image, are also connected to a hierarchy of features (John, Sally, Pam, Anne) which are then further generalized into classes (Person).

现在,您可以像前面列出的那样运行Cypher查询,该查询将按照发生的时间将事件按位字符串排序.注意:您应该将时间戳记应用到检索实际时间的节点.每个蓝色节点表示一个时间分隔的事件,但不一定表示实际时间,仅表示按顺序发生的事件.

Now you can run a Cypher query like the one I listed earlier which will then order the events by time of occurrence as a bit string. Note: That you should apply a timestamp to the node that retrieves the actual time. Each blue node represents a time separated event but not necessarily the actual time, just a representation of events that happened in an order.

MATCH p=(p0:person)-[:event]->(ev)-[:event]->(p1:person)
WITH p, ev
MATCH time_identity = (d0:d)<-[:event]-(ev)
WITH d0, p
MATCH p1=(d0)-[:child_of*]->(y0:y)
RETURN extract(x IN nodes(p)| coalesce(x.name, x.future)) AS Interaction, reduce(s = '' , n IN nodes(p1)| n.tempo + s) AS TimeIdentity
ORDER BY TimeIdentity

时间刻度中的层次结构使您可以对事件进行分组并查看更高级别的表示.因此,选择橙色节点下的所有绿色节点会选择4个可能的事件(以蓝色节点表示).

The hierarchies in the time scale allow you to group events and to see representations at higher levels. So selecting all green nodes below an orange node selects 4 possible events (represented by blue nodes).

如果您有任何疑问,请与我联系,一定要访问GraphGist以查看更多详细信息和时标事件子图的实际示例.

Let me know if you have any questions, and be sure to visit the GraphGist to see more details and actual live examples of the time scale event subgraph.

这篇关于neo4j中基于时间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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