Neo4j Cypher 比较 Cypher 查询中的日期
Neo4j Cypher comparing dates in Cypher query
现在我正在设计一个带有 Neo4j 数据库的系统,我必须能够查询检查节点中的 Date
属性 是在提供的之前、等于还是之后Date
.
我应该如何将 Date
存储在 Neo4j 节点 属性 中,以便能够与基于 ==
、[=18 等简单运算符的 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 查询中对日期应用 =
、>
、<
操作吗?
相关问题:
- Compare dates with Spring Data neo4j
然而,这个问题可以追溯到 2012 年。从那时起,我们就有了支持 date/time conversion. This lets you convert date/time values in formats described in the Javadoc of the SimpleDateFormat
class 的 APOC。
1970 年 1 月 1 日之前的日期将有效,它们将简单地用 negative numbers 表示。例如:
CALL apoc.date.parseDefault('1969-07-21 02:56:15', 's')
YIELD value
算术比较运算符(=
、<>
、<
、...)将对时间戳起作用。
现在我正在设计一个带有 Neo4j 数据库的系统,我必须能够查询检查节点中的 Date
属性 是在提供的之前、等于还是之后Date
.
我应该如何将 Date
存储在 Neo4j 节点 属性 中,以便能够与基于 ==
、[=18 等简单运算符的 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 查询中对日期应用 =
、>
、<
操作吗?
相关问题:
- Compare dates with Spring Data neo4j
然而,这个问题可以追溯到 2012 年。从那时起,我们就有了支持 date/time conversion. This lets you convert date/time values in formats described in the Javadoc of the SimpleDateFormat
class 的 APOC。
1970 年 1 月 1 日之前的日期将有效,它们将简单地用 negative numbers 表示。例如:
CALL apoc.date.parseDefault('1969-07-21 02:56:15', 's')
YIELD value
算术比较运算符(=
、<>
、<
、...)将对时间戳起作用。