現在我正在設計一個Neo4j數據庫系統,我必須能夠查詢一個節點中的Date
屬性是否在提供的Date
之前,等於或之後。Neo4j Cypher比較Cypher查詢日期
我應該如何存儲Date
Neo4j的節點屬性的內部能夠例如基於簡單的運營商如==
,>
做暗號查詢比較,<
是否還好存儲Date
像Long timestamp
?它會以這種方式工作嗎?如果不是,請提出更好的決定。
修訂
查詢我已經沒有運氣嘗試:
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
節點我有一個fo llowing數據:
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查詢日期?
感謝您的回答。我已經更新了我的問題,並提供了更多細節。你能告訴我做錯了什麼嗎?另外,請您舉一個例子說明如何使用新舊方法(使用APOC)來完成這項工作? – alexanoid
如果您只是使用此查詢返回節點,您會得到什麼結果? 'MATCH(filterCharacteristic153:Characteristics)WHERE id(filterCharacteristic153)= 153 RETURN *' –
我已經爲我的Neo4j添加了輸出值'Value'節點 – alexanoid