Web / Apache Solr Interview questions
1. What is Apache Solr?
Apache Solr is an open-source search platform built on top of Apache Lucene . It exposes Lucene's indexing and search library as a standalone server with a REST-like HTTP/JSON API, so applications can index and query data without writing low-level...
2. What are the types of fields in Solr?
Solr fields are defined by a field type , which controls how values are analyzed, stored, and indexed. The common built-in categories are: Text fields - text_general , text_en ; analyzed and tokenized for full-text search....
3. What is a Solr core?
A core is a single running instance of a Lucene index along with its own configuration: schema.xml (or managed-schema) and solrconfig.xml . It is the basic unit of indexing and search in standalone (non-cloud) Solr ....
4. What is a Solr collection?
A collection is the logical unit of indexing and search in SolrCloud , Solr's distributed mode. Unlike a core, a collection can span multiple servers: its data is split into shards , and each shard can have multiple replicas for...
5. What is SolrCloud?
SolrCloud is Solr's distributed, fault-tolerant operating mode. It uses Apache ZooKeeper as a coordination service to track cluster state, replica locations, live nodes, and leader assignments for each shard.
6. What is the purpose of solrconfig.xml?
solrconfig.xml is the operational control file for a Solr core or collection. It does not define field names or types; that's the schema's job....
7. What is the purpose of managed-schema in Solr?
managed-schema is the file that defines the data model for a Solr core or collection: field names, field types, dynamic field patterns, copy fields, and the unique key. It replaces the older, manually edited schema.xml approach....
8. Define analyzer in Solr?
An analyzer is the pipeline Solr runs over text to convert raw input into a stream of indexable or searchable tokens . It is attached to a field type and can differ for indexing and for querying....
9. Describe tokenizer in Solr?
A tokenizer is the first stage of an analyzer. It takes a raw stream of characters and breaks it into a stream of tokens , typically words, based on rules like whitespace or punctuation....
10. What is a filter in the Solr analysis chain?
A token filter runs after the tokenizer and transforms the token stream it receives, either by modifying tokens, adding new ones, or dropping some entirely. An analyzer can chain many filters in sequence....
11. What is an inverted index in Solr?
An inverted index is the core data structure Lucene, and therefore Solr, uses for fast full-text search. Instead of storing "which terms are in document 5" like a regular table, it stores "which documents contain this term" for every term....
12. How do you connect to Solr using SolrJ?
SolrJ is the official Java client for Solr. For standalone Solr, you typically use Http2SolrClient ; for SolrCloud, CloudSolrClient , which is ZooKeeper-aware and can route requests to the right shard leader.
13. List the ways to import data into Solr?
Solr supports several ingestion paths depending on the source system and update frequency: Update APIs - post JSON, XML, or CSV directly to /update using curl, the bin/post tool, or an HTTP client. SolrJ - programmatic indexing from Java applications....
14. What is the DataImportHandler in Solr?
The DataImportHandler (DIH) is a contrib module that pulls data into Solr from external sources - relational databases via JDBC, XML feeds, or flat files - based on a data-config.xml file describing the source query and field mappings. It supports...
15. What are the types of Solr request handlers?
A request handler processes a specific type of HTTP request sent to Solr. Common built-in types include: Handler Purpose SearchHandler ( /select ) Runs queries and returns results UpdateRequestHandler ( /update ) Adds, updates, deletes documents RealTimeGetHandler ( /get )...
16. How do you apply faceting in a Solr query?
Faceting returns counts of documents grouped by field values alongside the normal search results, powering filters like "Brand (Nike: 42, Adidas: 31)" on an e-commerce page. /select?q=laptop &facet=true &facet.field=brand &facet.range=price &facet.range.start=0 &facet.range.end=2000 &facet.range.
17. What is highlighting in Solr search results?
Highlighting returns short snippets of matched text with the query terms wrapped in emphasis tags, typically <em> , so a UI can show users why a document matched, similar to Google's bolded search snippets. /select?q=title:solr &hl=true &hl.fl=title,description &hl.simple.pre=<em> &hl.simple.post
18. What is the purpose of a query parser in Solr?
A query parser converts the raw text passed in the q parameter into a structured Lucene Query object that can actually be executed against the index. Solr ships with several: Standard (Lucene) parser - supports Lucene's own syntax: field:value, boolean...
19. What is the difference between stored and indexed fields in Solr?
Indexed and stored are independent boolean attributes on a field, and mixing them up is a common source of confusing search behavior. indexed="true" stored="true" Field is analyzed and added to the inverted index so it can be searched or faceted...
20. What is the difference between the standard query parser and DisMax?
The standard (Lucene) query parser exposes Lucene's full syntax directly: field:value pairs, boolean operators (AND, OR, NOT), wildcards, and range queries. It is powerful but unforgiving - a stray colon or unbalanced parenthesis from an end user can throw a...
21. What is the difference between DisMax and eDisMax query parsers?
eDisMax (Extended DisMax) is a superset of DisMax built to close its biggest gap: lack of full boolean logic. DisMax eDisMax No support for AND/OR/NOT or field:value syntax Supports full Lucene-style boolean operators and field:value syntax No support for pure...
22. What is the difference between q and fq parameters in Solr?
Both q and fq restrict which documents are considered, but they behave very differently underneath. q is the main relevance query....
23. What is the difference between soft commit and hard commit?
Both commits make recent index changes visible, but they differ in durability and cost. Hard commit Soft commit Flushes data to disk and truncates the transaction log Opens a new searcher without an fsync to disk Durable across a crash...
24. Why is SolrCloud preferred over standalone Solr for production?
Standalone Solr with master-slave replication works, but it has operational gaps that matter at production scale: No automatic failover - if the master goes down, writes stop until someone manually promotes a slave. No automatic sharding - a single core...
25. How does Solr replication work in standalone (master-slave) mode?
In classic standalone replication, one core is designated the master and one or more cores act as slaves . The master handles all writes; slaves handle read traffic and periodically pull data from the master....
26. How does ZooKeeper coordinate a SolrCloud cluster?
ZooKeeper acts as the single source of truth for a SolrCloud cluster's metadata, using a hierarchy of znodes that every node watches for changes. /live_nodes - ephemeral znodes listing which Solr nodes are currently up; removed automatically if a node...
27. Why is leader election necessary in SolrCloud shards?
Each shard in SolrCloud can have multiple replicas, but writes need a single point of coordination to stay consistent. That's the role of the shard leader ....
28. What is the difference between NRT, TLOG, and PULL replicas in SolrCloud?
SolrCloud lets you mix replica types within a shard to balance indexing cost against read availability. Type Behavior Can become leader?...
29. When would you choose sharding over replication in SolrCloud?
Sharding and replication solve different problems, and confusing them leads to either wasted hardware or a cluster that can't handle its data volume. Replication - copies the same full data set to more nodes....
30. How does Solr handle distributed search across shards?
When a collection has multiple shards, a query sent to any single replica must still search all shards to produce a complete result, since each shard only holds part of the data. Solr coordinates this transparently using a scatter-gather approach....
31. Explain the execution flow of a Solr search request?
A single /select request passes through a defined pipeline of components before a response is returned. flowchart LR A[HTTP request] --> B[SearchHandler] B --> C[Query parser builds Lucene Query] C --> D[QueryComponent runs search] D --> E[FacetComponent] D --> F[HighlightComponent]...
32. Explain the lifecycle of a document from indexing to searchability in Solr?
A document doesn't become searchable the instant it's added; it moves through several stages first. flowchart TD A[Client sends add request] --> B[Written to transaction log] B --> C[Buffered in in-memory RAM buffer] C -->|Soft commit| D[New searcher opened -...
33. Why doesn't Solr return newly indexed documents without a commit?
This trips up a lot of developers new to Lucene-based search: calling add() does not make a document searchable, because Solr (via Lucene) uses snapshot isolation for reads. Every search request runs against a specific IndexSearcher instance, which represents a...
34. How do you troubleshoot slow Solr queries?
Diagnosing slow queries in Solr is mostly a process of isolating which stage of the request is expensive. Add debugQuery=true and inspect the timing block in the response - it breaks down time spent per component (query, facet, highlight)....
35. How can you optimize indexing throughput in Solr?
Indexing throughput is usually limited by commit overhead, request overhead, or the ram buffer settings rather than raw CPU, so tuning those first tends to pay off the most. Batch documents - send hundreds or thousands of documents per update...
36. Explain the internal working of Solr's caching layers?
Solr keeps three main caches per searcher instance, each targeting a different part of the query lifecycle. Cache What it stores Best for Filter cache Bitset of matching doc IDs per unique fq clause Repeated filters (category, inStock) Query result...
37. How do you optimize faceted search performance on large collections?
Faceting cost grows with both the number of unique values in a field and the number of matching documents, so optimization usually targets one of those two dimensions. Enable docValues on faceted fields....
38. What happens when a Solr shard leader goes down?
Losing a shard leader triggers a well-defined recovery sequence rather than an outage, as long as at least one in-sync replica remains. The leader's session with ZooKeeper ends (crash, GC pause past timeout, or network partition), removing its ephemeral leader...
39. Which is better for autocomplete, EdgeNGram or the Suggester component, and why?
Both can power autocomplete, but they trade off index size, relevance, and speed differently, so "better" depends on the requirement. EdgeNGram field Suggester component Generates prefix n-grams at index time ("s","so","sol","solr") Builds a dedicated finite-state transducer (FST) structure from
40. How does Solr handle deep pagination, and why is cursorMark recommended over start/rows?
Standard pagination with start and rows looks simple - start=10000&rows=20 for page 501 - but internally Solr, like any Lucene-based system, still has to compute and rank the first 10,020 results and discard the first 10,000 just to return the...
41. Explain the execution flow of an atomic update in Solr?
An atomic update lets you modify one or more fields of an existing document (e.g. change a "price" field) without resending the entire document....
42. Why should you use docValues for sorting and faceting fields?
docValues store field values in a column-oriented, on-disk format built at index time, essentially the inverse of the inverted index: instead of term-to-documents, it's document-to-value, optimized for exactly the access pattern sorting, faceting, and grouping need. Without docValues, Solr falls
43. How do you troubleshoot OutOfMemory errors in a Solr node?
Solr OOM errors almost always trace back to heap being consumed faster than the JVM can reclaim it, and the fix depends on identifying which consumer is responsible before blindly raising heap size. Capture a heap dump at the time...
44. What is the difference between Solr's standard scoring and function queries?
Solr's default relevance scoring uses BM25 (the modern default similarity, replacing the older TF-IDF-based classic similarity), which ranks documents by term frequency, inverse document frequency, and field length normalization - purely based on how well the text matches the query...
45. How does SolrCloud handle a split-brain or network partition scenario?
Split-brain - two nodes both believing they're the legitimate leader and accepting conflicting writes - is exactly what SolrCloud's ZooKeeper-based coordination is designed to prevent, by relying on ZooKeeper's own quorum guarantee rather than inventing a separate consensus mechanism. ZooKeeper...
46. Explain the internal working of Lucene segment merging in Solr?
Every commit or flush in Solr creates a new immutable Lucene segment - a self-contained mini-index. Over time, continuous indexing produces many small segments, and having too many hurts both search speed (each query must check every segment) and disk...
47. When should you use a custom similarity or scoring function in Solr?
Solr's default BM25Similarity works well for general text relevance, so custom scoring should be reserved for cases where the default assumptions genuinely don't fit the domain, rather than applied as a default optimization step. Domain-specific term importance - if certain...
48. How do you optimize Solr for high-throughput near real-time indexing?
High-throughput NRT indexing means tuning the tension between "documents should appear searchable quickly" and "commits and merges are expensive," rather than chasing either extreme. Tune commit intervals separately....
49. What is the difference between Apache Solr and Elasticsearch?
Both are search platforms built on Apache Lucene and share the same underlying inverted-index fundamentals, but they diverge in ecosystem, API design, and operational model. Apache Solr Elasticsearch Fully open-source (Apache 2.0), governed by the Apache Software Foundation Source-available under
50. How do you secure a SolrCloud cluster in production?
A default SolrCloud install has no authentication and exposes a powerful admin API, so production hardening covers several independent layers rather than one setting. Authentication.