【发布时间】:2017-05-12 02:02:49
【问题描述】:
现在我正在设计一个带有 Neo4j 数据库的系统,我必须能够查询检查节点中的 Date 属性是否在提供的 Date 之前、等于或之后。
我应该如何将Date 存储在 Neo4j 节点属性中,以便能够与 Cypher 查询进行比较,例如基于 ==、>、< 等简单运算符的查询
可以像Long timestamp 一样存储Date 吗?它会这样工作吗?如果否,请提出更好的决定。
更新
我没有成功尝试过的查询:
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = '60305027689736')
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = 'Mon Dec 27 22:35:56 EET 3880')
filterValue153.value 的存储位置类似于 java.util.Date 对象在 Value.value 节点属性中
@NodeEntity
public class Value extends Authorable {
public final static String NODE_NAME = "Value";
private final static String SET_FOR = "SET_FOR";
private final static String SET_ON = "SET_ON";
@Relationship(type = SET_FOR, direction = Relationship.OUTGOING)
private Decision decision;
@Relationship(type = SET_ON, direction = Relationship.OUTGOING)
private Characteristic characteristic;
private Object value;
...
}
在Value 节点的数据库级别,我有以下数据:
id: 848013
value: 1482873001556
更新
这个查询工作正常
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = 60305030539682)
但是如何处理 1970 年 1 月 1 日 00:00:00 GMT 之前的日期?
也可以在此 Cypher 查询中应用 =、>、< 操作日期吗?
【问题讨论】:
标签: neo4j cypher spring-data-neo4j