Graph Namespacing
Using group_ids to create isolated graph namespaces
Overview
Graphiti supports the concept of graph namespacing through the use of group_id parameters. Namespacing creates isolated graph environments within one Graphiti instance, enabling multiple distinct knowledge graphs to coexist without interference.
Your application must authorize each group_id and group_ids value before it
passes the value to Graphiti. Derive the value from authenticated application
state. Do not accept a namespace identifier from an untrusted request. A
namespace filter does not replace application authorization.
Graph namespacing is particularly useful for:
- Multi-tenant applications: Isolate data between different customers or organizations
- Testing environments: Maintain separate development, testing, and production graphs
- Domain-specific knowledge: Create specialized graphs for different domains or use cases
- Team collaboration: Allow different teams to work with their own graph spaces
How Namespacing Works
In Graphiti, every node and edge can be associated with a group_id. When you specify a group_id, you’re effectively creating a namespace for that data. Nodes and edges with the same group_id form a cohesive, isolated graph that can be queried and manipulated independently from other namespaces.
Key benefits
- Data partitioning: Assign related data to the same namespace.
- Search scoping: Limit a search to one or more namespaces.
- Simplified management: Organize and manage related data together.
- Flexible architecture: Support multiple use cases within one Graphiti instance.
Using group_ids in Graphiti
Adding Episodes with group_id
When adding episodes to your graph, you can specify a group_id to namespace the episode and all its extracted entities:
Adding Fact Triples with group_id
When manually adding fact triples, ensure both nodes and the edge share the same group_id:
Querying within a namespace
When you search the graph, specify group_ids to limit the results to one or
more namespaces:
Best Practices for Graph Namespacing
- Consistent naming: Use a consistent naming convention for your
group_idvalues - Documentation: Maintain documentation of your namespace structure and purpose
- Granularity: Choose an appropriate level of granularity for your namespaces
- Too many namespaces can lead to fragmented data
- Too few namespaces may not provide sufficient isolation
- Cross-namespace queries: Pass multiple namespace values in
group_ids.
Example: Multi-tenant Application
Here’s an example of using namespacing in a multi-tenant application: