Reputation: 610
Neo4j documentation says that, read operations don't require to be in a transaction.
In the code below,
// graphDB and name variables defined somewhere.
graphDB.index().forNodex("indexKey").get("name", name);
"index", "forNodes" and even "get" functions of api require to be called in a transaction, how I know, they all begin with "assertInTransaction();" line.
What's the recommended usage of index? Should they be surrounded by a transaction all the time?
Upvotes: 0
Views: 83
Reputation: 41706
It always needs a read transaction, the code is wrong if there is not one.
Upvotes: 1