elasticsearch-optimization
Query optimization, aggregations, relevance tuning for production search systems.
Works with
---
name: elasticsearch-optimization
description: Query optimization, aggregations, relevance tuning for production search systems.
license: Apache-2.0
---
# Elasticsearch Query Optimization
> Query optimization, aggregations, relevance tuning for production search systems.
## Core Concepts
### Query Types
Different query patterns for different use cases.
```typescript
// Filter (fast, no scoring)
const results = await es.search({
query: {
bool: {
filter: [
{ term: { status: 'published' } },
{ range: { date: { gte: '2024-01-01' } } }
]
}
}
});
// Full-text search (scored)
const results = await es.search({
query: {
multi_match: {
query: 'elasticsearch optimization',
fields: ['title^2', 'content']
}
}
});
```
### Aggregations
Analytics and faceted search.
```typescript
const results = await es.search({
aggs: {
by_status: {
terms: { field: 'status', size: 10 }
},
avg_price: {
avg: { field: 'price' }
}
}
});
```
### Relevance Tuning
BM25 algorithm and boosting.
```typescript
const results = await es.search({
query: {
bool: {
must: [
{ match: { title: { query: 'python', boost: 2 } } }
],
should: [
{ match: { tags: 'web' } }
]
}
}
});
```
## Best Practices
1. **Mapping Strategy**: Define proper field types
2. **Index Sharding**: Balance between shards
3. **Query Efficiency**: Use filters for exact matches
4. **Caching**: Enable query result caching
5. **Monitoring**: Track slow queries
## Related Skills
- Full-Text Search Engine
- Database Migration Strategies
- Caching Strategies & Hierarchies
---
**Token Savings**: ~850 tokens | **Last Updated**: 2025-11-08 | **Installs**: 756 | **Remixes**: 234More Database skills
azure-upgrade
microsoft/azure-skills
Assess and upgrade Azure workloads between plans, tiers, or SKUs, or modernize Azure SDK dependencies in source code. WHEN: upgrade Consumption to Flex Consumption, upgrade Azure Functions plan, change hosting plan, function app SKU, migrate App Service to Container Apps, modernize legacy Azure Java SDKs (com.microsoft.azure to com.azure), migrate Azure Cache for Redis (ACR/ACRE) to Azure Managed Redis (AMR).
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-database-setup
prisma/skills
Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".

