C0deAttack
C0deAttack

Reputation: 24667

Cypher Query not finding Node

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.

Upvotes: 0

Views: 243

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33155

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

Upvotes: 3

Related Questions