Cypher Query not finding Node

↘锁芯ラ 提交于 2019-12-13 06:19:48

问题


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());

The console shows:

::: Verify Index Name :::
movieId

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"))

The console shows

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

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);

The console shows

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

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

Thanks.


回答1:


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


来源:https://stackoverflow.com/questions/15284565/cypher-query-not-finding-node

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!