agrag.retrieval.community_context.community_context
community_context(entity_ids:list[UUID], *, graph_store:GraphStore, top_k:int = 3, filters:SearchFilters | None = None, tracer:Tracer | None = None) -> list[SearchResult]
Return the top-overlapping communities' reports for a set of entities.
Ranks candidate communities by how many of entity_ids are their members (Microsoft GraphRAG's local-search pattern), then returns the top_k as SearchResults so they flow through the same Fusion/Ledger machinery as any other result.
Parameters:
- entity_ids (
list[UUID]) – The entity ids already found by a search's other retrieval methods. - graph_store (
GraphStore) – Where the overlap lookup runs. - top_k (
int) – The maximum number of communities to return. Zero or negative returns no results without querying. - filters (
SearchFilters | None) – Applied to the candidate community node viadocument_ids/properties(to_cypher_where); labels are not applied, since they check node labels and a Community node never carries an entity label. Community nodes carry no document or tenant scope of their own, so a filter naming a property Community nodes never have matches no communities -- a document- or property-scoped search gets no community enrichment rather than one drawn from outside its scope. - tracer (
Tracer | None) – Opens the context span. None opens no recorded span.
Returns:
list[SearchResult]– Up to top_k SearchResults wrapping Community items, highest overlaplist[SearchResult]– first. Empty when entity_ids is empty or no community overlaps.