algolia-migration-deep-dive
Migrate to Algolia from Elasticsearch, Typesense, or Meilisearch. Covers data migration, query translation, replaceAllObjects zero-downtime swap, and strangler fig traffic shifting. Trigger: "migrate to algolia", "switch to algolia", "algolia migration", "elasticsearch to algolia", "replace search engine", "algolia replatform".
What this skill does
# Algolia Migration Deep Dive
## Overview
Comprehensive guide for migrating from another search engine (Elasticsearch, Typesense, Meilisearch, or custom) to Algolia. Uses the strangler fig pattern: run old and new in parallel, gradually shift traffic, then cut over.
## Migration Planning
| From | Difficulty | Notes | Duration |
|------|-----------|-------|----------|
| Elasticsearch | Medium | query syntax differs significantly | 2-4 weeks |
| Typesense | Low | similar hosted model | 1-2 weeks |
| Meilisearch | Low | similar API concepts | 1-2 weeks |
| Custom SQL LIKE | Low | major upgrade | 1-2 weeks |
| Solr | Medium | config-heavy to API-driven | 2-4 weeks |
## Instructions
### Step 1: Assess Current Implementation
```bash
# Find all search-related code
grep -rn "elasticsearch\|elastic\|typesense\|meilisearch\|\.search(" \
--include="*.ts" --include="*.tsx" --include="*.js" src/ | wc -l
# Inventory current search features used
grep -rn "aggregations\|facets\|filters\|sort\|highlight\|suggest" \
--include="*.ts" --include="*.tsx" src/
```
```typescript
// Document current capabilities
interface MigrationAssessment {
currentEngine: string;
recordCount: number;
indexCount: number;
features: {
fullTextSearch: boolean;
faceting: boolean;
filtering: boolean;
geoSearch: boolean;
synonyms: boolean;
customRanking: boolean;
analytics: boolean;
abTesting: boolean;
recommendations: boolean;
};
integrationPoints: string[]; // Files that call the search engine
queryPatterns: string[]; // Types of queries used
}
```
### Step 2: Create the Adapter Layer
```typescript
// src/search/adapter.ts
// Abstraction layer — both engines implement the same interface
interface SearchResult<T> {
hits: T[];
totalHits: number;
totalPages: number;
currentPage: number;
facets?: Record<string, Record<string, number>>;
processingTimeMs: number;
}
interface SearchAdapter {
search<T>(params: {
index: string;
query: string;
filters?: string;
facets?: string[];
page?: number;
hitsPerPage?: number;
}): Promise<SearchResult<T>>;
index(params: { index: string; records: Record<string, any>[] }): Promise<void>;
delete(params: { index: string; ids: string[] }): Promise<void>;
}
```
### Step 3: Implement the Algolia Adapter
```typescript
// src/search/algolia-adapter.ts
import { algoliasearch, ApiError } from 'algoliasearch';
export class AlgoliaAdapter implements SearchAdapter {
private client;
constructor(appId: string, apiKey: string) {
this.client = algoliasearch(appId, apiKey);
}
async search<T>(params: {
index: string;
query: string;
filters?: string;
facets?: string[];
page?: number;
hitsPerPage?: number;
}): Promise<SearchResult<T>> {
const result = await this.client.searchSingleIndex<T>({
indexName: params.index,
searchParams: {
query: params.query,
filters: params.filters,
facets: params.facets || ['*'],
page: params.page || 0,
hitsPerPage: params.hitsPerPage || 20,
},
});
return {
hits: result.hits,
totalHits: result.nbHits,
totalPages: result.nbPages,
currentPage: result.page,
facets: result.facets,
processingTimeMs: result.processingTimeMS,
};
}
async index(params: { index: string; records: Record<string, any>[] }) {
const { taskID } = await this.client.saveObjects({
indexName: params.index,
objects: params.records.map(r => ({
objectID: r.id || r.objectID,
...r,
})),
});
await this.client.waitForTask({ indexName: params.index, taskID });
}
async delete(params: { index: string; ids: string[] }) {
const { taskID } = await this.client.deleteObjects({
indexName: params.index,
objectIDs: params.ids,
});
await this.client.waitForTask({ indexName: params.index, taskID });
}
}
```
### Step 4: Query Translation Guide
```typescript
// Elasticsearch → Algolia query translation
// ES: { "query": { "match": { "title": "laptop" } } }
// Algolia:
await client.searchSingleIndex({ indexName: 'products', searchParams: { query: 'laptop' } });
// ES: { "query": { "bool": { "filter": [{ "term": { "category": "electronics" } }] } } }
// Algolia:
await client.searchSingleIndex({
indexName: 'products',
searchParams: { query: '', filters: 'category:electronics' },
});
// ES: { "query": { "range": { "price": { "gte": 50, "lte": 200 } } } }
// Algolia:
await client.searchSingleIndex({
indexName: 'products',
searchParams: { query: '', numericFilters: ['price >= 50', 'price <= 200'] },
});
// ES: { "aggs": { "categories": { "terms": { "field": "category" } } } }
// Algolia:
await client.searchSingleIndex({
indexName: 'products',
searchParams: { query: '', facets: ['category'] },
});
// facets in response: { category: { electronics: 42, clothing: 18 } }
// ES: { "sort": [{ "price": "asc" }] }
// Algolia: Use a replica index with price sort ranking
await client.searchSingleIndex({ indexName: 'products_price_asc', searchParams: { query: '' } });
// ES: { "highlight": { "fields": { "title": {} } } }
// Algolia: Built-in, use _highlightResult in response
```
### Step 5: Data Migration
```typescript
// Full data migration with transform
async function migrateData(sourceAdapter: SearchAdapter, targetIndex: string) {
const client = algoliasearch(process.env.ALGOLIA_APP_ID!, process.env.ALGOLIA_ADMIN_KEY!);
// Use replaceAllObjects for atomic zero-downtime swap
// Internally: creates temp index → indexes all records → moves temp → deletes old
console.log(`Starting migration to ${targetIndex}...`);
const allRecords: Record<string, any>[] = [];
let page = 0;
let hasMore = true;
// Export from source
while (hasMore) {
const result = await sourceAdapter.search({
index: 'products',
query: '',
page,
hitsPerPage: 1000,
});
allRecords.push(...result.hits.map(transformRecord));
hasMore = page < result.totalPages - 1;
page++;
console.log(`Exported ${allRecords.length} records...`);
}
// Import to Algolia atomically
const { taskID } = await client.replaceAllObjects({
indexName: targetIndex,
objects: allRecords,
batchSize: 1000,
});
await client.waitForTask({ indexName: targetIndex, taskID });
console.log(`Migration complete: ${allRecords.length} records in ${targetIndex}`);
}
function transformRecord(record: any): Record<string, any> {
return {
objectID: record.id || record._id,
...record,
// Remove Elasticsearch-specific fields
_id: undefined,
_source: undefined,
_score: undefined,
};
}
```
### Step 6: Traffic Shifting (Strangler Fig)
```typescript
// Gradually shift traffic from old engine to Algolia
function getSearchAdapter(): SearchAdapter {
const algoliaPercent = parseInt(process.env.ALGOLIA_TRAFFIC_PERCENT || '0');
if (Math.random() * 100 < algoliaPercent) {
return new AlgoliaAdapter(process.env.ALGOLIA_APP_ID!, process.env.ALGOLIA_ADMIN_KEY!);
}
return new ElasticsearchAdapter(process.env.ES_URL!);
}
// Deployment steps:
// Week 1: ALGOLIA_TRAFFIC_PERCENT=10 (canary)
// Week 2: ALGOLIA_TRAFFIC_PERCENT=50 (half traffic)
// Week 3: ALGOLIA_TRAFFIC_PERCENT=100 (full cutover)
// Week 4: Remove old adapter code
```
### Step 7: Validation
```typescript
// Compare results between old and new engines
async function validateMigration(queries: string[]) {
const old = new ElasticsearchAdapter(process.env.ES_URL!);
const algolia = new AlgoliaAdapter(process.env.ALGOLIA_APP_ID!, process.env.ALGOLIA_ADMIN_KEY!);
for (const query of queries) {
const oldResult = await old.search({ index: 'products', query });
const algoliaResult = await algolia.search({ index: 'products', query });
const oldIds = new Set(oldResult.hits.map((h: any) => h.objectID || h.id));
const algoliaIds = new Set(algoliaResuRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.