2017-05-06 91 views
0

我是Cypher和Neo4j的新手。我有一组标有“线”每一行是一个很长的字符串,如节点: 0067011990999991950051507004+68750+023550FM-12+038299999V0203301N00671220001CN9999999N9+00001+99999999999cypher如何从其他节点的子串创建独特节点

有迹象表明我关心大约两子:yeartemp

match(l:Line) 
return toInteger(substring(l.line,15,4)) as year, toInteger(substring(l.line,87,5)) as temp 
limit (5) 

为了给:

year temp 

1941 44 

1942 90 

1942 12 

1948 100 

1948 -21 

我需要创建一套标有“年”为今年的每个唯一值的节点,一组不一的标有“温度”为每一个独特的温度读数。我还需要使用关系has_temp将每年的温度读数关联起来。 。(然后打印一年,温度读数和关系型降序排序的年度顺序

任何帮助,将不胜感激

回答

0

试试这个:

match(l:Line) 
with toInteger(substring(l.line,15,4)) as year, 
toInteger(substring(l.line,87,5)) as temp 
MERGE (y:Year{value:year}) 
MERGE (t:Temp{value:temp}) 
MERGE (y)-[s:has_temp]->(t) 
RETURN year,temp,type(s) as rel_type order by year desc 

如果你想检查后如何导入的节点,你可以这样做:!?

MATCH (y:Year)-[r]->(t:Temp) 
RETURN y.value as year,t.value as temp,type(r) as re_tzpe order by year desc 
+0

谢谢这与阅读人数最多的伟大工程 – Rachel

+0

如何获得年度(S)我知道我可以这样做MATCH (y:Year) - [r] - >(t:Temp) RETURN y.value as year,count(t.value)as temp_readings order by temp_readings desc limit 2; - resutlts 年\t temp_readings 1950年 1951年\t 75我可能有多年的读数相同的最高数量,因此限制不是一个好办法。任何其他想法?谢谢。 – Rachel