问题描述
我正在使用Neo4j 2.0版本。假设我有很多记录作为他们的字段之一,如果我们需要支持大量的查询,比如两个特定日期之间的记录计数等等,我认为我可以通过Date字段对所有的记录进行tpo索引。这是正确的吗?那么,我该怎么做RECORD类型的所有节点都需要被编入索引日期。我该如何实现?
请注意,Date是一个不唯一的字段。
我如何甚至在记录中存储Date属性。在CYPHER或Neo4j中支持日期。
如何按日期字段对记录进行排序?
不直接支持作为属性值的日期。根据您的使用情况,您通常会使用DateFormatter(在Java地区)使用长时间的财产或字符串表示从纪元(也称为date.getTime())存储毫秒。
如果您打算使用日期进行任何数学运算,长代表性将更适合。如果您希望您的属性在没有任何转换的情况下,您的属性是可读的,则字符串会更好。
在日期需要索引时,最简单的方法是从历元存储millis并将模式索引应用于这个。
I am using Neo4j 2.0 version. Suppose, I have lot of records which have date as one of their fields and if we need to support lot of queries like count of records between two specific dates etc, I think that I may have tpo index all the records by Date field.Is this correct? Then., how do I do it. All nodes of the type "RECORD" need to be indexed dy date. How can I achieve this?Please note that Date is a not unique field.And how do I even store Date property in the records. Is Date supported in CYPHER or Neo4j.How do I sort the records by Date field?
Dates as values for properties are not directly supported. Depending on your usecase you typically store the millis since epoch (aka date.getTime()) in a long property or a string representation using a DateFormatter (when being in Java land).
The long representation is better suited if you intend to do any math operation with dates. String is better if you want your properties being human readable without any conversion.
When requiring indexes on dates the easiest approach would be storing millis since epoch and apply a schema index on this.
这篇关于Neo4j DATE数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!