Neo4j node property type

graph-databases, neo4j

Solution

True, it does depend on your use case. If you add a type property and then wish to find all users, then you're in potential trouble as you've got to examine that property on every node to get to the users. In that case, the index would probably do better- but not in cases where you need to query for all users with conditions and relations not available in the index (unless of course, your index is the source of the "start"). If you have graphs like mine, where a relation type implies two different node types like A-(knows)-(B) and A or B can be a User or a Customer, then it doesn't work.

So your use case is really important- it's easy to model graphs generically, but important to "tune" it as per your usage pattern.

Problem

I'm playing around with neo4j, and I was wondering, is it common to have a `type` property on nodes that specify what type of Node it is? I've tried searching for this practice, and I've seen some people use `name` for a purpose like this, but I was wondering if it was considered a good practice or if indexes would be the more practical method? An example would be a "User" node, which would have type: `user`, this way if the index was bad, I would be able to do an all-node scan and look for types of `user`.

Original source