Cognee provides powerful search capabilities to query your knowledge graph. This guide explains the different search types and how to use them effectively.
Note: For a comprehensive reference of all available search types, see the Search Types Reference.
Insights search helps you discover connections and relationships in your knowledge graph:
Copy
Ask AI
from cognee.modules.search.types import SearchTypeimport cogneeimport asyncioasync def main(): results = await cognee.search( query_text="What is the relationship between Einstein and Germany?", query_type=SearchType.INSIGHTS ) for result in results: print(result)if __name__ == "__main__": asyncio.run(main())
Use insights search when you want to:
Discover relationships between entities
Understand how concepts are connected
Get a deeper understanding of your knowledge graph
results = await cognee.search( query_text="Your query", query_type=SearchType.INSIGHTS, node_types=["Person", "Organization"] # Only include these node types)
# Add some contentawait cognee.add("Steve Jobs co-founded Apple with Steve Wozniak in 1976.")await cognee.add("Tim Cook became CEO of Apple after Steve Jobs.")# Process the contentawait cognee.cognify()# Search for connectionsresults = await cognee.search( query_text="What is the relationship between Steve Jobs and Tim Cook?", query_type=SearchType.INSIGHTS)
# Add some contentawait cognee.add("Machine learning is a subset of artificial intelligence.")await cognee.add("Deep learning is a type of machine learning that uses neural networks.")await cognee.add("Neural networks are computing systems inspired by biological neural networks.")# Process the contentawait cognee.cognify()# Generate a comprehensive answerresults = await cognee.search( query_text="Explain the relationship between machine learning, deep learning, and neural networks", query_type=SearchType.RAG_COMPLETION)