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

GraphRagConfig
required
GraphRAG configuration object loaded from settings.yaml or constructed programmatically.
pd.DataFrame
required
DataFrame containing the final entities from entities.parquet.
pd.DataFrame
required
DataFrame containing the final communities from communities.parquet.
pd.DataFrame
required
DataFrame containing the final community reports from community_reports.parquet.
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.
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.
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
str
required
The user query to search for.
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events and context data.
bool
default:"False"
Enable verbose logging output.

Returns

str | dict | list[dict]
The generated response to the query. Format depends on the response_type.
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

GraphRagConfig
required
GraphRAG configuration object.
pd.DataFrame
required
DataFrame containing the final entities from entities.parquet.
pd.DataFrame
required
DataFrame containing the final communities from communities.parquet.
pd.DataFrame
required
DataFrame containing the final community reports from community_reports.parquet.
pd.DataFrame
required
DataFrame containing the final text units from text_units.parquet.
pd.DataFrame
required
DataFrame containing the final relationships from relationships.parquet.
pd.DataFrame | None
required
DataFrame containing the final covariates from covariates.parquet, or None if covariates are not used.
int
required
The community level to search at.
str
required
The type of response to generate.
str
required
The user query to search for.
list[QueryCallbacks] | None
default:"None"
List of callback objects to receive query events.
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

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

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