Status: This guide is in progress.This guide will walk you through building an extremely powerful workplace search and AI assistant platform that rivals Glean using Cortex APIs. You’ll learn how to create a unified search experience across multiple data sources with AI-powered Q&A capabilities.
Note: All code examples in this guide are for demonstration purposes. They show the concepts and patterns you can use when building your own Glean-like application with Cortex APIs. You’ll need to adapt these examples to your specific use case, technology stack, and requirements.
Overview
A Glean-like application typically includes these core features:- Universal Search: Search across multiple data sources (documents, emails, chats, etc.)
- AI-Powered Q&A: Get intelligent answers based on company knowledge
- AI Memories for User Preferences: Remember and adapt to individual user preferences, search patterns, and behavioral patterns
- Data Ingestion: Connect to various apps and services
- Knowledge Graph: Build connections between information
- Security & Access Control: Role-based permissions and data isolation
Architecture Overview
Step 1: Data Ingestion Strategy
1.1 App Connectors Setup
You’ll need to connect to various data sources. Here are recommended approaches:Option A: Using Composio
Composio provides pre-built connectors for popular apps:Option B: Vanilla API Integration
For custom integrations, use the native APIs:1.2 Data Normalization
Create a unified data format for all sources:Important: For optimal performance, limit each batch to a maximum of 20 app sources per request. Send multiple batch requests with an interval of 1 second between each request.
1.3 Batch Upload to Cortex
Use Cortex’s batch upload capabilities for efficient data ingestion:
Best Practice: Always verify processing after upload using the /upload/verify_processing
endpoint to ensure your data is properly indexed.
Step 2: Search and Q&A Implementation
2.1 Universal Search Interface
Create a search interface that queries across all data sources:Note: Cortex supports filtering bysource_title
andsource_type
using themetadata
parameter. Use these for targeted searches across specific data sources.
2.2 Advanced Search Features
Implement advanced search capabilities:Advanced Features:
multi_step_reasoning
: Automatically decomposes complex queries into stepsauto_agent_routing
: Routes queries to the best suitable AI agentsearch_alpha
: Controls semantic vs keyword matching (0.0-1.0)recency_bias
: Prioritizes recent content (0.0-1.0)
2.3 AI Memories and User Preferences
One of the most powerful features of building a Glean-like application with Cortex is leveraging AI Memories to create truly personalized experiences. Cortex automatically manages AI memories when you provide auser_name
and maintain consistent session_id
values. This allows your application to remember user preferences, past interactions, and behavioral patterns, making every search and interaction more relevant and efficient.
Understanding AI Memories
Cortex’s AI memories are dynamic, user-specific profiles that evolve over time. They capture not just what users say, but their intentions, preferences, and unique behaviors. Cortex automatically manages these memories when you provide auser_name
and maintain consistent session_id
values. This enables your Glean clone to:
- Remember User Preferences: Format preferences, source preferences, search patterns
- Understand Intent: Learn what types of information users typically seek
- Adapt Responses: Tailor answers based on past interactions
- Anticipate Needs: Suggest relevant information before users ask
Implementing AI Memories in Your Search
User Preference Learning
Memory-Enhanced Search Interface
Benefits of AI Memories in Your Glean Clone
- Personalized Search Results: Users get results tailored to their preferences and past behavior
- Faster Information Discovery: The system learns what sources and formats users prefer
- Improved User Experience: Every interaction feels more personal and relevant
- Reduced Cognitive Load: Users don’t need to repeat their preferences or search patterns
- Adaptive Learning: The system continuously improves based on user interactions
- Automatic Management: Cortex handles memory updates automatically - no manual implementation required
Best Practices for AI Memories
- Respect Privacy: Always give users control over their data and preferences
- Transparency: Show users what preferences are being used and allow them to modify them
- Graceful Degradation: Ensure the system works well even without user history
- Consistent Session IDs: Use persistent session IDs for users to maintain conversation context
- User Names: Provide consistent user names to enable Cortex’s automatic memory management
- Performance: Cache user profiles to avoid repeated API calls
Step 3: Frontend Implementation
3.1 Search Interface
3.2 Results Display
Step 4: Data Synchronization
4.1 Scheduled Sync Jobs
4.2 Webhook Integration
Step 5: Security and Access Control
5.1 Multi-Tenant Architecture
5.2 Data Privacy and Compliance
Step 6: Performance Optimization
6.1 Caching Strategy
6.2 Rate Limiting
Step 7: Monitoring and Analytics
7.1 Search Analytics
Best Practices and Recommendations
1. Data Ingestion Best Practices
- Batch Processing: Use Cortex’s batch upload endpoints for efficiency
- Batch Limits: Limit to 20 app sources per request with 1-second intervals between batches
- Incremental Sync: Only sync new/changed data to minimize API calls
- Error Handling: Implement retry logic with exponential backoff
- Processing Verification: Always verify upload processing using
/upload/verify_processing
- Rate Limiting: Respect API rate limits and implement queuing
2. Search Optimization
- Query Preprocessing: Clean and normalize user queries
- Result Ranking: Use
search_alpha
andrecency_bias
for fine-tuning - Metadata Filtering: Use
source_title
andsource_type
for targeted searches - Multi-Step Reasoning: Enable for complex queries that require multiple steps
- Auto Agent Routing: Let Cortex choose the best AI agent for each query
- Caching: Cache frequent queries and results
- Streaming: Use streaming for real-time search results
3. Security Considerations
- Data Encryption: Encrypt sensitive data at rest and in transit
- Access Control: Implement role-based access control (RBAC)
- Audit Logging: Log all search queries and data access
- Data Retention: Implement automatic data deletion policies
4. Performance Tips
- Connection Pooling: Reuse HTTP connections
- Async Processing: Use async/await for non-blocking operations
- Memory Management: Implement proper cleanup for large datasets
- Batch Optimization: Respect 20-source batch limits and 1-second intervals
- Processing Verification: Verify uploads to ensure data is properly indexed
- Monitoring: Track response times and error rates
5. User Experience
- Autocomplete: Implement search suggestions
- Faceted Search: Allow filtering by source type, date, author
- Saved Searches: Let users save and share search queries
- Export Results: Allow users to export search results
Deployment Checklist
- Set up authentication and authorization
- Configure data connectors and sync schedules
- Implement error handling and monitoring
- Set up caching and rate limiting
- Configure backup and disaster recovery
- Test with production data volumes
- Set up analytics and reporting
- Document API usage and troubleshooting