Author : Gaurav Jham & Dheeraj Kumar Jha

(Image Credit:

What is Solr?

Its major features include full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features and rich document (e.g., Word, PDF) handling.

Need for Solr Automation

As data in many modules in Shiksha is fed through Solr. So to reduce that manual effort and to make testing effective, we need to integrate Solr in our scripts and verify data of each module through automation.

Modules automated in Shiksha Automation Suite :

  1. Shiksha Reviews.
  2. Predictor Data Validation.
  3. Scholarship Data on Study Abroad Pages.

Important points to keep in mind before Automating Solr

  1. One should have proper knowledge of Solr Queries & how to pass data in Solr Queries. One should also be aware of Faceting Queries which helps in actual filtering of data & count based on the filter .
  2. Faceting Range Queries is also one of the important queries while fetching the data.

Querying Data from Solr

  1. Faceting Queries — Faceting in Apache Solr refers to the classification of the search results into various categories .It returns the number of documents in the current search results that also match the given query.Faceting commands are added to any normal Solr query request, and the faceting counts come back in the same query response.


All requests to Solr are sent by a SolrClient. SolrClient’s are the main workhorses at the core of SolrJ. They handle the work of connecting to and communicating with Solr, and are where most of the user configuration happens.

Requests are sent in the form of SolrRequests, and are returned as SolrResponses.

Maven Configuration

Dependency can be found on maven central.

Implementation in Automation Project

  1. We need to have a Solr host to set up a Connection. For Solr Connection, first we need to create SolrClient , which is actually used to send requests to Solr Server. For this, we require a HTTPSolrClient which interacts directly to Solr Server via HTTP.
  2. Then, we need to create a SolrQuery, which represents a collection of name-value pairs sent to the Solr server during a request.
  3. Then, We create a QueryResponse object which will store the response and the output of the Solr Query . While fetching response from request , We need to throw SolrServerException (which may occur while communicating with Solr Server) .We can parse this Response and store it in a String object.

Below is the code snippet for the same.

Querying in SolrJ

Same has been shown in the above screenshot.

Benefits after Automating Solr

  1. Manual effort got reduced
  2. Chances of finding irregularities are high. It leads to minimal data issues in the system.