1

Is there a way to get a node by specific attributes using the Java API? Specifically:

  • By Name
  • By Label
  • By properties - (various properties)

The only functions I found were:

findNode(label)
findNode(label, key, value)

Which only supports one property. Or do I have to use Cypher to get this?

Gabor Szarnyas
  • 4,410
  • 3
  • 18
  • 42
raycons
  • 735
  • 12
  • 26
  • It is not clear what you mean by "name" in your question. Nodes do not have "names". You can specify a "name" property if you want, but it would have no special significance to neo4j. Using Cypher, you can specify an "identifier" for a node, but identifiers are only meaningful within a Cypher query, and are never persisted in the DB. – cybersam Oct 28 '16 at 17:04
  • Ah sorry I confused the label. I was talking about multiple labels and multiple properties. And I don't like using cypher that much there. As far as I understood I don't have the transaction guarantees and they're slower. – raycons Oct 29 '16 at 12:13
  • Cypher queries run in transactions, and are not necessarily slower. – cybersam Oct 30 '16 at 23:51

1 Answers1

2

If your question is about how to find nodes that have specific multiple property values, the Java API has no method that does that task. In general, it is easier to use Cypher for that.

cybersam
  • 63,203
  • 6
  • 53
  • 76
  • But isn't cypher slower? – raycons Oct 29 '16 at 11:48
  • Cypher can be faster, but it depends. The Cypher implementation is improving ll the time, and can the cost planner can alter the runtime processing depending on the characteristics of your actual data characteristics at the time -- something a hardcoded Java imlementation cannot do, – cybersam Oct 30 '16 at 23:55