删除索引及其项的Cypher命令是什么?

4

如果我使用默认的Lucene索引引擎,删除索引的Cypher命令是什么?另外,在特定索引中删除索引条目的Cypher命令是什么?

2个回答

6

我不知道你的问题是否已过时,因为你可能正在使用更新版本的Neo4j,但在2.2.1版本中,可以通过Cypher删除索引。

DROP INDEX ON :Label(property)

0

嗯,我不确定是否有一种使用Cypher删除Index的方法。

但是您可以使用Neo4j API按以下方式执行此操作:

for ( String indexName : server.getDatabase().graph.index()
                    .nodeIndexNames() )
            {
                    try{
                        server.getDatabase().graph.index()
                                .forNodes( indexName )
                                .delete();
                    } catch(UnsupportedOperationException e) {
                            // Encountered a read-only index.
                    }
            }

            for ( String indexName : server.getDatabase().graph.index()
                    .relationshipIndexNames() )
            {
                    try {
                        server.getDatabase().graph.index()
                                .forRelationships( indexName )
                                .delete();
                    } catch(UnsupportedOperationException e) {
                            // Encountered a read-only index.
                    }
            }

你可以在这里查看一下,可能会对你有所帮助。

嗨ManSour,感谢您的回答。我发现删除索引的Cypher命令是:index --delete“index_name”。但我仍然不知道在特定索引中删除索引条目的Cypher命令。 - William Zhang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接