Cortex automatically detects communities - clusters of related documents and entities that share common themes. This enables topic discovery, document organization, and focused Q&A.
What Are Communities?
Communities are groups of entities (and their associated documents) that are densely connected in the knowledge graph. They represent natural topic clusters within your knowledge base.
Detection Algorithm
Cortex uses Leiden (preferred) or Louvain algorithm for community detection, with a BFS fallback when GDS is unavailable:
Key improvements in the detection pipeline:
- Old community cleanup before re-detection prevents stale data accumulation
- Undirected projection treats all relationships as bidirectional for community membership
- Relationship weights (0-10 scale) influence community membership — strongly weighted relationships pull entities together
- Co-mention edges connect entities that appear in the same chunk, providing structure even when direct entity-to-entity relationships are sparse
- Distribution monitoring logs warnings for pathological distributions (e.g., one mega-community containing >50% of entities)
API Usage
Detect Communities
Start community detection (runs as a background task):
Code
Response:
Code
Track Detection Progress
Code
Code
List Communities
Code
Code
Get Community Details
Community IDs are integers. The detail endpoint returns the community's summary, member entities, and key relationships (filtered to the API key's allowed collections):
Code
Code
Community Members
The detail endpoint above returns the community's member entities (and their key
relationships). There is no per-community documents listing — browse documents
per collection instead, e.g. GET /api/documents?collection_id=<collection_id>.
Summarize Communities
Generate or regenerate AI summaries for communities (batch endpoint; requires manage permission):
Code
Omit community_ids to summarize all communities; omit force_regenerate (or
set it false) to skip communities that already have a summary.
Code
Community-Based Queries
Communities are not a scoping parameter on the search or ask endpoints:
POST /api/searchaccepts no community filter —SearchRequestscopes bycollection_idonly. A community field in the body is ignored: it adds no community restriction, and the search remains scoped exactly as it would be without it — the suppliedcollection_id, or the API key's collection scope when nocollection_idis supplied.collection_idon/api/searchand/api/askselects a Collection (Collection.id) only. A community identifier such ascomm_1matches no collection, and community IDs are integers — passing one as a string collection scope finds nothing, while a numeric value fails the string field with 422.
Use the supported paths below.
Search Community Summaries
Search communities by their summary content (results are filtered to the API key's allowed collections):
Code
Code
Ask with Community Context
There is no community-scoped ask. On agentic (deep research) queries, the
researcher agent can retrieve relevant community summaries into the answer
context with its community_search tool, scoped to the request's
collection_id (or the API key's allowed collections) — tool use is
model-chosen per run, not a guaranteed inclusion. To focus an ask, scope it to
a real collection ID:
Code
(legacy equivalent: "use_agentic": true in place of depth).
To read one community's summary and members directly, use
GET /api/graph/communities/{community_id} with the community's integer ID.
Regenerating Communities
Communities are not automatically updated when documents are added. To update:
Code
Configuration
Code
Use Cases
- Topic Discovery - Find natural topic clusters in your documents
- Content Organization - Use communities to organize collections
- Focused Q&A - Ask questions about specific topic areas
- Knowledge Mapping - Visualize how topics relate
- Onboarding - Help new users understand the knowledge base