Overview
The Search API performs semantic search across all your indexed content in Khoj. It uses embeddings to find relevant information based on meaning, not just keyword matching.Search Content
Search for content across your knowledge base.cURL
Python
JavaScript
Request
Search query string
Number of results to return (1-100)
Content type to search. Options:
all- Search all content typesorg- Org-mode filesmarkdown- Markdown filespdf- PDF documentsplaintext- Plain text filesimage- Imagesdocx- Word documentsgithub- GitHub repositoriesnotion- Notion pages
Whether to rerank results using cross-encoder for improved relevance
Maximum semantic distance for results (0.0-1.0). Lower values return more similar results.
Whether to deduplicate similar results
Client identifier for telemetry (e.g., “web”, “obsidian”, “emacs”)
Response
Returns an array of search results ordered by relevance.The content snippet or entry text
Relevance score (lower is more relevant)
Additional metadata about the result
Example Response
Search Types
Khoj supports searching across different content types:All Content
Search across all indexed content:Markdown Files
Search only markdown documents:PDF Documents
Search only PDF files:GitHub Repositories
Search across indexed GitHub repos:Notion Pages
Search Notion content:Advanced Search Options
Reranking for Better Results
Enable reranking to improve result quality using a cross-encoder model:Filtering by Distance
Limit results to those within a semantic distance threshold:0.0 - 0.3: Very similar content0.3 - 0.5: Moderately similar0.5 - 0.7: Somewhat related> 0.7: Less related
Disable Deduplication
Get all matching results including similar duplicates:Use Cases
Personal Knowledge Base
Search your personal notes and documents:Research Assistant
Find relevant passages in research papers:Code Search
Search through your GitHub repositories:Meeting Notes
Find information from past meetings:Error Handling
401 Unauthorized
400 Bad Request
t parameter) is one of the supported values.
500 Internal Server Error
Best Practices
Use Specific Queries
More specific queries return more relevant results. Instead of “python”, try “python async await patterns”.
Choose Right Content Type
Filter by content type when you know where information should be (e.g., code in GitHub, docs in Markdown).
Enable Reranking Selectively
Use reranking for important queries where accuracy matters more than speed.
Adjust Result Count
Start with 5-10 results. Increase if needed, but more results means more data to process.
Rate Limits
- Free tier: 50 searches per day
- Premium tier: Unlimited searches
Next Steps
Update Content
Learn how to index new content for search
