NEO4j 3.0 retrieve data between certain period

时间:2016-08-31 12:21:49

标签: neo4j

I'm using NEO4J 3.0 and it seems that HAS function was removed. Type of myrelationship is a date and I'm looking to retrieve all relation between two dates such as my property "a" is greater than certain value.

How can I test this using NEO4j Thank you

[EDITED to add info from comments]

I have tried this:

MATCH p=(n:origin)-[r]->()
WHERE r>'2015-01'
RETURN AVG(r.amount) as totalamout;

I created relationship per date and each one has a property, amount, and I am looking to compute the average amount for certain period. As example, average amount since 2015-04.

1 个答案:

答案 0 :(得分:1)

要回答第一句话引发的问题:在neo4j 3.x中,HAS()函数已替换为EXISTS()

[更新1]

此版本的查询应该有效:

MATCH p=(n:origin)-[r]->()
WHERE TYPE(r) > '2015-01'
RETURN AVG(r.amount) as totalamout;

但是,根据日期为您的关系提供不同的类型是一个坏主意。最好只使用date属性。

[更新2]

如果您更改了数据模型以向您的关系添加date属性(我将向其提供类型FOO),则以下查询将找到每{{1}的平均数量pdate之后的所有关系(假设您的所有日期都遵循相同的严格2015-01模式):

YYYY-MM