Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can query a node from index #179

Open
hansman opened this issue Oct 14, 2015 · 8 comments
Open

Can query a node from index #179

hansman opened this issue Oct 14, 2015 · 8 comments
Labels

Comments

@hansman
Copy link

hansman commented Oct 14, 2015

What happens here?

  • create a node
  • save the node
  • index the node
  • get the indexed node

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
Copy link
Member

aseemk commented Oct 14, 2015

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
Copy link
Member

aseemk commented Oct 14, 2015

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
Copy link
Author

hansman commented Oct 14, 2015

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
Copy link
Member

aseemk commented Oct 14, 2015

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

  • You write db.index, but your code is actually node.index, right?
  • There are no errors returned for any of these calls, incl. node.index?

Assuming both of these are indeed the case:

  • What happens if you check the index after some delay (e.g. a few seconds)? Does it show up? If so, it would seem that Neo4j legacy indexes are eventually consistent, not immediate. I don't know anything about that, though; might check with the Neo4j mailing list or Slack.
  • You might already be aware of this, but could you use Neo4j v2 schema indexes? Those are immediately consistent, I'm pretty sure.

@hansman
Copy link
Author

hansman commented Oct 14, 2015

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
Copy link
Author

hansman commented Oct 14, 2015

question: have you tried doing this yourself?

@aseemk
Copy link
Member

aseemk commented Oct 14, 2015

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
Copy link
Member

aseemk commented Oct 14, 2015

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

'index nodes': (_) ->
daniel.index 'users', 'name', 'Daniel', _
node = db.getIndexedNode 'users', 'name', 'Daniel', _
expect(node).to.be.an 'object'
expect(node.exists).to.be.true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants