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

查看:138
本文介绍了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,这样,如果索引不好,我就可以进行全节点扫描并查找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-(知道)-(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天全站免登陆