You are on page 1of 8

8/28/2019 Walkthrough: Setting up Solr

Other documentation for 9.2

Walkthrough: Setting up Solr


Current version: 9.2

This walkthrough describes how to set up Solr for use with Sitecore. It does not cover all con guration
options available in Solr: it only documents con guration details speci c for using Solr in Sitecore.

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 wiki[http://wiki.apache.org/solr/] hosted there is especially useful.

Note

You must use a separate core for each index. This topic[http://wiki.apache.org/solr/CoreAdmin] on


the Solr wiki introduces the multiple core concept.

This walkthrough describes how to:

Populate an XML schema for Solr[walkthrough--setting-up-solr.html#UUID-71d33faa-48fb-ca6d-7c52-


f69641fb1112_N1528811068737]

Generate an XML Schema for Solr[walkthrough--setting-up-solr.html#UUID-71d33faa-48fb-ca6d-7c52-


f69641fb1112_N1528811088643]

Verify that Solr is running correctly[walkthrough--setting-up-solr.html#UUID-71d33faa-48fb-ca6d-7c52-


f69641fb1112_N1528438014638]

Con gure Sitecore to work with Solr[walkthrough--setting-up-solr.html#UUID-71d33faa-48fb-ca6d-7c52-


f69641fb1112_N1528725280956]

Rebuild the search Indexes[walkthrough--setting-up-solr.html#UUID-71d33faa-48fb-ca6d-7c52-


f69641fb1112_N1528438097356]

 Populate an XML schema for Solr

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 1/8
8/28/2019 Walkthrough: Setting up Solr

[#UUID-71d33faa-48fb-ca6d-7c52-f69641fb1112_N1528811068737_body]

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   le tells Sitecore that Solr is
enabled and Sitecore attempts to connect to the Solr server the next time the index is accessed:

<add key="search:define" value="Solr" />

Solr uses a de ned schema when it works with documents. You can modify an existing schema
with the Populate Solr Managed Schema tool. This tool automatically populates Sitecore elds
and makes sure all elds that Sitecore needs are present.

You can add more elds to this schema by adding elds to the managed-schema  le as long as
you do not change the system index elds. 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 elds.

Follow these steps to populate a Solr schema:

1. Copy the Solr-provided con guration example folder called _default (or
basic_configs in older Solr versions) from
the  [SOLR_DIR]/server/solr/configsets  folder to the [SOLR_DIR]/server/solr
folder, and name the copied folder the same as the appropriate index name.

2. Create a text le called core.properties in the folder you created


( [SOLR_DIR]/server/solr/[CORE_NAME] ), and specify the following values:

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

3. Open the managed-schema le under the  conf  folder of folder created in step 1.

a. Set the value in  <uniqueKey>id</uniqueKey>  to  _uniqueid .

b. In the  fields  section, add eld con guration for  _uniqueid : <field
name="_uniqueid" type="string" indexed="true" required="true"
stored="true"/>

c. Save your changes.

4. Repeat step 1 and step 2 for all indexes.

5. Start Solr.

6. Start Sitecore, and go to the  Control Panel .

7. In the Schema Populate window, select the indexes you want to populate:

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 2/8
8/28/2019 Walkthrough: Setting up Solr

8. Click Populate.

 Generate an XML Schema for Solr


[#UUID-71d33faa-48fb-ca6d-7c52-f69641fb1112_N1528811088643_body]

It is possible to use manual schemas (the "classic" way) by using a Solr  schema.xml   le:

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 3/8
8/28/2019 Walkthrough: Setting up Solr

1. In the   Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config   le,


change the value of the  ContentSearch.Solr.SolrSchemaClass  setting to  classic .

2. Set the  <schemaFactory>  class to  ClassicIndexSchemaFactory  in


the  solrconfig.xml   le.

Earlier versions of this topic have more information.

 Verify that Solr is running correctly


[#UUID-71d33faa-48fb-ca6d-7c52-f69641fb1112_N1528438014638_body]
After populating a new  schema.xml   le and updating the  solrconfig.xml   le, you must
verify that Solr runs correctly.

To verify that Solr is running correctly:

1. Ensure Solr is not running. A full restart is needed so that it loads the new con guration.

2. Start Solr.

3. Check the output log les. 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:

4. Click Core Admin and then click a core. In this example, there is one core,
called  itembuckets :

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 4/8
8/28/2019 Walkthrough: Setting up Solr

If you can see the Solr administration page and do not get any errors in the log les, then Solr is
running correctly.

 Con gure Sitecore to work with Solr


[#UUID-71d33faa-48fb-ca6d-7c52-f69641fb1112_N1528725280956_body]

The solr.search connection string speci es where the Solr server is located.

This example speci es the default Solr location:

<add name="solr.search" connectionString="https://localhost:8983/solr" >

The following Solr speci c settings can be found in


the  Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config   le.

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.config   le.

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 5/8
8/28/2019 Walkthrough: Setting up Solr

This setting contains the maximum number of documents to retrieve on a single request if
a limit has not been speci ed 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 ushed to a le 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 tra c which is not very e cient. 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 ushes 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


[#UUID-71d33faa-48fb-ca6d-7c52-f69641fb1112_N1528438097356_body]

Before you can start using the Solr indexing system, you must re-index Sitecore content.

To rebuild the Sitecore search indexes:

1. In the Control Panel, click Indexing manager.

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 6/8
8/28/2019 Walkthrough: Setting up Solr

2. Select Select all, and then click Rebuild.

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 7/8
8/28/2019 Walkthrough: Setting up Solr

Send feedback about the documentation to


docsite@sitecore.net[mailto:docsite@sitecore.net?Subject=Title : walkthrough--
setting-up-solr&body=Url: https://doc.sitecore.com/developers/92/platform-
administration-and-architecture/en/walkthrough--setting-up-solr.html]

Privacy policy[http://www.sitecore.net/Company/Contact/Privacy-Policy.aspx] ·
Legal notice[http://www.sitecore.net/Legal/Legal-Notice.aspx] · DMCA
Notice[https://pro le.sitecore.net:443/dmca_notice] · Copyright © 1999-2019
Sitecore[http://www.sitecore.net/Legal/Copyright.aspx]

https://doc.sitecore.com/developers/92/platform-administration-and-architecture/en/walkthrough--setting-up-solr.html 8/8

You might also like