thingdom / node-neo4j

[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Apache License 2.0
926 stars 136 forks source link

Can query a node from index #179

Open hansman opened 9 years ago

hansman commented 9 years ago

What happens here?

var indexName = 'myNodeIndex'; var node = db.createNode({name: 'hey'}); node.save(function() { db.index(indexName, 'name', 'hey', function() { db.getIndexedNode(indexName, 'name', 'hey', console.log) }) })

Expected: getIndexedNode returns the node that just got indexed.

Actual: getIndexedNode has empty response

aseemk commented 9 years ago

You're passing console.log as a callback directly. Can you instead pass a proper function (err, node) { console.log(node); } callback? Does that work?

aseemk commented 9 years ago

The other thing is, you're not seeing if you're getting any errors. For each of the callbacks, it's good to check if (err) throw err; where err is the first param.

hansman commented 9 years ago

For sure. This code is only to point out the flow. console.log is sufficient to see that there is an empty response which is the point of this demonstration.

aseemk commented 9 years ago

Got it. Would you mind confirming a couple things for sanity:

Assuming both of these are indeed the case:

hansman commented 9 years ago

no errors. yes I use node.index. I can't get the node from the index even after a long delay. Not a eventual consistency case.

hansman commented 9 years ago

question: have you tried doing this yourself?

aseemk commented 9 years ago

Okay, surprising.

No, I haven't tried this myself. We use exclusively v2 schema indexes and legacy auto-indexes, not legacy manual indexes. I can try myself later.

Another thing to try would be using the Neo4j webadmin to do these things manually. Does it work there? If so, suggests a node-neo4j or code bug. If not, suggests a Neo4j bug.

aseemk commented 9 years ago

However, we do cover manual indexing in our tests, and that's always worked:

https://github.com/thingdom/node-neo4j/blob/b1f6348c447fd052836532086efdc55638391983/test/crud._coffee#L220-L224