Apache Solr Tutorial: Product Search, Facets, and Recovery
Build a local Solr 10.1.0 product search, add category facets and eDisMax tuning, then practice a standalone-core backup and restore.
Choose between Solr and Elasticsearch by matching the search features and operating model to your team. Then build a small Solr 10.1.0 product index, query it with eDisMax, facet the results, and restore a standalone-core backup.
Apache Solr Tutorial: Product Search, Facets, and Recovery
Solr and Elasticsearch both build on Apache Lucene. Choose between them by the search behavior you need and the system your team can operate. This guide starts with that choice, then uses one small product catalog for indexing, faceting, relevance tuning, and recovery.
Commands and documentation were checked against Apache Solr 10.1.0 on 2026-11-04. The Solr downloads page lists 10.1.0 as the latest release. Use this as a local lab; adapt deployment and security for your environment before running a search service.
Choose Solr or Elasticsearch first
Decide from the work your search service must do and the systems your team already operates. Compare the requirements you can verify in a prototype:
| Question | Solr may fit when… | Elasticsearch may fit when… |
|---|---|---|
| How will you shape search? | You want to configure schema, analyzers, request handlers, and query behavior directly in Solr. | Your team already uses Elasticsearch APIs and its surrounding tools. |
| Which interactions matter? | Your product search depends on field facets, filters, and explicit query-time relevance controls. | Your use case maps cleanly to the query and aggregation APIs your team already knows. |
| Who will operate it? | The team can own Solr configuration and, if needed, SolrCloud operations. | The team has an established Elasticsearch service, managed offering, or operating practice. |
| What should you test? | Index representative documents and validate schema, facets, and relevance judgments. | Run the same corpus and representative queries through the Elasticsearch stack you plan to operate. |
Use the table to narrow the options. Before choosing, run representative queries against sample documents and write down which results should rank first. Then check the operational requirements: deployment, access control, upgrades, backups, and on-call ownership. For a closer comparison, see the repository’s Elasticsearch guide. If your main concern is index shape or query load, continue with search scaling and database indexes.
Start a local Solr 10.1.0 core
Solr 10.x requires Java 21 or newer for the server. Download the full Solr 10.1.0 binary archive, extract it, and run the commands from that directory. The installation guide describes the binary packages and setup.
bin/solr start --user-managed
bin/solr create -c products -d _default
--user-managed starts standalone mode, where create makes a core rather than a SolrCloud collection. The _default configset provides the managed schema used below. See the Solr control script reference for the CLI options.
The lab will index four product documents. Each document has a unique id, searchable name and description, and a single category for faceting:
| ID | Name | Category | Description |
|---|---|---|---|
p-101 |
Wireless headphones | audio | Over-ear headphones with noise cancellation and Bluetooth. |
p-102 |
Bluetooth speaker | audio | A portable speaker for wireless music playback. |
p-201 |
Desk lamp | home | An adjustable LED lamp for a reading desk. |
p-301 |
SQL pocket guide | books | A short reference to relational database queries. |
Solr uses a schema to define field types and behavior. The following request adds fields to the managed schema. The two text fields use the configset’s text_general field type; the category field is a string with doc values so it can be faceted as a literal category. The id unique key already comes from the configset, as shown in the Solr 10.1.0 _default schema. For schema options and the API, see Schema Elements and the Schema API.
curl 'http://localhost:8983/solr/products/schema' \
-H 'Content-Type: application/json' \
--data-binary '{
"add-field": [
{"name":"product_name","type":"text_general","stored":true,"indexed":true},
{"name":"product_description","type":"text_general","stored":true,"indexed":true},
{"name":"product_category","type":"string","stored":true,"indexed":true,"docValues":true}
]
}'
The schema API reloads the core so the fields can be used for later indexing. If you rerun this request, Solr will report that the fields already exist; keep the core and schema between the steps or create a fresh lab core.
Index the product documents
Save the following JSON array as products.json. A stable id lets an update replace the matching indexed document later. The JSON update handler accepts an array of documents at /update; the commit=true parameter commits this small lab batch so it is immediately searchable. See Indexing with Update Handlers for JSON request forms and commit behavior.
[
{
"id": "p-101",
"product_name": "Wireless headphones",
"product_category": "audio",
"product_description": "Over-ear headphones with noise cancellation and Bluetooth."
},
{
"id": "p-102",
"product_name": "Bluetooth speaker",
"product_category": "audio",
"product_description": "A portable speaker for wireless music playback."
},
{
"id": "p-201",
"product_name": "Desk lamp",
"product_category": "home",
"product_description": "An adjustable LED lamp for a reading desk."
},
{
"id": "p-301",
"product_name": "SQL pocket guide",
"product_category": "books",
"product_description": "A short reference to relational database queries."
}
]
Post the file to the core:
curl 'http://localhost:8983/solr/products/update?commit=true' \
-H 'Content-Type: application/json' \
--data-binary @products.json
Solr should return a response header with status 0. The core now has four documents. Check that before moving to query behavior:
curl 'http://localhost:8983/solr/products/select?q=*:*&rows=0&wt=json'
The response’s response.numFound should be 4. If it is 0, confirm the core name, JSON request content type, and update response before changing query settings.
Search and facet the same catalog
Start with a search for wireless headphones. The field list asks Solr to return the ID, name, category, and score. URL-encoding the values with curl -G keeps spaces and the boost character intact:
curl -G 'http://localhost:8983/solr/products/select' \
--data-urlencode 'q=wireless headphones' \
--data-urlencode 'defType=edismax' \
--data-urlencode 'qf=product_name product_description' \
--data-urlencode 'fl=id,product_name,product_category,score' \
--data-urlencode 'rows=10' \
--data-urlencode 'wt=json'
Setting defType=edismax makes Solr parse q with eDisMax; qf supplies the fields it searches. The top result should be p-101, whose name contains both search terms. Scores and ordering depend on the schema, analyzers, and indexed content, so use representative products and expected results to tune the query. The eDisMax guide documents qf, phrase fields, and other parser parameters.
Now return counts by product category for the full index:
curl -G 'http://localhost:8983/solr/products/select' \
--data-urlencode 'q=*:*' \
--data-urlencode 'rows=0' \
--data-urlencode 'facet=true' \
--data-urlencode 'facet.field=product_category' \
--data-urlencode 'facet.mincount=1' \
--data-urlencode 'wt=json'
The facet should contain audio: 2, home: 1, and books: 1. A field facet counts indexed terms for documents matching the query; rows=0 suppresses document results while still returning facet counts. Keep product_category a string field so values such as audio are treated as whole labels rather than analyzed text. Solr’s faceting reference describes field facets and the facet parameters.
Tune relevance with a testable change
The first query gives both text fields equal weight. For a product catalog, a match in the product name may be a stronger signal than a match in the longer description. Change the query fields so the name has a higher weight and add a phrase-field boost for documents whose name contains the query terms together:
curl -G 'http://localhost:8983/solr/products/select' \
--data-urlencode 'q=wireless headphones' \
--data-urlencode 'defType=edismax' \
--data-urlencode 'qf=product_name^4 product_description' \
--data-urlencode 'pf=product_name^8' \
--data-urlencode 'fl=id,product_name,score' \
--data-urlencode 'rows=10' \
--data-urlencode 'wt=json'
qf weights matches in product_name more heavily than matches in product_description; pf adds a phrase proximity boost when the query terms appear close together in that field. Use 4 and 8 only as trial weights for this lab. Before shipping a change, compare results for real queries against judgments from people who know the catalog. Check relevance and note whether useful lower-ranked matches disappear. Add function boosts only when a field or business rule gives you a reason to do so.
Back up and restore this standalone core
The standalone core uses Solr’s ReplicationHandler for index backups. SolrCloud uses the Collections API instead. The two workflows are different: a SolrCloud backup spans shards and requires a shared filesystem mounted at the same path on each node. Solr backups capture hard-committed index data; a soft commit can make recent changes visible to search without including them in a later backup. The Solr 10.1 backup and restore guide describes both paths and this commit boundary.
The indexing request above used commit=true, which is a hard commit. Start a named local backup in a directory writable by the Solr process:
curl -G 'http://localhost:8983/solr/products/replication' \
--data-urlencode 'command=backup' \
--data-urlencode 'location=/tmp/solr-backups' \
--data-urlencode 'name=products-demo'
The backup call is asynchronous. Check its status before treating the snapshot as ready:
curl 'http://localhost:8983/solr/products/replication?command=details&wt=json'
Look for the backup status to report success. To practice restoring, run the restore request against this disposable lab core:
curl -G 'http://localhost:8983/solr/products/replication' \
--data-urlencode 'command=restore' \
--data-urlencode 'location=/tmp/solr-backups' \
--data-urlencode 'name=products-demo'
Restore is asynchronous and replaces the current core’s index with the snapshot when complete. Check command=restorestatus, then rerun the q=*:*&rows=0 query. It should again report four documents, and the category facet should still show the same counts. Use a disposable core for this exercise. After a restore, verify that the index answers the queries your application needs.
This example keeps the backup on the same machine as Solr. It is useful for learning, but it will not protect against losing that host or disk. For a real deployment, configure a repository and storage location that meet your recovery needs, track backup status, and rehearse restore with the same Solr version and configuration. SolrCloud uses a separate Collections API procedure and shared storage requirements.
Verify the lab
The lab is complete when each check succeeds:
q=*:*&rows=0reports four documents before and after restore.- The category facet reports
audio: 2,home: 1, andbooks: 1. - The eDisMax query returns
p-101at the top with the sample weights. - Backup and restore status both report success.
The comparison and indexing guides linked above give you next steps for testing another engine or planning for a larger query load.
Summary
Choose Solr or Elasticsearch based on the search behavior and operating model your team can support. In Solr 10.1.0, a managed schema, JSON update handler, eDisMax query, field facet, and standalone ReplicationHandler are enough to walk a small catalog from indexing through a local recovery check. Keep the query judgments and backup test tied to your own documents before carrying the design into production.
Category
Related Posts
Elasticsearch: Full-Text Search at Scale
Learn how Elasticsearch powers search at scale with inverted indexes, sharding, replicas, and its powerful Query DSL for modern applications.
Skip Lists: Layered Linked Lists for Fast Search
Understand skip lists as probabilistic alternatives to balanced trees, providing O(log n) search with simple implementation and lock-free variants.
Search Scaling: Sharding, Routing, and Horizontal Growth
Learn how to scale search systems horizontally with index sharding strategies, query routing, replication patterns, and cluster management techniques.