Introduction to Apache Solr
Last modified: November 22, 2017
Solr is an open source search platform based on the Lucene Java search library. It integrates with Hadoop's HDFS and provides real-time indexing to support things like full-text and faceted search on a distributed cluster. In this article, we explore Solr including how it works, key features, and most appropriate use cases.
What is Solr?
Solr is essentially a wrapper for the Apache Lucene Java library. Lucene was developed to support full-text search and indexing on larger data sets where full-table scans jeopardize search query performance.
Lucene works by creating indexes based on search terms / words in your database. When a full-text search is performed, Lucene consults the index rather than performing full-table scans. This can dramatically improve search performance, especially when dealing with terabytes of data.
Solr simply implements a wrapper for the Lucene library. It provides a convenient REST API for querying data in HDFS with Lucene. Solr also provides a non-relational data store (NoSQL) primarily used for storing indexes.
Solr Key features
There are a few key features that make Solr ideal for real-time indexing and full-text search within a distributed cluster. These include:
NoSQL data storage:Solr provides a non-relational data store for storing full-text indexes.
Solr implements a convenient HTTP interface for accessing and modifying data. This makes it possible to use Solr with little Java programming experience.
Solr provides a nice UI for running search queries directly in the browser.
Since it's based on the open-source Lucene project, Solr is easily extensible.
Solr supports a SQL-like interface for business intelligence, analytics, and reporting.
Distributed Cluster Support
Solr supports automatic sharding and replication via Solr cloud.
How Solr Works
Clients send HTTP requests to Solr via the Solr API. While request handlers identify the type of request (select, update, etc.) search components define the type of search (query, faceting, spelling) to be performed. A query parser then converts the requested query to a Lucene-friendly format that is then analyzed/tokenized by Solr. Once results have been processed, a response writer is used to specify a format (XML, JSON, CSV, etc.) and return the results to the client.
Should I use Solr?
Since it automatically handles sharding and replication, Solr is a convenient add-on to any distributed cluster environment. It integrates well with Hadoop and is highly recommended for applications requiring frequent full-text or filtered search queries.
Solr can be used in conjunction Hive, HBase, and other popular Hadoop apps.
Solr is ideal for full-text search and real-time indexing. It integrates well with Hadoop and other distributed processing environments. Use Solr if you need to perform full-text or faceted (filtered) search queries in a big data environment.