密码查询未找到节点 [英] Cypher Query not finding Node

查看:111
本文介绍了密码查询未找到节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这样的Java项目中创建了一个嵌入式Neo4J:

I have created an embedded Neo4J in a Java project like this:

graphDb = new GraphDatabaseFactory()
            .newEmbeddedDatabaseBuilder("db")
            .setConfig(GraphDatabaseSettings.node_keys_indexable, "movieId, userId, rating, genre")
            .setConfig(GraphDatabaseSettings.node_auto_indexing, "true")
            .newGraphDatabase();

我已经验证了索引已创建,并且它具有我期望的名称:

I have verified that the index is created, and it has the name that I expect:

Index<Node> index = graphDb.index().forNodes("movieId");
System.out.println("::: Verify Index Name :::");
System.out.println(index.getName());

控制台显示:

::: Verify Index Name :::
movieId

我可以使用Java API查找节点

I can find the node using the Java API

ReadableIndex<Node> graphDbIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex();
Node movie = graphDbIndex.get("movieId", 2).getSingle();
System.out.println("::: Get with Java API Result :::");
System.out.println("MovieId: " + movie.getProperty("movieId"));
System.out.println("Title: " + movie.getProperty("title"))

控制台显示

::: Get with Java API Result :::
MovieId: 2
Title: Jumanji (1995)

但是当我尝试使用Cypher时,结果就是

But when I try with Cypher this is the result

ExecutionEngine engine = new ExecutionEngine(graphDb);
ExecutionResult result = engine.execute("start movie=node:movieId(movieId='2') return movie, movie.title");
System.out.println("::: get with Cypher Result :::");
System.out.println(result);

控制台显示

::: get with Cypher Result :::
+---------------------+
| movie | movie.title |
+---------------------+
+---------------------+
0 row
8 ms

我做错了什么还是只是错过了明显的事情?

Am I doing something very wrong or have I just missed something obvious?

谢谢.

推荐答案

id是字符串吗?尝试使用lucene索引语法:

Is the id a string? Try like this with the lucene index syntax:

start movie=node:node_auto_index('movieId:2') 
return movie, movie.title

这篇关于密码查询未找到节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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