KQL Syntax
KQL (Knowledge Query Language) combines SQL and Cypher patterns for graph queries.
Basic Query Structure
MATCH pattern
[WHERE condition]
RETURN projection
[ORDER BY field [ASC|DESC]]
[LIMIT n]
[OFFSET m]
MATCH Patterns
Simple Node Queries
Find all files in the database:
KQL Query
Loading...
Press Ctrl+Enter to run
Find files with specific properties:
KQL Query
Loading...
Press Ctrl+Enter to run
Find all functions:
KQL Query
Loading...
Press Ctrl+Enter to run
Relationship Patterns
Find files and the functions they define:
KQL Query
Loading...
Press Ctrl+Enter to run
Find function call chains:
KQL Query
Loading...
Press Ctrl+Enter to run
WHERE Clauses
Numeric Comparisons
Find large files (> 5000 bytes):
KQL Query
Loading...
Press Ctrl+Enter to run
Find functions with many lines:
KQL Query
Loading...
Press Ctrl+Enter to run
String Matching
Find all public functions:
KQL Query
Loading...
Press Ctrl+Enter to run
Combined Conditions
Find large Rust files:
KQL Query
Loading...
Press Ctrl+Enter to run
RETURN Projections
Specific Properties
Return just file paths:
KQL Query
Loading...
Press Ctrl+Enter to run
Return multiple properties:
KQL Query
Loading...
Press Ctrl+Enter to run
With Relationships
KQL Query
Loading...
Press Ctrl+Enter to run
ORDER BY
Single Column
Order files by size:
KQL Query
Loading...
Press Ctrl+Enter to run
Multiple Columns
Order by language, then size:
KQL Query
Loading...
Press Ctrl+Enter to run
LIMIT and OFFSET
Pagination
Get first 5 files:
KQL Query
Loading...
Press Ctrl+Enter to run
Skip first 5, get next 5:
KQL Query
Loading...
Press Ctrl+Enter to run
Complex Queries
Finding Imports
Find files that import other files:
KQL Query
Loading...
Press Ctrl+Enter to run
Multi-hop Queries
Find files connected through functions:
KQL Query
Loading...
Press Ctrl+Enter to run
Try Your Own Queries!
Experiment with your own KQL queries using the mock dataset:
KQL Query
Loading...
Press Ctrl+Enter to run
Available Data
The playground includes mock data:
- Files: 15 files with properties:
id,path,size,language,lines - Functions: 18 functions with properties:
id,name,signature,visibility,lines - Relationships:
DEFINES: Files define functionsCALLS: Functions call other functionsIMPORTS: Files import other files
Next Steps
- MATCH Clause - Deep dive into pattern matching
- WHERE Clause - Advanced filtering
- RETURN Clause - Projections and aggregations