如何对单个Neo4j数据库进行分区? [英] How to partition a single Neo4j database?

查看:245
本文介绍了如何对单个Neo4j数据库进行分区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以对一个Neo4j数据库进行划分,以便在一个数据库中有多个起点,以便可以隔离所有查询,而不是拥有多个数据库?

Can one Neo4j database be divided up so that there are multiple starting points in one database so that all queries can be isolated, instead of having multiple databases?

我已经考虑过这一点,并且我认为它可以起到一定的作用,但是一旦使用了标签之类的方法,该想法将无法正常工作,因为标签查询将始终覆盖整个数据库.

I have thought about this and I think it can work up to a point, but once things like labels are used then the idea will not work, as a label query will always span the whole database.

无论如何,我想知道是否有人成功地做到了这一点,以及他们是如何做到的.

Anyway I would like to know if anyone has successfully done this and how they did it.

推荐答案

您所描述的听起来像多租户. Neo4j 2.0.1目前不支持多租户功能.在Neo4j数据库实例中实现多租户架构的方法和策略多种多样.

What you are describing sounds like multitenancy. Neo4j 2.0.1 does not at this time support multitenancy as a feature. There are various methods and strategies for implementing a multitenant architecture within your Neo4j database instance.

您可以按标签划分属性图的集合.由于节点可以具有多个标签,因此可以使用一个分区的唯一标识标签来标记该分区.

You can partition sets of your property graph by label. Since nodes can have multiple labels, you can label one partition with a unique identifying label for that partition.

请在此处参考有关标签的文档: http://docs. neo4j.org/chunked/milestone/graphdb-neo4j-labels.html

Please refer to documentation on labels here: http://docs.neo4j.org/chunked/milestone/graphdb-neo4j-labels.html

该策略要注意的是要确保所有Cypher调用都包含标签的分区标识符,以确保两个分区在图中相互隔离.重要的是要确保一个分区中的关系不会扩展到另一分区中.

Things to note with this strategy are to ensure that all your Cypher calls contain the partition identifier for the label, to ensure that the two partitions are isolated from one another within the graph. It's important to ensure that relationships from one partition do not span into another partition.

例如,分区1可以是标签Partition1.假设您的应用程序上下文在Partition1上运行:

For example, partition 1 could be the label Partition1. Assuming your application context is operating on Partition1:

MERGE (user:User:Partition1 { name: 'Peter' })
RETURN user

假设您的应用程序上下文在Partition2上运行:

Assuming your application context is operating on Partition2:

MERGE (user:User:Partition2 { name: 'Peter' })
RETURN user

执行这两个查询时,将为Partition1Partition2创建两个单独的Peters.

When executing these two queries, two separate Peters are created for Partition1 and Partition2.

您只需要确保应用程序正在操作的分区标签将其标签附加到每个查询中即可.尽管这很繁琐,但这是此时建议进行多租户的建议方法.

You'll just need to ensure that the partition label your application is operating on appends its label to each one of your queries. While this is tedious, it is the suggested way to go about multitenancy at this time.

这篇关于如何对单个Neo4j数据库进行分区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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