Skip to Content
ReferenceSearch Types

Search Types Reference

Cognee provides a variety of search types to query your knowledge graph in different ways. This reference guide explains each search type, its purpose, and how to use it effectively.

Available Search Types

Cognee offers the following search types through the SearchType enum:

from cognee.modules.search.types import SearchType # Available search types SearchType.SUMMARIES SearchType.INSIGHTS SearchType.CHUNKS SearchType.INFORMATION # Alias for CHUNKS in some contexts SearchType.COMPLETION SearchType.GRAPH_COMPLETION SearchType.GRAPH_SUMMARY_COMPLETION SearchType.CODE SearchType.RAG # Alias for COMPLETION in some contexts

Basic Search Syntax

All search types use the same basic function call pattern:

import cognee from cognee.modules.search.types import SearchType results = await cognee.search( query_text="Your search query", query_type=SearchType.INSIGHTS, # Replace with your desired search type )

Detailed Search Type Descriptions

SUMMARIES

The SUMMARIES search type retrieves summarized information from your knowledge graph.

results = await cognee.search( query_text="Summarize what is known about quantum computing", query_type=SearchType.SUMMARIES )

Best for:

  • Getting concise overviews of topics
  • Summarizing large amounts of information
  • Quick understanding of complex subjects

INSIGHTS

The INSIGHTS search type discovers connections and relationships between entities in your knowledge graph.

results = await cognee.search( query_text="What is the relationship between Einstein and Germany?", query_type=SearchType.INSIGHTS )

Best for:

  • Discovering how entities are connected
  • Understanding relationships between concepts
  • Exploring the structure of your knowledge graph

CHUNKS / INFORMATION

The CHUNKS search type (also available as INFORMATION in some contexts) retrieves specific facts and information chunks from your knowledge graph.

results = await cognee.search( query_text="When was Einstein born?", query_type=SearchType.CHUNKS # or SearchType.INFORMATION )

Best for:

  • Finding specific facts
  • Getting direct answers to questions
  • Retrieving precise information

COMPLETION / RAG

The COMPLETION search type (also available as RAG in some contexts) uses retrieval-augmented generation to provide comprehensive answers based on your knowledge graph.

results = await cognee.search( query_text="Explain Einstein's contributions to physics", query_type=SearchType.COMPLETION # or SearchType.RAG )

Best for:

  • Getting detailed explanations
  • Combining multiple pieces of information
  • Generating comprehensive answers

GRAPH_COMPLETION

The GRAPH_COMPLETION search type leverages the graph structure to provide more contextually aware completions.

results = await cognee.search( query_text="How do quantum computers differ from classical computers?", query_type=SearchType.GRAPH_COMPLETION )

Best for:

  • Complex queries requiring graph traversal
  • Questions that benefit from understanding relationships
  • Queries where context from connected entities matters

GRAPH_SUMMARY_COMPLETION

The GRAPH_SUMMARY_COMPLETION search type combines graph traversal with summarization to provide concise but comprehensive answers.

results = await cognee.search( query_text="Summarize the key developments in AI from 2010 to 2023", query_type=SearchType.GRAPH_SUMMARY_COMPLETION )

Best for:

  • Getting summarized information that requires understanding relationships
  • Complex topics that need concise explanations
  • Queries that benefit from both graph structure and summarization

CODE

The CODE search type is specialized for retrieving and understanding code-related information from your knowledge graph.

results = await cognee.search( query_text="How to implement a binary search tree in Python", query_type=SearchType.CODE )

Best for:

  • Code-related queries
  • Programming examples and patterns
  • Technical documentation searches

Advanced Usage

Combining Search Types

For complex queries, you might want to use multiple search types in sequence:

# First get insights about relationships insights = await cognee.search( query_text="Relationship between quantum computing and cryptography", query_type=SearchType.INSIGHTS ) # Then get a detailed explanation explanation = await cognee.search( query_text=f"Explain how quantum computing affects cryptography, considering: {insights}", query_type=SearchType.GRAPH_COMPLETION )

Search with Filters

You can filter search results by node type or other properties:

# Search only for people and organizations results = await cognee.search( query_text="Who founded Microsoft?", query_type=SearchType.INSIGHTS, node_types=["Person", "Organization"] )

Choosing the Right Search Type

Here’s a quick guide to help you choose the most appropriate search type:

If you want to…Use this search type
Get a quick summarySUMMARIES
Discover relationshipsINSIGHTS
Find specific factsCHUNKS / INFORMATION
Get detailed explanationsCOMPLETION / RAG
Understand complex relationshipsGRAPH_COMPLETION
Get concise answers about complex topicsGRAPH_SUMMARY_COMPLETION
Find code examples or technical informationCODE

Examples

Example 1: Research Paper Analysis

# Add research papers to your knowledge graph await cognee.add("file:///path/to/research_paper1.pdf") await cognee.add("file:///path/to/research_paper2.pdf") # Process the content await cognee.cognify() # Get a summary of the key findings summaries = await cognee.search( query_text="Summarize the key findings from these research papers", query_type=SearchType.SUMMARIES ) # Discover relationships between concepts insights = await cognee.search( query_text="What is the relationship between the methodologies used in these papers?", query_type=SearchType.INSIGHTS ) # Get a comprehensive analysis analysis = await cognee.search( query_text="Provide a comprehensive analysis of how these papers contribute to the field", query_type=SearchType.GRAPH_COMPLETION )

Example 2: Code Documentation

# Add code documentation to your knowledge graph await cognee.add("file:///path/to/codebase") # Process the content await cognee.cognify() # Find specific code examples code_examples = await cognee.search( query_text="How to implement authentication in this codebase", query_type=SearchType.CODE ) # Understand the architecture architecture = await cognee.search( query_text="Explain the overall architecture of this codebase", query_type=SearchType.GRAPH_SUMMARY_COMPLETION )

Troubleshooting

If you’re not getting the expected search results:

  1. No results: Make sure you’ve added relevant content and run cognee.cognify()
  2. Irrelevant results: Try refining your query or using a different search type
  3. Missing connections: Your knowledge graph might not have captured the relationships you’re looking for; try adding more relevant content

Next Steps