Apache Solr Tutorial: Learn Search Platform from Scratch (2026)
Apache Solr is a search platform built on Apache Lucene, providing full-text search, faceted navigation, and near-real-time indexing. I have deployed Solr for e-commerce product search, log analytics, and document retrieval systems. Its key strengths are the rich query syntax (edismax), server-side faceting, and the SolrCloud distributed architecture.
This tutorial covers the end-to-end workflow: schema design with field types and analyzers, indexing strategies, query construction with boosting, and SolrCloud cluster configuration.
Schema Design and Field Types
Solr schema defines how fields are indexed, stored, and analyzed. Each field has a type and analysis chain consisting of tokenizer and filters. Field types like text_en apply language-specific stemming, stop-word removal, and lowercasing.
Copy fields aggregate multiple source fields into a single searchable field. Dynamic fields accept field names matching a pattern for schemas that evolve frequently.
Indexing: Full Import and Delta Updates
Solr indexes documents via POSTing XML, JSON, or CSV to /update handler. The DataImportHandler pulls data from relational databases. Full imports rebuild the entire index; delta imports update changed documents.
The commit operation makes documents searchable. Hard commit fsyncs to disk; soft commit makes documents visible without fsyncing.
# Index via JSON:
curl -X POST -H 'Content-Type: application/json' \
http://localhost:8983/solr/products/update?commit=true \
-d '[
{"id": "1", "title": "Wireless Mouse", "price": 29.99},
{"id": "2", "title": "Mechanical Keyboard", "price": 89.99}
]'
Querying: edismax and Filtering
The edismax query parser supports fielded search with boosts, phrase boosting, and minimum-match for fuzzy queries. The qf parameter lists fields with relative boosts. Filter queries (fq) narrow results without affecting scoring.
I use fq for all structured filters — category, price range, in-stock status. Faceting computes counts per field value for navigation.
http://localhost:8983/solr/products/select?
q=wireless+mouse&
qf=title^4+description^2+category&
pf=title^10&
fq=price:[10+TO+100]&
fq=in_stock:true&
facet=true&
facet.field=category
SolrCloud: Distributed Search and Replication
SolrCloud distributes index data across nodes using shards and replicas. A collection is split into shards, each with multiple replicas for redundancy and read scalability. ZooKeeper manages cluster state, leader election, and shard assignment.
I aim for 5-20 million documents per shard.
# Create a SolrCloud collection:
bin/solr create -c products -shards 4 -replicationFactor 3
# Check status:
http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS
Analysis and Tokenization Pipeline
Solr analysis chain determines how text is tokenized and filtered. A standard chain includes StandardTokenizer, LowerCaseFilter, StopFilter, and SnowballPorterStemmerFilter. Multi-language content needs different field types per language.
The Analysis page in the Admin UI is invaluable for debugging how text passes through each analyzer step.
Performance Tuning: Caches and Merges
Solr uses three caches: filter cache (fq results), query result cache (complete queries), and document cache (stored fields). The filter cache is most impactful — reuse of fq across requests avoids re-evaluation.
Index merges consolidate segments. TieredMergePolicy is the default and works well for most workloads.
Frequently Asked Questions
What is the difference between Solr and Elasticsearch?
Both are built on Lucene. Solr offers richer faceting and mature caching. Elasticsearch excels at log analytics with the Elastic Stack and has a more intuitive REST API.
How does Solr handle Chinese or Japanese text?
Use the ICU tokenizer for CJK languages or a dedicated analyzer like Kuromoji for Japanese.
What is the purpose of the Schema API?
The Schema API allows adding, updating, and removing fields without restarting the cluster or editing XML files.
How do I migrate from standalone mode to SolrCloud?
Upload your standalone index to HDFS or S3, create a SolrCloud collection with the same config set, and restore the index.
Originally published on Ayodhyyya. Last updated June 1, 2026.