2017-08-17 49 views
-1

我是新来的Neo4j,我被困在一个简单的问题:neo4j的这个创建语句语法有什么问题?

create (machine1:host); 
match (n) where n.host='machine1' return n; 

匹配失败。当使用解释我看到这个:

The provided property key is not in the database 
One of the property names in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing property name is: host) 

我做错了什么?感谢大家的时间。

+0

我要注意:我使用的是社区版,版本3.2.1上述行作为在原本空白的新数据库所使用的前两行。 – ewm

回答

3

您应该知道标签和属性之间的区别。 标签是Node的分组工具,所有具有标签的节点都是同一组的一部分。 我认为你应该使用机器标签来表示机器的节点。 而你应该使用主机属性来存储它的名字值。

create (:Machine {host:'machine1'}); 
    match (n) where n.host='machine1' return n; 

甚至更​​好:

match (n:Machine) where n.host='machine1' return n; 
+0

现在我明白了!谢谢! – ewm

+0

这与数学图不同,其中标签唯一地应用于单个顶点。此外,neo4j的术语页面(https://neo4j.com/docs/developer-manual/current/terminology/)对于属性也很模糊:“存储在节点或关系中的属性 - 名称值,属性的同义词”。和“属性 - 属性的同义词”。 – ewm