cognee/cognee/tests
hajdul88 508165e883
feature: Introduces wide subgraph search in graph completion and improves QA speed (#1736)
<!-- .github/pull_request_template.md -->

This PR introduces wide vector and graph structure filtering
capabilities. With these changes, the graph completion retriever and all
retrievers that inherit from it will now filter relevant vector elements
and subgraphs based on the query. This improvement significantly
increases search speed for large graphs while maintaining—and in some
cases slightly improving—accuracy.

Changes in This PR:

-Introduced new wide_search_top_k parameter: Controls the initial search
space size

-Added graph adapter level filtering method: Enables relevant subgraph
filtering while maintaining backward compatibility. For community or
custom graph adapters that don't implement this method, the system
gracefully falls back to the original search behavior.

-Updated modal dashboard and evaluation framework: Fixed compatibility
issues.
Added comprehensive unit tests: Introduced unit tests for
brute_force_triplet_search (previously untested) and expanded the
CogneeGraph test suite.

Integration tests: Existing integration tests verify end-to-end search
functionality (no changes required).

Acceptance Criteria and Testing

To verify the new search behavior, run search queries with different
wide_search_top_k parameters while logging is enabled:
None: Triggers a full graph search (default behavior)
1: Projects a minimal subgraph (demonstrates maximum filtering)
Custom values: Test intermediate levels of filtering

Internal Testing and results:
Performance and accuracy benchmarks are available upon request. The
implementation demonstrates measurable improvements in query latency for
large graphs without sacrificing result quality.

## Type of Change
<!-- Please check the relevant option -->
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [x] Code refactoring
- [x] Performance improvement
- [ ] Other (please specify):

## Screenshots/Videos (if applicable)
None

## Pre-submission Checklist
<!-- Please check all boxes that apply before submitting your PR -->
- [x] **I have tested my changes thoroughly before submitting this PR**
- [x] **This PR contains minimal changes necessary to address the
issue/feature**
- [x] My code follows the project's coding standards and style
guidelines
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added necessary documentation (if applicable)
- [x] All new and existing tests pass
- [x] I have searched existing PRs to ensure this change hasn't been
submitted already
- [x] I have linked any relevant issues in the description
- [x] My commits have clear and descriptive messages

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.

---------

Co-authored-by: Pavel Zorin <pazonec@yandex.ru>
2025-11-26 15:18:53 +01:00
..
cli_tests Remove all references to SearchType.INSIGHTS across the codebase, meaningfully replacing it with SearchType.GRAPH_COMPLETION where applicable. 2025-10-08 12:13:59 +01:00
integration feat: csv ingestion & chunking (#1574) 2025-11-22 14:48:27 -08:00
subprocesses feat: Redis lock integration and Kuzu agentic access fix (#1504) 2025-10-16 15:48:20 +02:00
tasks fix: Resolve issue with entity extraction test 2025-11-04 16:43:41 +01:00
test_data feat: csv ingestion loader & chunk 2025-10-22 16:56:46 +08:00
unit feature: Introduces wide subgraph search in graph completion and improves QA speed (#1736) 2025-11-26 15:18:53 +01:00
__init__.py
test_add_docling_document.py fix: Resolve docling test 2025-10-31 13:57:12 +01:00
test_advanced_pdf_loader.py make advanced pdf loader optional 2025-09-22 15:07:58 +08:00
test_chromadb.py COG-3050 - remove insights search (#1506) 2025-10-11 09:09:56 +02:00
test_cognee_server_start.py fix: add auth headers to ontology upload request and enhance ontology content 2025-11-20 15:36:15 +05:00
test_concurrent_subprocess_access.py feat: Redis lock integration and Kuzu agentic access fix (#1504) 2025-10-16 15:48:20 +02:00
test_conversation_history.py Fix: fixes session history test for multiuser mode (#1746) 2025-11-06 14:13:55 +01:00
test_custom_model.py
test_deduplication.py test: Rollback deduplication test 2025-10-01 18:10:57 +02:00
test_delete_by_id.py
test_delete_hard.py refactor: Speed up CI/CD execution time 2025-08-26 21:28:11 +02:00
test_delete_soft.py refactor: Speed up CI/CD execution time 2025-08-26 21:28:11 +02:00
test_edge_ingestion.py feat: optimize repeated entity extraction (#1682) 2025-10-30 13:56:06 +01:00
test_feedback_enrichment.py fix: Use same dataset name accross cognee calls 2025-10-30 17:40:00 +01:00
test_graph_visualization_permissions.py
test_kuzu.py Revert "Revert "fix: search without prior cognify"" 2025-10-22 13:21:51 +01:00
test_lancedb.py COG-3050 - remove insights search (#1506) 2025-10-11 09:09:56 +02:00
test_library.py refactor: fix search result for library test 2025-10-29 19:14:53 +01:00
test_load.py test: fix path based on pr comment 2025-11-03 17:06:51 +01:00
test_multi_tenancy.py feat: Add test for multi tenancy, add ability to share name for dataset across tenants for one user 2025-11-07 15:50:49 +01:00
test_neo4j.py Revert "Revert "fix: search without prior cognify"" 2025-10-22 13:21:51 +01:00
test_neptune_analytics_graph.py
test_neptune_analytics_hybrid.py
test_neptune_analytics_vector.py COG-3050 - remove insights search (#1506) 2025-10-11 09:09:56 +02:00
test_parallel_databases.py feat: enable multi user for falkor (#1689) 2025-11-11 17:03:48 +01:00
test_permissions.py test: Removed long text string about qunatum computers from tests. Used a file instead. 2025-10-01 17:59:53 +02:00
test_pgvector.py COG-3050 - remove insights search (#1506) 2025-10-11 09:09:56 +02:00
test_relational_db_migration.py Relational DB migration test search (#1752) 2025-11-12 21:32:22 +01:00
test_remote_kuzu.py COG-3050 - remove insights search (#1506) 2025-10-11 09:09:56 +02:00
test_remote_kuzu_stress.py
test_s3.py
test_s3_file_storage.py Deprecate SearchType.INSIGHTS, replace all references to default search type - SearchType.GRAPH_COMPLETION 2025-10-08 12:13:59 +01:00
test_search_db.py refactor: Rename access control functions 2025-11-04 12:06:16 +01:00
test_starter_pipelines.py
test_telemetry.py
test_temporal_graph.py Merge dev into main (#1422) 2025-09-17 10:32:10 +02:00