Solr 4.3: shard splitting quick look

With the release of Solr 4.3 we’ve got a long awaited feature – we can now split shards of collections that were already created and have data (in SolrCloud type deployment). In this entry we would like to try that feature and see how it works. So let’s do it.

A few words before we try

Choosing the right amount of shard a collection should be built of is one of those variables that needs to be known before the final deployment. After our collection was created we couldn’t change the number of shard, we were only able to add more replicas. Of course that came with consequences – if we’ve chosen the number of shards wrong we could end up with too low shards count and the only way to go was creating a new collection with the proper amount of shard and re-index our data. With the release of Apache Solr 4.3 we are now able to split shards of our collections.

Small cluster

In order to test the new shard split functionality I decided to run a small and simple cluster containing a single Solr instance with the embedded ZooKeeper and use the example collection provided with Solr. In order to achieve that I’ve run the following command:

After launching the mini cluster its view was as follows:


Test data

As usual we need some data for tests and I decided to use the example data provided with Solr. In order to index them I’ve run the following command in the exampledocs directory:

The number of indexed documents were checked with the following command:

The response returned by Solr was as follows:

As you can see we’ve got 32 documents in our collection.

Shard split

So now let’s try to divide the single shard our collection is built of. In order to do that we will use Collections API and a new – SPLITSHARD action. In its simplest form it takes two parameters – collection which is the collection name we want to divide and the shard which is the name of the shard we want to split. So in our case, the command that will split the shard looks like this:

If everything run without a problem, after a few seconds we will get response form Solr that indicates the end of the process. The response will look more or less like this:

Cluster after the split

After the split our cluster view will look like this:

after_splitAs we can see we have two new shards. In theory each of the new shards should contain a portion of documents from the original shard1 – some of the documents should be placed in  shard1_1 and some in shard1_0. Again using Solr administration panel we can check each of the cores (which are the actual shards):


Statistics for shard with the name of Shard1_1 are as follows:



And the statistics for shard with the name of Shard1_0 are as follows:


As you can see we have 32 documents in total, which is the same as in the original collection.

Cleaning up

I’ve left the cleaning up for the end. First of all in order to see the data in new shards we need to run the commit command against our collection. For example, this can be done by using the following command:

In addition to that we can also remove the original shard, for example by using Solr administration panel or by using the CoreAPI.

Final test

As a summary I decided to test if the documents are available in the shards created by the SPLITSHARD action. In order to do that I’ve used the following command:

And Solr responded in the following way:

As you can see documents came from both shard, which is again what we expected. Please remember that this is only a sample usage and we will get back to shard split topic for sure.

8 thoughts on “Solr 4.3: shard splitting quick look

  • 16 May 2013 at 06:23

    This article is clear and really useful. I indexed the documents as u specified. But when I execute the command “localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=collection1&shard=shard1” the command runs successfully and shards also created.But the documents are not moved inside the shards.anything am I missing?

    • 16 May 2013 at 07:22

      Did you try running the commit after the split ended ?

  • 16 May 2013 at 18:51

    This is a great article – can I re-post this on for the Lucene/Solr community? Of course I’ll link back to you and this original article.

    • 16 May 2013 at 19:01

      Sure, please re-post, we don’t have nothing against it.

  • 17 May 2013 at 19:15

    Great. Thanks.

    All I have for your name is “gr0” can you email me your name so I can add it to the post?

    • 5 July 2013 at 10:38

      Not sure what you are trying to achieve. Could you be more specific?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.