Adventures with Solr: Part 1

So, for the last few months I've been engaged on a project that doesn't use Sitecore, but was instead heavily focused on Solr, the Apache search platform providing content search for a lot of modern Sitecore instances (and more or less required for Sitecore 9, unless you go down the Azure search route). For the next couple of posts I'm going to talk about ways of working with Solr in .NET.

When developing Sitecore instances you rarely work within Solr itself; typically as a developer you're adding computed index fields, altering index update configs etc. Solr does actually provide a variety of means by which to update, monitor and work on your cores, alter your installation of solr itself, and execute queries within the UI.

Modifying the installation

Chances are that, if your installation is on a Windows server, you started Solr using the bundled solr.cmd file something like this:

solr.cmd start


It is typically found at \your-solr-installation-dir\bin\solr.cmd. Unsurprisingly, you can stop solr using:

solr.cmd stop


If you need to specify a port, your argument is as follows:

solr.cmd start -p 8983

There are plenty of arguments you can use to tailor your installation. For eaxmple:

  • -h allows you to specify a hostname
  • -s allows you to specify the directory that your solr cores will be installed into
  • -f starts solr in the foreground

One argument that came in handy was the ability to specify the size of the JVM heap allocation as Solr in its default installation will rapidly start hitting java.lang.OutOfMemoryError exceptions once you start putting it through its paces. To do this, try something like:

solr.cmd start -f -p 8983 -m8g

Where -m sets both the min and max heap size for the JVM (8GB). By default, solr is allocated 512MB.

Core stuff

Core creation/deletion/alteration is really simple too, and readily achievable through the cmd prompt.

solr.cmd create -c your-core-name -p 8983


And again to remove it, just do this:

solr.cmd delete -c your-core-name -p 8983


Cloud stuff

If you were installing solr in cloud mode, you'd do the following:

solr.cmd start -cloud

The cloud install will also start an Apache Zookeeper instance at whatever port you specified +1000, typically 9983 if using the default port. If unfamiliar with solr cloud installs, I recommend also adding the -e argument, which runs you through an example setup with prompts to add shards and replicas and configurations to your installation via solr's API.

More on this at

If you're working with Zookeeper, there's a helpful CLI to allow you to interact directly with your configuration files stored in Zookeeper. More on this at>


After a while it becomes easier to have solr installed as a windows service; I recommend using the NSSM (non-sucking service manager) for this. Once you have nssm you're able to inspect the service by navigating to your nssm directory (by default) C:\Program Files\nssm-2.24\win64 and in cmd calling nssm edit <servicename>. Just entering nssm will yield the list of usages to explore.


Solr, farewell

In the next posts, I'll discuss using Solr's API, and getting into SolrNet, the most popular Nuget package for working with Solr in .NET applications.