问题描述
我有一些运行 Cypher init 脚本的集成测试套件,我希望其中的所有操作都是幂等的。
第一次运行 CALL db.index.fulltext.createNodeIndex("usernames",["User"],["username"])
运行良好,但在随后的尝试中失败。
我试过了:
CALL apoc.do.when(
apoc.schema.node.indexExists("User",["username"]),'RETURN NULL','CALL db.index.fulltext.createNodeIndex("usernames",["username"])'
)
结果:
Failed to invoke procedure `apoc.do.when`: Caused by: org.neo4j.graphdb.security.AuthorizationViolationException: Schema operations are not allowed for user 'neo4j' with roles [PUBLIC,admin] overridden by TOKEN_WRITE overridden by TOKEN_WRITE.
如何使用全文索引实现此目的?
这是在 Neo4j 4.2.1 中
解决方法
您不能运行密码查询来删除/创建索引。但是您可以分两步删除/创建它,例如
CALL db.index.fulltext.drop("usernames") ;
CALL db.index.fulltext.createNodeIndex("usernames",["User"],["username"]) ;