Prev Next

Web / Apache Solr Interview questions

1. What is Apache Solr? 2. What are the types of fields in Solr? 3. What is a Solr core? 4. What is a Solr collection? 5. What is SolrCloud? 6. What is the purpose of solrconfig.xml? 7. What is the purpose of managed-schema in Solr? 8. Define analyzer in Solr? 9. Describe tokenizer in Solr? 10. What is a filter in the Solr analysis chain? 11. What is an inverted index in Solr? 12. How do you connect to Solr using SolrJ? 13. List the ways to import data into Solr? 14. What is the DataImportHandler in Solr? 15. What are the types of Solr request handlers? 16. How do you apply faceting in a Solr query? 17. What is highlighting in Solr search results? 18. What is the purpose of a query parser in Solr? 19. What is the difference between stored and indexed fields in Solr? 20. What is the difference between the standard query parser and DisMax? 21. What is the difference between DisMax and eDisMax query parsers? 22. What is the difference between q and fq parameters in Solr? 23. What is the difference between soft commit and hard commit? 24. Why is SolrCloud preferred over standalone Solr for production? 25. How does Solr replication work in standalone (master-slave) mode? 26. How does ZooKeeper coordinate a SolrCloud cluster? 27. Why is leader election necessary in SolrCloud shards? 28. What is the difference between NRT, TLOG, and PULL replicas in SolrCloud? 29. When would you choose sharding over replication in SolrCloud? 30. How does Solr handle distributed search across shards? 31. Explain the execution flow of a Solr search request? 32. Explain the lifecycle of a document from indexing to searchability in Solr? 33. Why doesn't Solr return newly indexed documents without a commit? 34. How do you troubleshoot slow Solr queries? 35. How can you optimize indexing throughput in Solr? 36. Explain the internal working of Solr's caching layers? 37. How do you optimize faceted search performance on large collections? 38. What happens when a Solr shard leader goes down? 39. Which is better for autocomplete, EdgeNGram or the Suggester component, and why? 40. How does Solr handle deep pagination, and why is cursorMark recommended over start/rows? 41. Explain the execution flow of an atomic update in Solr? 42. Why should you use docValues for sorting and faceting fields? 43. How do you troubleshoot OutOfMemory errors in a Solr node? 44. What is the difference between Solr's standard scoring and function queries? 45. How does SolrCloud handle a split-brain or network partition scenario? 46. Explain the internal working of Lucene segment merging in Solr? 47. When should you use a custom similarity or scoring function in Solr? 48. How do you optimize Solr for high-throughput near real-time indexing? 49. What is the difference between Apache Solr and Elasticsearch? 50. How do you secure a SolrCloud cluster in production?

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 Lucene code. Solr adds features Lucene does not p...

Read full answer

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. String fields - string ; stored as a single exact token, used for filterin...

Read full answer

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 . A single Solr server process can host multiple cores side by side, each isolated...

Read full answer

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 redundancy. All nodes belonging to a collection share a single confi...

Read full answer

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. Instead of manually managing master-slave replication, SolrCloud automatically distribut...

Read full answer

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. Instead it configures how Solr behaves at runtime. Request handlers - which endpoints exist ( /select , /update ) and their default parameters. Caches - ...

Read full answer

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. As the name suggests, it is meant to be modified through the Schema ...

Read full answer

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. An analyzer is made up of exactly one tokenizer , which splits text into initial tokens, followed by ...

Read full answer

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. Common built-in tokenizers include: StandardTokenizer - splits on whitespace and punctuation using Unicode tex...

Read full answer

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. Frequently used filters include: LowerCaseFilter - normalizes case so "Apple" matches "apple...

Read full answer

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. Forward index Inverted index doc → list of terms ter...

Read full answer

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. SolrClient client = new Http2SolrClient.Builder("http://localhost:8983/solr/products") ....

Read full answer

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. DataImportHandler (DIH) - pulls data from a d...

Read full answer

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 full imports , which reindex everything, and delt...

Read full answer

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 ) Fetches a document by I...

Read full answer

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....

Read full answer

17. What is highlighting in Solr search results?

Highlighting returns short snippets of matched text with the query terms wrapped in emphasis tags, typically , 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= &hl.simple.post...

Read full answer

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 operators, ranges. DisMax - simplified synta...

Read full answer

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 on Field's original value is kept and returned in q...

Read full answer

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 syntax error. Standard parser DisMax F...

Read full answer

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 negative queries Supports pure negat...

Read full answer

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. It affects the score of each document, which drives ranking order. fq (filter query) narrows the result set further but contributes no score . Documents either match ...

Read full answer

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 Not durable by itself; relies on the tlog for recovery More e...

Read full answer

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 is limited by one machine's disk and memory...

Read full answer

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. A slave's ReplicationHandler polls the master on a configured interval, checking the mas...

Read full answer

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 disconnects. /collections//state.json -...

Read full answer

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 . When a client sends an update, it can hit any replica, but that replica forwards the write to the current leader for that shard. The leader ...

Read full answer

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? NRT Indexes locally and keeps a transaction log; supports soft commits for near-real-time search Yes TLOG Keeps a transaction log but only updates its index via...

Read full answer

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. Use it when a single shard's index already fits comfortably on one node's disk and memor...

Read full answer

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. sequenceDiagram participant Client participant R ...

Read full answer

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] D --> G[MoreL...

Read full answer

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 - visible to search] C -->|RAM buffer f...

Read full answer

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 fixed, immutable view of the index ...

Read full answer

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). Check the admin UI's Query tab and cache statistics - a l...

Read full answer

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 request instead of one HTTP call per document; this am...

Read full answer

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 cache Ordered doc ID list for a full query+sort+...

Read full answer

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. Without it, Solr builds an in-memory uninverted index (fieldCache) on first use, which is slo...

Read full answer

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 znode and its entry in /live_nodes ....

Read full answer

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 ...

Read full answer

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 requested 20. As start grows, this becomes increasing...

Read full answer

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. Under the hood, Lucene has no concept of in-place field updates on a document, so Solr has to simulate one. sequenceDiagram participant Client participa...

Read full answer

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 ...

Read full answer

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 of the crash ( -XX:+HeapDumpOnOutOfMemoryError ) and inspect it wi...

Read full answer

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 terms. Functio...

Read full answer

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 i...

Read full answer

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 usage (deleted documents aren't reclaimed unt...

Read full answer

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 terms should never be ...

Read full answer

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. Set a short autoSoftCommit (e.g. 1-3 seconds) for visibility, and a longer autoC...

Read full answer

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...

Read full answer

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. Enable a security plugin such as BasicAuthPlugin for simple username/password control, or KerberosPlugin in enterp...

Read full answer

«
»

Comments & Discussions