【发布时间】:2014-03-24 13:17:36
【问题描述】:
我在我的嵌入式graphDb中的标签学生上创建了以下索引
Schema schema = graphDb.schema();
indexDefinition = schema.indexFor(DynamicLabel.label("Student")).on("NodeType").create();
indexDefinition = schema.indexFor(DynamicLabel.label("Student")).on("Marks").create();
使用密码时MATCH查询
这行得通:match (n:Student) return n;
这也有效:match (n:Student) where n.Marks<30 return n;
但是,这失败了:match (n:Student) where n.Marks=30 return n;
还有这个:match (n:Student) where n.Marks='30' return n;
奇怪的是这个有效吗:
start n=node(127) match (n:Student) where n.Marks=30 return n;
有效:我得到了预期的结果,失败:没有结果
任何人都可以解释这种行为,因为所有属性都已被索引(标签)并且密码应该返回所需的结果。
我还使用以下方法检查了标签的属性是否已编入索引:
Label label1 = DynamicLabel.label("Student");
System.out.println(schema.getIndexes(label1));
我正在使用this 方法执行密码查询。
[编辑] 节点创建:
Integer marks = 30;
Label label = DynamicLabel.label("Student");
tx = graphDb.beginTx();
Node studentNode = graphDb.createNode(label);
studentNode.setProperty("NodeType", "Student");
studentNode.setProperty("Marks", marks);
tx.success();
【问题讨论】:
-
我已经试过了,这很有效。我确实必须更正您的密码查询,以便它们在节点'n'周围有括号并删除了几个';'他们不应该去的地方。
-
您是如何使用标签“学生”和“标记”值创建节点的?你用的是什么 Neo4j 版本?
-
我已经编辑了问题,在那里找到它。
-
我正在使用 neo4j-community-2.0.0-M03。