This page references the global_search.ipynb notebook from the GraphRAG repository.
When to use global search
Global search is best suited for:- High-level questions - “What are the main themes?”
- Dataset-wide insights - “What are the most significant trends?”
- Comparative analysis - “How do different communities relate?”
- Summarization tasks - “What is this dataset about?”
How global search works
Community report retrieval
Global search loads all community reports generated during indexing. These reports summarize clusters of related entities and relationships.
Map phase
Each community report is sent to the LLM with your question, generating intermediate answers from different parts of the knowledge graph.
Setting up the notebook
Import required libraries
Configure language models
Load community reports
The
COMMUNITY_LEVEL parameter controls granularity. Higher values use more detailed community reports but increase computational cost.Build global context
Configure search parameters
- Context builder
- Map LLM
- Reduce LLM
Create search engine
Perform search
Inspect context data
Analyze token usage
Example queries
Dataset-wide themes
Dataset-wide themes
Comparative analysis
Comparative analysis
Trend identification
Trend identification
Summary generation
Summary generation
Tuning parameters
Community level selection
- Level 0 (coarsest)
- Level 1-2 (balanced)
- Level 3+ (finest)
- Fewest communities
- Broadest summaries
- Lowest cost
- Best for very high-level questions
Response type options
Performance optimization
Parallel processing
Increase
concurrent_coroutines for faster map phaseToken management
Adjust
max_tokens based on your model limitsCommunity filtering
Set minimum rank to skip low-importance communities
Summary mode
Use summaries instead of full reports to reduce tokens
Comparison with local search
| Aspect | Global Search | Local Search |
|---|---|---|
| Question Type | High-level, broad | Specific, detailed |
| Data Source | Community reports | Entities + text chunks |
| Cost | Higher (map-reduce) | Lower (single query) |
| Response Time | Slower | Faster |
| Best For | Themes, trends, summaries | Entity details, relationships |
Next steps
Local search
Learn about local search for specific queries
DRIFT search
Explore hybrid search methods
Search comparison
Compare all search methods
Query guide
Complete global search documentation