# Walkthrough: Setting up Solr

Abstract

Learn how to set up Solr on Sitecore

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 website has information about more advance Solr setup. Sitecore 9.3 supports Solr 8.1.1 version.

### Note

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 Apache Solr wiki hosted there is especially useful.

### Note

You must use a separate core for each index. The Apache Solr wiki provides an introduction to the concept of multiple cores.

## Configure Solr to work with Sitecore

Sitecore uses managed schema as the default schema in Solr.

### Note

In Sitecore 9.3, support for the classic schema configuration is deprecated and it will be removed completely in a later Sitecore version. Later in this walkthrough you can find how to configure Solr using classic scheme.

To modify the example configuration in Solr to use it with Sitecore, follow these steps:

1. Copy the configuration example folder provided by Solr called _default from the [SOLR_DIR]/server/solr/configsets folder to the [SOLR_DIR]/server/solr folder.

2. Create a text file called core.properties in the folder you created ([SOLR_DIR]/server/solr/[CORE_NAME]), and specify these values:

name=[CORE_NAME]
config=solrconfig.xml
update.autoCreateFields=false
dataDir=data

To configure the managed schema, follow these steps:

1. Open the managed schema file in the conf subfolder of the folder you created.

2. Set the value in the <uniqueKey>id</uniqueKey> node to _uniqueid (for example, <uniqueKey>_uniqueid</uniqueKey>).

3. In the fields section, add field configuration for _uniqueid:

<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>

You must configure all Solr indexes for Sitecore in the same way. The list of indexes Sitecore uses is in The indexes used by Sitecore.

These are the indexes of the when you use xDB:

## Run Solr

When you have created cores, restart the Solr instance. To verify that Solr is running correctly:

1. Open the administration page at https://<host>:8983/solr:

2. Check the Logging section for any errors in the logs.

3. Open the Core Admin section to verify the available cores. These cores are created automatically because you specified them in the core.properties file. It is crucial that you use the correct core names in the configuration files. The names are case-sensitive. If you use the default names, you do not need to change the configuration.

## Configure Sitecore to work with Solr

This section describes how to configure Sitecore to work with Solr. Follow these steps:

1. To specify the correct connection string to Solr for the Sitecore instance, open the \Website\App_config\ConnectionStrings.config file and inspect the solr.search connection string. It should look like this example:

<add name="solr.search" connectionString="https://localhost:8983/solr">
2. To specify the search provider, open the Web.config file. and inspect the search:define key. It should look like this:

<add key="search:define" value="Solr" />
3. In the \Website\App_config\Sitecore\ContentSearch\Sitecore.ContentSearch.config file, the value of the <setting name="ContentSearch.SearchMaxResults" value="1000000" /> specifies the maximum number of documents retrieved in a single request if the number has not been specified in the query. The default is 1000000. In most cases, you do not need to change this. Patch this value if you need to change it.

4. In the \Website\App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file, the value of the <setting name="ContentSearch.Update.BatchModeEnabled" value="true" /> specifies if commits are in batch mode. This reduces the network traffic between the CM server and the Solr server. The value of the <setting name="ContentSearch.Update.BatchSize" value="500" /> setting specifies the number of document updates in a batch. Batch mode is on by default. If your index is very large, you can patch the batch size setting to a larger number to improve performance.

5. Specify custom names for Solr cores.

By default, Sitecore looks for predefined index names in Solr. For example, the predefined name for the master index is sitecore_master_index. If have not changed, you do not need to do anything.

If, however, you have named the indexes yourself, you must patch the configuration to reflect this. The value of the <param desc="name">\$(id)</param> in the \website\App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.Index.Master.config file specifies the custom index name, for example <param desc="name">sc93_sitecore_master_index</param> for an index called sc93_sitecore_master_index. This a full list of files where you must specify custom index:

Sitecore.ContentSearch.Solr.Index.Core.config
Sitecore.ContentSearch.Solr.Index.Master.config
Sitecore.ContentSearch.Solr.Index.Web.config
Sitecore.ContentTesting.Solr.IndexConfiguration.config
Sitecore.FXM.Solr.DomainsSearch.Index.Master.config
Sitecore.FXM.Solr.DomainsSearch.Index.Web.config
Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Master.config
Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Solr.Index.Web.config
Sitecore.Marketing.Solr.Index.Master.config
Sitecore.Marketing.Solr.Index.Web.config
Sitecore.Personalization.Solr.IndexConfiguration.config

The files are in subfolders under \website\App_config\sitecore. There are two places in the Sitecore.ContentTesting.Solr.IndexConfiguration.config where you must specify the index name.

## Populate the Solr schemas

When you have Solr running and have configured Sitecore, you populate Solr schemas with Sitecore fields.

To populate the schemas:

1. In Sitecore, go to the Control Panel and click Populate Solr Managed Schema.

2. Select all indexes and click Populate:

The Schema Populate tool populates the schema with the Sitecore files it needs.

You can add more fields to the schema by adding fields to the managed-schema file but do not change the system index fields. We recommend that you only do this after you have populated the Solr schema with the tool. You can use the solr admin schema page to add additional fields.

## Rebuild search indexes

Before you can start using Solr for indexing, you must re-index Sitecore content. To rebuild the search indexes:

1. In Sitecore, go to the Control Panel and click Indexing manager.

2. Select all indexes and click Rebuild:

## Configure Solr with a classic schema

Classic schemas are deprecated in Sitecore 9.3, and will not be supported in later versions of Sitecore. If you still need to configure Solr with a classic schema, follow these steps:

1. Copy the configuration example folder provided by Solr called _default  from the [SOLR_DIR]/server/solr/configsets folder to the [SOLR_DIR]/server/solr folder, and give the copied folder the same name as the appropriate index.

2. In the folder you copied, rename the managed-schema file schema.xml.

3. In the solrconfig.xml file, add this in the <config> section:

<schemaFactory class="ClassicIndexSchemaFactory"  />
4. In the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file, addthe SolrSchemaClass value from managed to classic:

<setting name="ContentSearch.Solr.SolrSchemaClass" value="managed" />
5. Start (or restart) Sitecore, and go to the Control Panel. Click Generate the Solr Schema.xml file.

6. Generate the schema.xml file with source file and target file specified like this:

• Source file: C:\[SOLR DIR]\ server\solr\[CORE_NAME]\conf\schema.xml

• Target file: C:\[SOLR DIR]\ server\solr\[CORE_NAME]. The target file must be different from the source file.

7. Move the generated schema.xml file from the target to the source location.

8. Create a text file called core.properties in the folder you created ([SOLR_DIR]/server/ solr/[CORE_NAME]), and specify the following values in the file:

name=[CORE_NAME]
config=solrconfig.xml
update.autoCreateFields=false
dataDir=data
9. Create index folders for all other indexes in the current folder, C:\[SOLR DIR]\ server\solr\[CORE_NAME]\.

10. Start Solr and verify it runs correctly.

## The indexes used by Sitecore

This section lists the indexes Sitecore uses.

With xDB:

sitecore_core_index
sitecore_master_index
sitecore_web_index
sitecore_marketingdefinitions_master
sitecore_marketingdefinitions_web
sitecore_marketing_asset_index_master
sitecore_marketing_asset_index_web
sitecore_testing_index
sitecore_suggested_test_index
sitecore_personalization_index
sitecore_fxm_master_index
sitecore_fxm_web_index

Without xDB:

sitecore_core_index
sitecore_master_index
sitecore_web_index