How to Set Up Elasticsearch for Full-Text Search
Elasticsearch is a distributed search and analytics engine built on Apache Lucene. It provides powerful full-text search, structured queries, and real-time analytics capabilities. Running Elasticsearch on your Breeze instances enables your applications to deliver fast, relevant search results across large datasets.
Installing Elasticsearch
On your Breeze instance running Ubuntu or Debian:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | \
sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] \
https://artifacts.elastic.co/packages/8.x/apt stable main" | \
sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt update
sudo apt install -y elasticsearch
During installation, Elasticsearch generates a password for the built-in elastic user. Save this password securely.
Configuration
Edit /etc/elasticsearch/elasticsearch.yml for a single-node setup:
cluster.name: breeze-search
node.name: breeze-es-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.type: single-node
xpack.security.enabled: true
xpack.security.http.ssl.enabled: false
For production, allocate JVM heap in /etc/elasticsearch/jvm.options.d/heap.options:
-Xms2g
-Xmx2g
Set heap to 50% of available RAM, but never more than 31 GB. Start and enable the service:
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
Creating an Index with Mappings
Define an index with explicit field mappings for your search use case:
curl -X PUT "http://localhost:9200/articles" -H 'Content-Type: application/json' \
-u elastic:YourPassword -d '{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"content_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "stop", "snowball"]
}
}
}
},
"mappings": {
"properties": {
"title": { "type": "text", "analyzer": "content_analyzer", "boost": 2.0 },
"body": { "type": "text", "analyzer": "content_analyzer" },
"author": { "type": "keyword" },
"tags": { "type": "keyword" },
"published_at": { "type": "date" },
"view_count": { "type": "integer" }
}
}
}'
Indexing Documents
Add documents to your index:
curl -X POST "http://localhost:9200/articles/_doc" -H 'Content-Type: application/json' \
-u elastic:YourPassword -d '{
"title": "Getting Started with Breeze Instances",
"body": "This guide walks you through deploying your first application on a Breeze cloud instance...",
"author": "admin",
"tags": ["tutorial", "getting-started"],
"published_at": "2026-03-01",
"view_count": 150
}'
Searching Documents
Perform full-text search queries:
curl -X GET "http://localhost:9200/articles/_search" -H 'Content-Type: application/json' \
-u elastic:YourPassword -d '{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "deploy application",
"fields": ["title^2", "body"],
"type": "best_fields",
"fuzziness": "AUTO"
}
},
"filter": [
{ "term": { "author": "admin" } },
{ "range": { "published_at": { "gte": "2026-01-01" } } }
]
}
},
"highlight": {
"fields": {
"title": {},
"body": { "fragment_size": 150, "number_of_fragments": 3 }
}
},
"size": 10
}'
Monitoring and Maintenance
Monitor cluster health and index statistics:
# Cluster health
curl -u elastic:YourPassword "http://localhost:9200/_cluster/health?pretty"
# Index statistics
curl -u elastic:YourPassword "http://localhost:9200/articles/_stats?pretty"
# Node resource usage
curl -u elastic:YourPassword "http://localhost:9200/_nodes/stats?pretty"
Elasticsearch on a single Breeze instance can handle millions of documents with sub-second search response times. For larger workloads, scale horizontally by adding more Breeze instances to the cluster and increasing the shard count.