Neo4j 节点属性类型 [英] Neo4j node property type

查看:90
本文介绍了Neo4j 节点属性类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在玩neo4j,我想知道,在节点上有一个 type 属性来指定它是什么类型的节点是很常见的吗?我试过搜索这种做法,我看到有些人将 name 用于这样的目的,但我想知道这是否被认为是一种好的做法,或者索引是否更实用方法?

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?

一个例子是用户"节点,它的类型是:user,这样如果索引不好,我就可以进行全节点扫描并查找类型用户.

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.

推荐答案

确实,这取决于您的用例.如果您添加一个类型属性,然后希望找到所有用户,那么您可能会遇到麻烦,因为您必须在每个节点上检查该属性才能找到用户.在这种情况下,索引可能会做得更好 - 但在您需要查询条件和关系在索引中不可用的所有用户的情况下(当然,除非您的索引是开始"的来源).如果您有像我这样的图表,其中关系类型意味着两种不同的节点类型,如 A-(knows)-(B) 并且 A 或 B 可以是用户或客户,那么它不起作用.

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.

这篇关于Neo4j 节点属性类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆