J
Jerome Thayananthajothy
Guest
A case study in solving the "search problem" without forcing infrastructure migrations
Picture this: You're three months into building a SaaS application. Your users love it, but they keep asking for one thing; better search functionality. Your current MySQL
Sound familiar? This exact scenario has played out in every project I've worked on. The usual advice? "Just migrate to Elasticsearch." But that always felt like using a sledgehammer to crack a nut.
So I built Altus 4, an AI-enhanced MySQL full-text search engine that works with your existing database infrastructure.
Don't get me wrong; Elasticsearch is incredible. But for most applications, it introduces unnecessary complexity:
Most applications don't need the full power of Elasticsearch. They just need MySQL to be smarter about search.
The core insight behind Altus 4 is simple: What if we could make MySQL's existing full-text search intelligent without changing your data architecture?
Here's what that looks like in practice:
The difference? Altus 4 understands that "premium coffee products" should also match "high-quality espresso beans" or "artisan coffee roasters" thanks to AI-powered semantic understanding.
Altus 4 sits between your application and MySQL databases, enhancing search capabilities through several layers:
1. Database Service Layer
2. AI Enhancement Layer
3. Search Orchestration
Here's a simplified version of how the semantic enhancement works:
Let me show you a concrete example. I implemented Altus 4 for a client's e-commerce platform:
1. Setup (literally 5 minutes):
2. Connect existing database:
3. Start searching:
Want to try this out? Here's a complete walkthrough:
Edit
Altus 4 is perfect for:
Type safety was crucial for this project. With multiple database connections, AI integrations, and complex search logic, TypeScript caught countless potential runtime errors during development.
Familiarity and ecosystem. Most developers know Express, and the middleware ecosystem is unmatched for authentication, validation, and logging.
Dogfooding our own solution. Altus 4's own metadata (user accounts, API keys, database connections) is stored in MySQL and searchable through the same API.
Two main use cases:
Managing connections to multiple MySQL databases efficiently required custom pooling logic:
OpenAI has rate limits. For semantic search, we implemented intelligent batching:
Combining traditional full-text scores with semantic similarity scores required experimentation:
I'm actively developing Altus 4 with these priorities:
Altus 4 is completely open source (Apache 2.0 License). I built this to solve a real problem I kept encountering, and I'm excited to see how the community uses and improves it.
Building Altus 4 taught me that sometimes the best solution isn't the most obvious one. Instead of joining the "just use Elasticsearch" chorus, I asked: "What if we made MySQL smarter instead?"
The result is a tool that:
If you're struggling with search in your MySQL-based application, give Altus 4 a try. It might just be the "good enough" solution that's actually better than the complicated alternative.
Try Altus 4:
Tags: #mysql #opensourcedev #ai #searchengine #typescript #nodejs #elasticsearch
Continue reading...
The Problem That Started It All
Picture this: You're three months into building a SaaS application. Your users love it, but they keep asking for one thing; better search functionality. Your current MySQL
LIKE
queries are slow, inflexible, and frankly embarrassing when users type "find my recent premium orders" and get zero results.Sound familiar? This exact scenario has played out in every project I've worked on. The usual advice? "Just migrate to Elasticsearch." But that always felt like using a sledgehammer to crack a nut.
So I built Altus 4, an AI-enhanced MySQL full-text search engine that works with your existing database infrastructure.
Why Not Just Use Elasticsearch?
Don't get me wrong; Elasticsearch is incredible. But for most applications, it introduces unnecessary complexity:
The Elasticsearch Route:
- New infrastructure to provision, configure, and maintain
- Data synchronization nightmares between MySQL and ES
- Learning curve for your entire team
- Operational overhead of managing two data stores
- Additional costs for hosting and maintenance
The Reality Check:
Most applications don't need the full power of Elasticsearch. They just need MySQL to be smarter about search.
Enter Altus 4: Enhancing MySQL Instead of Replacing It
The core insight behind Altus 4 is simple: What if we could make MySQL's existing full-text search intelligent without changing your data architecture?
Here's what that looks like in practice:
Before (Traditional MySQL Search):
Code:
SELECT * FROM products
WHERE name LIKE '%premium coffee%'
OR description LIKE '%premium coffee%';
After (Altus 4 Enhanced):
Code:
curl -X POST http://localhost:3000/api/v1/search \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"query": "find premium coffee products",
"databases": ["ecommerce_db"],
"searchMode": "natural"
}'
The difference? Altus 4 understands that "premium coffee products" should also match "high-quality espresso beans" or "artisan coffee roasters" thanks to AI-powered semantic understanding.
Technical Architecture: How It Works
Altus 4 sits between your application and MySQL databases, enhancing search capabilities through several layers:
Core Components:
1. Database Service Layer
- Connects to multiple MySQL databases
- Discovers existing full-text indexes
- Manages connection pooling and optimization
2. AI Enhancement Layer
- OpenAI integration for semantic search
- Query optimization and natural language processing
- Relevance scoring improvements
3. Search Orchestration
- Federated search across multiple databases
- Result ranking and deduplication
- Real-time analytics and caching
The Magic: Semantic Search Implementation
Here's a simplified version of how the semantic enhancement works:
Code:
class SearchService {
async enhancedSearch(query: string, databases: string[]) {
// 1. Generate embeddings for the search query
const queryEmbedding = await this.aiService.generateEmbedding(query);
// 2. Execute traditional full-text search
const traditionalResults = await this.executeFullTextSearch(query, databases);
// 3. Enhance with semantic understanding
const semanticResults = await this.findSemanticMatches(queryEmbedding, databases);
// 4. Combine and rank results
return this.rankAndCombineResults(traditionalResults, semanticResults);
}
private async findSemanticMatches(embedding: number[], databases: string[]) {
// Find conceptually similar content even without exact keyword matches
return this.vectorSimilaritySearch(embedding, databases);
}
}
Real-World Use Case: E-commerce Search
Let me show you a concrete example. I implemented Altus 4 for a client's e-commerce platform:
The Challenge:
- 50,000+ products across multiple categories
- Users searching with natural language ("gifts for coffee lovers")
- Existing MySQL setup they didn't want to change
- Need for real-time inventory integration
The Implementation:
1. Setup (literally 5 minutes):
Code:
git clone https://github.com/altus4/core.git
cd altus4
npm install
cp .env.example .env
# Configure MySQL and OpenAI credentials
npm run migrate
npm run dev
2. Connect existing database:
Code:
curl -X POST http://localhost:3000/api/v1/databases \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"name": "E-commerce DB",
"host": "localhost",
"database": "ecommerce",
"username": "db_user",
"password": "password"
}'
3. Start searching:
Code:
// Natural language search
const results = await fetch('/api/v1/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: "gifts for coffee enthusiasts under $50",
databases: ["ecommerce_db"],
searchMode: "natural",
filters: {
price: { max: 50 }
}
})
}).then(r => r.json());
The Results:
- Search relevance improved by 60% (measured by click-through rates)
- Setup time: 30 minutes vs. weeks for Elasticsearch migration
- Zero downtime during implementation
- Maintenance overhead: minimal (just keeping Altus 4 updated)
Comparison: Altus 4 vs. Traditional Approaches
Feature | MySQL LIKE | Elasticsearch | Altus 4 |
---|---|---|---|
Setup Time | 5 minutes | 2-4 weeks | 30 minutes |
Infrastructure Changes | None | Significant | None |
Semantic Search | ![]() | ![]() | ![]() |
Natural Language | ![]() | ![]() | ![]() |
Operational Complexity | Low | High | Low |
Multi-Database Search | Manual | Complex | Built-in |
Cost (monthly) | $0 | $500-2000+ | $50-200 |
Getting Started: Your First Search in 10 Minutes
Want to try this out? Here's a complete walkthrough:
Prerequisites:
- Node.js 18+
- MySQL 8.0+
- Redis 6.0+
- OpenAI API key (optional for basic features)
Step 1: Installation
Code:
git clone https://github.com/altus4/core.git
cd altus4
npm install
Step 2: Environment Setup
Code:
cp .env.example .env
Edit
.env
with your credentials:
Code:
DB_HOST=localhost
DB_USERNAME=your_mysql_user
DB_PASSWORD=your_mysql_password
DB_DATABASE=altus4_metadata
REDIS_HOST=localhost
REDIS_PORT=6379
OPENAI_API_KEY=sk-your-openai-key
Step 3: Database Setup
Code:
# Run migrations to create Altus 4 metadata tables
npm run migrate
# Start the server
npm run dev
Step 4: Add Your First Database
Code:
curl -X POST http://localhost:3000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "secure_password",
"name": "Test User"
}'
# Follow the authentication flow to get your API key
# Then add your database connection
Step 5: Your First Search
Code:
const searchResponse = await fetch('/api/v1/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: "user accounts created last month",
databases: ["your_db_id"],
searchMode: "natural"
})
});
const results = await searchResponse.json();
console.log(results);
When Should You Use Altus 4?
Altus 4 is perfect for:
Great Fit:
- Existing MySQL applications needing better search
- Teams wanting to avoid Elasticsearch complexity
- SaaS applications with user-generated content
- E-commerce platforms with product catalogs
- Internal tools and admin dashboards
- Prototypes and MVPs needing professional search quickly
Consider Alternatives:
- Massive scale (millions of searches per second)
- Complex aggregation requirements beyond search
- Teams already invested in Elasticsearch ecosystem
- Applications requiring millisecond response times at scale
Technical Deep-Dive: Architecture Decisions
Why TypeScript?
Type safety was crucial for this project. With multiple database connections, AI integrations, and complex search logic, TypeScript caught countless potential runtime errors during development.
Why Express.js?
Familiarity and ecosystem. Most developers know Express, and the middleware ecosystem is unmatched for authentication, validation, and logging.
Why MySQL for Metadata?
Dogfooding our own solution. Altus 4's own metadata (user accounts, API keys, database connections) is stored in MySQL and searchable through the same API.
Why Redis?
Two main use cases:
- Caching search results for performance
- Storing search analytics and user behavior data
Challenges and Lessons Learned
Challenge 1: Connection Pool Management
Managing connections to multiple MySQL databases efficiently required custom pooling logic:
Code:
class DatabaseConnectionManager {
private pools = new Map<string, mysql.Pool>();
async getConnection(databaseId: string): Promise<mysql.PoolConnection> {
if (!this.pools.has(databaseId)) {
const config = await this.getDatabaseConfig(databaseId);
this.pools.set(databaseId, mysql.createPool(config));
}
return this.pools.get(databaseId)!.getConnection();
}
}
Challenge 2: AI Rate Limiting
OpenAI has rate limits. For semantic search, we implemented intelligent batching:
Code:
class AIService {
private requestQueue: QueryQueue = new QueryQueue();
async generateEmbedding(text: string): Promise<number[]> {
// Batch multiple requests and respect rate limits
return this.requestQueue.add(async () => {
return this.openai.createEmbedding({
model: "text-embedding-ada-002",
input: text
});
});
}
}
Challenge 3: Result Ranking
Combining traditional full-text scores with semantic similarity scores required experimentation:
Code:
private calculateCombinedScore(
fullTextScore: number,
semanticScore: number,
boost: number = 1.0
): number {
// Weighted combination with configurable boost
return (fullTextScore * 0.7 + semanticScore * 0.3) * boost;
}
What's Next: Roadmap
I'm actively developing Altus 4 with these priorities:
Short-term (Next 3 months):
- Vector database integration for better semantic search performance
- GraphQL API alongside REST
- Webhook support for real-time search index updates
- Advanced analytics dashboard
Long-term (6+ months):
- Auto-scaling capabilities for high-traffic applications
- Machine learning for personalized search ranking
- Multi-language support beyond English
- Plugin ecosystem for custom search behaviors
Open Source and Community
Altus 4 is completely open source (Apache 2.0 License). I built this to solve a real problem I kept encountering, and I'm excited to see how the community uses and improves it.
Contributing:
- GitHub: [Repository link]
- Issues: Bug reports and feature requests welcome
- Pull Requests: All skill levels welcome
- Documentation: Always needs improvement
Community:
- Discord: Join our developer community
- Examples: Real-world implementation examples
- Blog: Regular technical deep-dives
Conclusion: Solving Real Problems
Building Altus 4 taught me that sometimes the best solution isn't the most obvious one. Instead of joining the "just use Elasticsearch" chorus, I asked: "What if we made MySQL smarter instead?"
The result is a tool that:
- Solves the search problem for 80% of applications
- Respects existing architecture decisions
- Reduces operational complexity instead of adding to it
- Provides enterprise features without enterprise overhead
If you're struggling with search in your MySQL-based application, give Altus 4 a try. It might just be the "good enough" solution that's actually better than the complicated alternative.
Try Altus 4:
- Website: https://altus4.thavarshan.com
- GitHub: https://github.com/altus4/core
- Documentation: https://altus4.thavarshan.com/docs
Tags: #mysql #opensourcedev #ai #searchengine #typescript #nodejs #elasticsearch
Continue reading...