Skip to main content
The query API provides multiple search methods to query your indexed knowledge graph. Each search method has both a standard and streaming variant.

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
Perform a global search across the entire knowledge graph.

Parameters

config
GraphRagConfig
required
GraphRAG configuration object loaded from settings.yaml or constructed programmatically.
entities
pd.DataFrame
required
DataFrame containing the final entities from entities.parquet.
communities
pd.DataFrame
required
DataFrame containing the final communities from communities.parquet.
community_reports
pd.DataFrame
required
DataFrame containing the final community reports from community_reports.parquet.
community_level
int | None
required
The community level to search at. Higher levels provide broader context, lower levels provide more detail. Use None to search all levels.
dynamic_community_selection
bool
required
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.
response_type
str
required
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
query
str
required
The user query to search for.
callbacks
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events and context data.
verbose
bool
default:"False"
Enable verbose logging output.

Returns

response
str | dict | list[dict]
The generated response to the query. Format depends on the response_type.
context
str | list[pd.DataFrame] | dict[str, pd.DataFrame]
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.
Parameters are identical to global_search. Returns an AsyncGenerator that yields response chunks as strings. Perform a local search focused on specific entities and their context.

Parameters

config
GraphRagConfig
required
GraphRAG configuration object.
entities
pd.DataFrame
required
DataFrame containing the final entities from entities.parquet.
communities
pd.DataFrame
required
DataFrame containing the final communities from communities.parquet.
community_reports
pd.DataFrame
required
DataFrame containing the final community reports from community_reports.parquet.
text_units
pd.DataFrame
required
DataFrame containing the final text units from text_units.parquet.
relationships
pd.DataFrame
required
DataFrame containing the final relationships from relationships.parquet.
covariates
pd.DataFrame | None
required
DataFrame containing the final covariates from covariates.parquet, or None if covariates are not used.
community_level
int
required
The community level to search at.
response_type
str
required
The type of response to generate.
query
str
required
The user query to search for.
callbacks
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events.
verbose
bool
default:"False"
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.
Perform a DRIFT (Dynamic Reasoning with Iterative Feedback and Traversal) search.

Parameters

config
GraphRagConfig
required
GraphRAG configuration object.
entities
pd.DataFrame
required
DataFrame containing the final entities from entities.parquet.
communities
pd.DataFrame
required
DataFrame containing the final communities from communities.parquet.
community_reports
pd.DataFrame
required
DataFrame containing the final community reports from community_reports.parquet.
text_units
pd.DataFrame
required
DataFrame containing the final text units from text_units.parquet.
relationships
pd.DataFrame
required
DataFrame containing the final relationships from relationships.parquet.
community_level
int
required
The community level to search at.
response_type
str
required
The type of response to generate.
query
str
required
The user query to search for.
callbacks
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events.
verbose
bool
default:"False"
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.
Perform a basic vector similarity search over text units.

Parameters

config
GraphRagConfig
required
GraphRAG configuration object.
text_units
pd.DataFrame
required
DataFrame containing the final text units from text_units.parquet.
response_type
str
required
The type of response to generate.
query
str
required
The user query to search for.
callbacks
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events.
verbose
bool
default:"False"
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