Documentation Home



SolrStarter is a Spring Boot starter project written by Broadleaf Commerce to get you up and running quickly by providing an out of the box Solr solution perfect for development. If you have just gone through the Running Locally guide, then you probably noticed Solr being downloaded during startup. This project was responsible for that download and the default configuration that connects Broadleaf to Solr.

How it works

Startup and Shutdown

The SolrStarter module is activated by @EnableAutoConfiguration, which is included in the @SpringBootApplication annotation on each of the Community Starter's main application classes. @EnableAutoConfiguration finds the SolrStarter primary configuration class which registers the blAutoSolrServer bean with Spring. This bean is of type org.springframework.context.SmartLifecycle, which is a Spring extension point to hook into the lifecycle of the application. What this results in is a Solr service being downloaded if it hasn't been already, started up, and finally shut down along with the Spring application.

Solr Bean Configuration

While the SolrStarter module automatically ensures you have a Solr service running for you along with your application, it is not responsible for actually connecting your Spring application to the Solr service. This configuration is actually found in the ApplicationSolrConfiguration class within the core module of the Community Starter files you downloaded. In this class you'll find the bean definitions that are actually used by Broadleaf to consume Solr.

There are three properties that define the URLs pointing to the Solr service and drive the SolrClient bean definitions:

  • solr.url.primary=http://localhost:8983/solr/catalog
  • solr.url.reindex=http://localhost:8983/solr/catalog_reindex
  • solr.url.admin=http://localhost:8983/solr

There URLs match the default properties configured by SolrStarter so that by the time these beans are instantiated the server will be available and the SolrClient can connect.

These properties can be defined per-environment and combine well with option (2) in Disabling SolrStarter below.

Solr Configuration Files

When the SolrStarter starts the Solr service, it also copies a set of Solr configuration files, most importantly solr.xml, schema.xml and solrconfig.xml, to the Solr configuration directory. These files can be found within the SolrStarter project in resources/solr/standalone/solrhome by default. These files will be important later when we talk about moving to a production environment.

Disabling SolrStarter

SolrStarter can be disabled one of two ways.

  1. One way is to simply remove the broadleaf-boot-starter-solr dependency from your pom.xml files.

  2. Another way is to set the property solr.server.autoConfigEnabled to false in your properties files. This has the added benefit of selectively choosing which runtime environments use the SolrStarter and which do not.

Moving to production

While the SolrStarter is great for development, it isn't suited for production because it is not persistent. Additionally, in a production environment, you generally want Solr running on its own server or cluster of servers to provide maximum search performance for the application.

When setting up and configuring the Solr server, you will need to copy the relevant configuration files from SolrStarter's resources/solr directory to provide Solr with information on how to index Broadleaf's catalog data.

For standalone Solr setups you will want the catalog configuration files from resources/solr/standalone/solrhome/. Technically all of the files from this directory could be copied, but only the catalog files are relevant in a Community Starter project. Once this is done and the Solr server is up and running, you will need to configure the URL properties from above to point to the location of the Solr server.

Alternatively you could use a Solr Cloud cluster for maximum flexibility and power for your search services. While the configuration of a cluster is out of scope for this guide, you will need to follow some general steps to configure and utilize the cluster. First, instead of copying the standalone Solr configuration files from SolrStarter, you will want to copy from files located in resources/solr/cloud. Additionally, in your core module's ApplicationSolrConfiguration, you will need to define those beans as type CloudSolrClient instead of HttpSolrClient as connections to a Solr Cloud cluster are actually made to a Zookeeper service instead of directly to Solr.