neo4j cypher:无法创建和使用索引 [英] neo4j cypher : unable to create and use an index

查看:371
本文介绍了neo4j cypher:无法创建和使用索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在neo4j 2.0上创建一些索引,但我无法理解这里有什么问题。从新数据库开始,我的输入命令看起来像

I'd like to create a few indexes on neo4j 2.0 but I can't understand what's wrong here. Starting with a fresh database, my input command looks like

CREATE INDEX ON :user(name);
CREATE INDEX ON :root(root);
CREATE INDEX ON :origin(origin);
CREATE INDEX ON :gender(gender);
create (n1:root {root : 'root'}),(n2:gender {gender : 'female'}),(n3:gender {gender : 'male'}),(n4:origin {origin : 'english (modern)' }),(n5:origin {origin : 'finnish' }),(n6:user {name : 'aaliyah'}),(n7:user {name : 'aapeli'}),(n8:user {name : 'aapo'});

此时一切看起来都很好(参见下面的输出)但是当我尝试使用索引时得到错误:

Everything looks fine at this point ( see the output below) but when I try to use the index I get an error:

neo4j-sh (0)$ start n=node:user(name="aapo") return n;
MissingIndexException: Index `user` does not exist

知道为什么会这样吗?请注意,在索引之前创建节点不会改变任何内容。

Any idea why this is happening ? Note that creating the nodes before the index doesn't change anything.

提前致谢

我的输出第一个命令:

neo4j-sh (0)$ CREATE INDEX ON :user(name);
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
235 ms
neo4j-sh (0)$ CREATE INDEX ON :root(root);
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
246 ms
neo4j-sh (0)$ CREATE INDEX ON :origin(origin);
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
173 ms
neo4j-sh (0)$ CREATE INDEX ON :gender(gender);
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
160 ms
neo4j-sh (0)$ create (n1:root {root : 'root'}),(n2:gender {gender : 'female'}),(n3:gender {gender : 'male'}),(n4:origin {origin : 'english (modern)' }),(n5:origin {origin : 'finnish' }),(n6:user {name : 'aaliyah'}),(n7:user {name : 'aapeli'}),(n8:user {name : 'aapo'});
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 8
Properties set: 8
Labels added: 8
1027 ms


推荐答案

通过Cypher创建的索引是称为Schema索引,不能在 START 子句中使用。 START 子句索引查找是为您通过自动索引或通过非Cypher API创建的旧索引保留的。

The indexes created via Cypher are called Schema indexes, and are not to be used in the START clause. The START clause index lookups are reserved for the legacy indexes that you create via autoindexing or through the non-Cypher APIs.

为了使用你创建的:user索引,你可以这样做:

In order to use the :user index you've created, you can do this:

match n:user
where n.name="aapo"
return n;

尝试使用个人资料

这篇关于neo4j cypher:无法创建和使用索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆