Search methods
GraphRAG provides four search methods:- Global search - Query the entire knowledge graph using hierarchical community summaries
- Local search - Query specific entities and their local context
- DRIFT search - Dynamic reasoning with iterative feedback and traversal
- Basic search - Simple vector similarity search over text units
Global search
Perform a global search across the entire knowledge graph.Parameters
GraphRAG configuration object loaded from settings.yaml or constructed programmatically.
DataFrame containing the final entities from
entities.parquet.DataFrame containing the final communities from
communities.parquet.DataFrame containing the final community reports from
community_reports.parquet.The community level to search at. Higher levels provide broader context, lower levels provide more detail. Use
None to search all levels.Enable dynamic community selection instead of using all community reports at a fixed level. When
True, the search engine intelligently selects relevant communities. You can still provide community_level to cap the maximum level.The type of response to generate. Common options:
"multiple paragraphs"- Detailed multi-paragraph response"single paragraph"- Concise single paragraph"single sentence"- Brief single sentence"list of 3-7 items"- Bullet point list"multi-page report"- Comprehensive report
The user query to search for.
List of callback objects to receive query events and context data.
Enable verbose logging output.
Returns
The generated response to the query. Format depends on the response_type.
The context data used to generate the response, including relevant community reports and entities.
Global search streaming
Stream the global search response as it’s generated.global_search. Returns an AsyncGenerator that yields response chunks as strings.
Local search
Perform a local search focused on specific entities and their context.Parameters
GraphRAG configuration object.
DataFrame containing the final entities from
entities.parquet.DataFrame containing the final communities from
communities.parquet.DataFrame containing the final community reports from
community_reports.parquet.DataFrame containing the final text units from
text_units.parquet.DataFrame containing the final relationships from
relationships.parquet.DataFrame containing the final covariates from
covariates.parquet, or None if covariates are not used.The community level to search at.
The type of response to generate.
The user query to search for.
List of callback objects to receive query events.
Enable verbose logging output.
Returns
Returns a tuple of(response, context) similar to global search.
Local search streaming
Stream the local search response as it’s generated.DRIFT search
Perform a DRIFT (Dynamic Reasoning with Iterative Feedback and Traversal) search.Parameters
GraphRAG configuration object.
DataFrame containing the final entities from
entities.parquet.DataFrame containing the final communities from
communities.parquet.DataFrame containing the final community reports from
community_reports.parquet.DataFrame containing the final text units from
text_units.parquet.DataFrame containing the final relationships from
relationships.parquet.The community level to search at.
The type of response to generate.
The user query to search for.
List of callback objects to receive query events.
Enable verbose logging output.
Returns
Returns a tuple of(response, context) similar to other search methods.
DRIFT search streaming
Stream the DRIFT search response as it’s generated.Basic search
Perform a basic vector similarity search over text units.Parameters
GraphRAG configuration object.
DataFrame containing the final text units from
text_units.parquet.The type of response to generate.
The user query to search for.
List of callback objects to receive query events.
Enable verbose logging output.
Returns
Returns a tuple of(response, context) similar to other search methods.
Basic search streaming
Stream the basic search response as it’s generated.Complete example
Here’s a complete example showing how to load data and perform different types of searches:Streaming example
Related
- Index API - Build knowledge graph indexes
- Prompt tune API - Generate custom prompts
- Configuration - Configure search settings