简体   繁体   English

OrientDB时间搜索查询

[英]OrientDB Time Search Query

In OrientDB I have setup a time series using this use case . OrientDB中,我已使用此用例设置了时间序列。 However, instead of appending my Vertex as an embedded list to the respective hour I have opted to just create an edge from the hour to the time dependent Vertex. 但是,我没有将我的顶点作为嵌入列表附加到各个小时,而是选择仅创建一个从小时到与时间相关的顶点的边。

For arguments sake lets say that each hour has up to 60 time Vertex each identified by a timestamp. 为了争辩,可以说每个小时最多包含60个时间Vertex每个时间Vertex都由时间戳标识。 This means I can perform the following query to obtain a specific desired Vertex: 这意味着我可以执行以下查询以获得特定的所需顶点:

SELECT FROM ( SELECT expand( month[5].day[12].hour[0].out() ) FROM Year WHERE year = 2015) WHERE timestamp = 1434146922

The first part of this question is whether there are any advantages/disadvantages to storing the timestamp as a property of the Vertex (as above query) versus storing it as the edge (or an edge property). 这个问题的第一部分是将时间戳存储为Vertex的属性(如上述查询)与将其存储为边缘(或edge属性)是否有任何优点/缺点。 In which case I think the query would be: 在这种情况下,我认为查询将是:

SELECT expand( month[5].day[12].hour[0].out('1434146922') ) FROM Year WHERE year = 2015

Although this looks more elegant I have 2 concerns; 尽管这看起来更优雅,但我有两个问题。 the overhead of creating new edge types. 创建新边缘类型的开销。 The flexibility if you don't actually know the exact timestamp. 灵活性,如果您实际上不知道确切的时间戳。

The second part of the question relates to the fact that once I have isolated the individual Vertex based on time, this is only the head of a hierarchal tree of Vertex. 问题的第二部分涉及以下事实:一旦我根据时间隔离了单个顶点,这仅仅是顶点层次树的头部。

I could of course get the @rid from the above query and then construct a new query but I was wondering how I could adapt the above to do it all in one. 我当然可以从上面的查询中获取@rid ,然后构造一个新查询,但是我想知道如何才能将上面的内容@rid实现。 For example assume there is a boolean property called active in all the hierarchal Vertexes. 例如,假设在所有分层顶点中都有一个称为activeboolean属性。 How can I get all the Vertex that are true ? 我怎样都可以得到的顶点是true

Answer for the first part of your question : 回答问题的第一部分:

Like stated in the use case documentation : 就像用例文档中所述:

If you need more granularity than the Hour you can go ahead until the Time unit you need: 如果您需要比小时更多的粒度,则可以继续使用直到需要的时间单位:

Hour -> minute (map) -> Minute -> second (map) -> Second

You get more flexibility by adding more precision to the tree instead of storing a timestamp of the time in the hour. 通过为树添加更多精度而不是将时间的时间戳存储在小时中来获得更大的灵活性。

Adding more precision to the tree has the only advantage of being able to group by smaller time unit in a really efficient way. 为树添加更高的精度的唯一优势是能够以一种真正有效的方式按较小的时间单位进行分组。 If you don't need to group by a smaller unit then an hour, then you don't have to add more precision. 如果您不需要按一个小时来分组较小的单位,则不必增加精度。

The timestamp should be stored in the vertex property because the filtering will be easy and efficient. 时间戳应该存储在vertex属性中,因为过滤将很容易且有效。 Check out this blog bost to know the best way to filter on a vertex property when traversing : Improved SQL filtering 查看此博客,了解遍历时对顶点属性进行过滤的最佳方法: 改进的SQL过滤

Answer for the second part of your question : 回答问题的第二部分:

Get the specific vertex and then do your query on the hiearachical tree of vertex : 获取特定的顶点,然后在该顶点的层次树上进行查询:

<your-hierachical-tree-query> from (select out('edge')[property = "value"] from
(select expand(month[1].day[1].hour[1].min[1]) from Year where year = 2015))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM