Walkthrough: Setting up Solr
This walkthrough describes how to set up Solr for use with Sitecore. It does not cover all configuration options available in Solr: it only documents configuration details specific for using Solr in Sitecore.
The Solr server that hosts your Content Search cores can be different from the server that hosts your xDB Search Index core.
Follow the instructions in the Solr documentation to install Solr. The Solr website lists resources. The wiki hosted there is especially useful.
You must use a separate core for each index. This topic on the Solr wiki introduces the multiple core concept.
This walkthrough describes how to:
- Populate an XML schema for Solr
- Generate an XML Schema for Solr
- Verify that Solr is running correctly
- Configure Sitecore to work with Solr
- Rebuild the search Indexes
Populate an XML schema for Solr
You must enable a Solr search provider in Sitecore before you populate an XML schema. The Enabling a Search Provider setting in the Web.config file tells Sitecore that Solr is enabled and Sitecore attempts to connect to the Solr server the next time the index is accessed:
Solr uses a defined schema when it works with documents. You can modify an existing schema with the Populate Solr Managed Schema tool. This tool automatically populates Sitecore fields and makes sure all fields that Sitecore needs are present.
You can add more fields to this schema by adding fields to the managed-schema file as long as you do not change the system index fields. We recommend that you only do this after you have populated the Solr schema with the Populate Solr Managed Schema tool. You can use the solr admin schema page to add additional fields.
Follow these steps to populate a Solr schema:
-
Copy the Solr-provided configuration example folder called
_default(orbasic_configsin older Solr versions) from the[SOLR_DIR]/server/solr/configsetsfolder to the[SOLR_DIR]/server/solrfolder, and name the copied folder the same as the appropriate index name. -
Create a text file called
core.propertiesin the folder you created ([SOLR_DIR]/server/solr/[CORE_NAME]), and specify the following values: -
Open the
managed-schemafile under theconffolder of folder created in step 1.- Set the value in
<uniqueKey>id</uniqueKey>to_uniqueid. - In the
fieldssection, add field configuration for_uniqueid:<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/> - Save your changes.
- Set the value in
-
Repeat step 1 and step 2 for all content search indexes.
NoteDo not do this for xdb indexes. Follow this description instead.
-
Start Solr.
-
Start Sitecore, and go to the
Control Panel. -
In the Schema Populate window, select the indexes you want to populate:

-
Click Populate.
Generate an XML Schema for Solr
It is possible to use manual schemas (the "classic" way) by using a Solr schema.xml file:
- In the
Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.configfile, change the value of theContentSearch.Solr.SolrSchemaClasssetting toclassic. - Set the
<schemaFactory>class toClassicIndexSchemaFactoryin thesolrconfig.xmlfile.
Earlier versions of this topic have more information.
Verify that Solr is running correctly
After populating a new schema.xml file and updating the solrconfig.xml file, you must verify that Solr runs correctly.
To verify that Solr is running correctly:
-
Ensure Solr is not running. A full restart is needed so that it loads the new configuration.
-
Start Solr.
-
Check the output log files. If there are no errors, then open the Solr administration page.
To open the administration page, enter the following URL in your browser: http://localhost:8983/solr/admin:

-
Click Core Admin and then click a core. In this example, there is one core, called
itembuckets:
If you can see the Solr administration page and do not get any errors in the log files, then Solr is running correctly.
Configure Sitecore to work with Solr
The solr.search connection string specifies where the Solr server is located.
This example specifies the default Solr location:
The following Solr specific settings can be found in the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file.
-
Enabling a Search Provider
This setting tells Sitecore that Solr is enabled and so attempts to connect to the Solr server the next time the index is accessed. If it cannot connect you get an error.
<setting name="ContentSearch.Provider" value="Solr" /> -
Maximum Number of Search Results
This is a global setting found in the
Sitecore.ContentSearch.configfile.This setting contains the maximum number of documents to retrieve on a single request if a limit has not been specified in the query, for example, Take(10). It is important to remember, for performance reasons, when querying how many results will be returned from the query being run and to handle them correctly, for example by using paging.
<setting name="ContentSearch.SearchMaxResults" value="500" /> -
Enabling Batch Mode
When an item is indexed the composed document is saved to the search index. When the default Lucene provider is enabled then each write is being flushed to a file on the local disk. When a document is written using the Solr provider the update has to travel over a network.

When an index is rebuilt a large number of document updates are created, this could result in a lot of network traffic which is not very efficient. Therefore using batch can help to optimize the update process as your indexes grow in size.
<setting name="ContentSearch.Update.BatchModeEnabled" value="true" /><setting name="ContentSearch.Update.BatchSize" value="500" />Batch mode (enabled by default) takes these document updates and only flushes to the Solr server when the batch has reached a certain size.

As your index grows you may want to increase this batch size to gain the most out of this process.
Rebuild the search Indexes
Before you can start using the Solr indexing system, you must re-index Sitecore content.
To rebuild the Sitecore search indexes:
-
In the Control Panel, click Indexing manager.

-
Select Select all, and then click Rebuild.
NoteIf you deployed marketing definitions before, it is not necessary to select the marketing definitions indexes as they are already rebuilt.
