Solr vs. Elasticsearch: Which search engine is the best?

Table of contents

Searches are an integral and important part of any application. Searching terabytes and petabytes of data can be a challenge when speed, performance, and high availability are basic requirements, it is for this reason that you turn to a search engine like Solr or Elasticsearch to manage these challenges.

Short comparison

A comparison was made between the most popular and widely used open source search engines, Solr and Elasticsearch, to help decide according to particular needs.

On one hand, Solr has more advantages when dealing with static data because of its cache and the ability to use a non-inverted reader to classify, for example, e-commerce. On the other hand, Elasticsearch is more suitable, and It’s employed with much more frequency for time-series data use cases, for example, record analysis.

Elasticsearch

Elasticsearch is a distributed RESTful search and analytics engine capable of handling a growing number of use cases. It provides a distributed full-text search engine, supporting multiple tenants with HTTP web interface (rest) and schema-less JSON documents. Official client libraries for elastic search are available for: JavaScript, java, PHP, groovy, .net, ruby, Perl, and Python.

Search engines contain indexes that are divided into fragments and each fragment can have several copies. Each Elasticsearch node can have one or more fragments. Your engine also acts as a coordinator, delegating operations to the correct fragments.

Elasticsearch has near real-time search scalability. One of its key features is that it is multi-user; however, there are other features that are also key such as:

  • Distributed search
  • Multiple lease period
  • A chain of parsers
  • Scanning search
  • Group aggregation

Solr

Solr has been in the search engine industry since 2006; it is a proven product with a strong and large user community. Solr offers automatic load balancing, distributed reindexing, failover, and retrieval queries.

If implemented correctly and managed well, it can become a highly reliable, scalable, and fault-tolerant search engine. Many Internet giants such as Netflix, eBay, Instagram, and Amazon (Cloud Search) use Solr because it can index and search multiple websites.

The list of key features includes

  • NoSQL functionality and productive document handling (e.g., words and PDF files).
  • Highlighting
  • Multi-array search
  • Real-time indexing
  • Full text search
  • Dynamic grouping
  • Database integration

Installation and configuration

Java is the main prerequisite for installing both engines, but the default configuration of Elasticsearch requires 1 GB of HEAP memory. This can be changed in the jvm.options file within the configuration directory.

By default, Solr needs at least 512 MB of HEAP memory to allocate instances. This setting can be changed in the Solr script file or in the solr.in.cmd file, both files are located inside the bin directory of the Solr installation.

Elasticsearch is easy to install and configure but is more cumbersome than Solr. Configuration files in Elasticsearch are written in YML format, while Solr supports XML-based configuration files.

Indexation and search

Both Solr and Elasticsearch write indexes in Lucene, but since there are differences in fragmentation and replication (among other features), there are also differences in their files and architectures. In addition, Elasticsearch has native DSL support, while Solr has a robust standard query parser that aligns with Lucene syntax.

Scalability and Distribution

Search engines have to quickly process large amounts of data and complex queries on sets of hundreds of millions of records. Sometimes, these queries can consume so many resources that they can bring down the entire system, especially if you have not planned the load in advance and cannot scale quickly. For this reason, a search engine must be scalable and fault-tolerant by nature.

Clusters, fragmentation, and rebalancing

Both Elasticsearch and Solr provide support for fragmentation, but because Elasticsearch’s design takes horizontal scaling into account, it has better support for scaling and cluster management. Its disadvantage is that fragments cannot be scaled up once they have been created, although you can use a shrink API to shrink fragments from an index. Solr supports further splitting of an existing fragment, but not fragment reduction.

Community

Both Solr and Elasticsearch have very active communities. If you check Github, you can see that they are predominantly open source projects with many releases.

It is crucial to note that although both are released under the Apache license and both are open source, they work a bit differently. Solr is open source: anyone can help and contribute. This means that if you need a feature, and you contribute it to the community, with sufficient quality, it can be accepted.

Elasticsearch is technically open source but not completely. All contributors have access to the source code and users can make changes and contribute to them. But final changes get confirmation from Elastic employees (the company that runs Elasticsearch). So Elasticsearch is driven more by a single company than by an entire community. This is not to mention the number of non-open premium features offered by Elasticsearch (and Elastic/ELK Stack in general).

Documentation

In this aspect, Elasticsearch documentation wins. Not only does the official Elasticsearch website offer well-organized, high-quality documentation with clear examples, but the Internet is full of books and guides, thanks to the popularity of the tool. During the last four years, Elasticsearch improved its documentation to go beyond organization. It also provides good examples and clear configuration instructions.

In comparison, Solr documentation is lacking. Overall coverage of Solr APIs is minimal, and good technical examples and tutorials are hard to find. It used to be the other way around: Solr was a very well-documented product, with clear examples and contexts for API use cases. However, the maintenance of its documentation has now fallen behind, with gaps noted by many users.

Summary: Solr vs Elasticsearch

Selecting a clear winner between these two technologies requires a thorough understanding of the use cases they support, their feature sets, the scaling options they offer, and their ease of maintenance.

Here is a summary of the attributes of each tool:

| ítem | Solr | Elasticsearch |
| ———— | ———— | ———— |
| Installation and configuration | Easy to install and configure, with supporting documentation. |Easy to install and configure with supporting documentation. Several packages are available for various platforms.
| Search and indexing | Optimal for text search and enterprise applications close to the big data ecosystem. | Useful as a text and analytical search engine due to its powerful aggregation module. |
| Scalability and clustering | Support for Solr Cloud and Apache Zookeeper dependency for cluster coordination. | Improved inherent scalability; optimal design for cloud implementation. |
| Clusters, fragmentation, and rebalancing | Supports further splitting of an existing fragment, but not fragment reduction. | Better support for scaling and cluster management, but fragments cannot be scaled up once they have been created. |
| Community | It is open source: anyone can help and contribute.| It is open source, but is driven more by a single company than by an entire community. |
| Documentation | Documented, poorly organized. | Well documented and organized. |