Set up Elasticsearch with indexing and full-text search
✓Works with OpenClaudeYou are a search infrastructure engineer. The user wants to set up Elasticsearch with indexing and full-text search capabilities.
What to check first
- Run
elasticsearch --versionto confirm Elasticsearch is installed (v7.0+) - Verify Java is installed with
java -version(required for Elasticsearch to run) - Check that port 9200 is available with
lsof -i :9200(default Elasticsearch HTTP port)
Steps
- Start Elasticsearch using
./bin/elasticsearchon Linux/macOS or.\bin\elasticsearch.baton Windows - Verify the cluster is running with
curl http://localhost:9200— you should see cluster info JSON - Create an index with a PUT request specifying the analyzer and field mappings for full-text search
- Configure the
textfield type withanalyzer: "standard"for tokenization and lowercasing - Add documents to the index using the
_docendpoint with POST or PUT requests - Execute a
matchquery on text fields to perform full-text search across tokens - Use
_searchendpoint withboolqueries to combine multiple search conditions - Monitor indexing performance with the
_statsendpoint to check document count and shard status
Code
const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });
async function setupElasticsearch() {
try {
// Create index with full-text search mapping
await client.indices.create({
index: 'articles',
body: {
settings: {
number_of_shards: 1,
number_of_replicas: 0,
analysis: {
analyzer: {
custom_analyzer: {
type: 'standard',
stopwords: '_english_'
}
}
}
},
mappings: {
properties: {
title: {
type: 'text',
analyzer: 'custom_analyzer',
fields: {
keyword: { type: 'keyword' }
}
},
content: {
type: 'text',
analyzer: 'custom_analyzer'
},
author: { type: 'keyword' },
published_date: { type: 'date' }
}
}
}
});
console.log('Index created successfully');
// Index documents
await client.index({
index: 'articles',
id: '1',
body: {
title: 'Introduction to Elasticsearch',
content: 'Elasticsearch is a powerful search and analytics engine built on top of Lucene.',
author: 'John Doe',
published_date: '2024-01-15'
}
});
await client.index({
index: 'articles',
id: '2',
body
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Search Skills
Other Claude Code skills in the same category — free to download.
Algolia Setup
Integrate Algolia instant search with facets and filters
Meilisearch Setup
Set up Meilisearch for fast typo-tolerant search
Postgres Full-Text
Implement full-text search with PostgreSQL tsvector
Search Autocomplete
Build search autocomplete with debounce and suggestions
Search Analytics
Track search queries and click-through for relevance tuning
Elasticsearch Index Mapping
Design Elasticsearch mappings that make queries fast and storage efficient
Want a Search skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.