Apache Solr: Setup and Basic Querying

Apache Solr is a fast open-source Java search server.
Solr provides a indexing, replication and load-balanced querying for your data, data may contains websites, databases and files.

Solr built based on Apache Lucene (http://lucene.apache.org/). Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.

Download Solr

Apache provides a ready to use distribution for Solr, to download visit official site of Solr : https://lucene.apache.org/solr/ and click Download link.

For the demo i have used version 6.3.0 which is latest stable version at a time of writing of this blog. Download direct from http://redrockdigimark.com/apachemirror/lucene/solr/6.3.0/.

Distribution available in zip and tgz format.

  • zip: http://redrockdigimark.com/apachemirror/lucene/solr/6.3.0/solr-6.3.0.zip
  • tgz: http://redrockdigimark.com/apachemirror/lucene/solr/6.3.0/solr-6.3.0.tgz

Once downloaded extract it to your favorite location.
I have extracted it to E:\SOLR directory.

Let’s look into Filesystem.

Start Solr

To start a Solr Server follow steps below

  • Open command prompt
  • Change directory to E:\SOLR\solr-6.3.0\bin
  • Execute Command solr.cmd start

On successful execution of command it shows

Means everything goes fine and good to go.

Ready to GO!

We can check status of server using 2 methods
Command Based
Execute command below to check status of solr server.


Web Based
You can hit below url in your favorite browser to see status.

Here it shows everything goes fine and that’s why we got this web page. It shows no core available and it required to create one. Next section will show you how to create a Core.

Create a Core

Here we are using command based methodology to create a Core.


This command will create a necessary files into E:\SOLR\solr-6.3.0\server\solr directory shown in image below.

Let’s see web to check status of core “test”.

It shows created core and other details about it.
Thing which i want to highlight here is it shows numDocs is 0 means Solr contains 0 documents.

Indexing a file

I have created a sample xml file to be indexed.
File: employee.xml

Use command below to index content of above file.
Here i have placed my employee.xml at location E:\SOLR\employee.xml
and using posting tool(post.jar) which is provided by Solr and resides in distribution at location <SOLR_HOME>\example\exampledocs.



In previous section it shows value of numDocs and MaxDoc is 0 as we don’t have any document available, not we have 3 documents which you can verify using web.

Now it show numDocs is 3.

Basic Searching

Here we are using web based method to search on core.
To begin with search please select “test” from “Query Selector” and than click on “Query” to open a query browser, it open a query browser in right area.

Here we want to search a documents where value contains “Employee_1” so we added “Employee_1” in text-area labeled with “q” and hit “Execute Query” button.

Now it shows output in right pane.

You can use direct web url also for searching.


That’s it for basics.

Will have some good tutorials on querying, administration, performance, optimization, load balancing and integration with Spring and Java in upcoming post.

Share current post by copy: https://goo.gl/kYSqsa
Happy Learning!

Thanks, Yogesh P