Friday, 11 November 2016

Part 2: Sitecore 8.2 with SOLR 6.2

Leave a Comment
Hello, Sitecore enthusiasts! This is the second article of Sitecore 8.2 with Solr 6.2 blog series.

Configuring Solr to use with Sitecore

Generate an XML Schema for Solr

Solr needs a defined XML schema when working with documents. Follow below steps to generate Solr Schema XML file:
  1. Duplicate basic_configs folder under C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets and rename duplicated folder as sitecore_configs.
  2. Verify that that you have a file named schema.xml under the C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs\conf folder. If you don't have a schema.xml file under the folder then you will need to perform below extra steps, as explained in solution 2 of the Solr Compatibility Table:
    • Create schema.xml file by duplicating and renaming the managed-schema file present in C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs\conf folder
    • Switch to ClassicIndexSchemaFactory by adding the following line in the end to the SolrConfig.xml file present in C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs\conf folder:
      <schemaFactory class="ClassicIndexSchemaFactory" />
  3. Open schema.xml file and make the following changes:
    • Enclose all <field> and <dynamicField> elements in a <fields> tag.
    • Enclose all <fieldType> elements in a <types> tag.
  4. Save schema.xml and also create a backup file of schema.xml.
  5. Log into your Sitecore instance.
  6. Navigate to Sitecore Control Panel.
  7. In the Control Panel, click Generate the Solr Schema.xml file link in Index section.
  8. In the dialog window, change the source file and target file to point to the newly created schema file (C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs\conf\schema.xml) and click the ‘Generate’ button.
  9. Sitecore will create a modified schema.xml file, using the schema.xml file we created as a baseline in above steps and add all its necessary Solr specific fields needed for indexing, unique keys etc. 
  10. Open the newly generated schema file (C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs\conf\schema.xml) and add below line:
    <fieldType name="pint" class="solr.TrieIntField" docValues="true" precisionStep="0" positionIncrementGap="0" />

Organize Solr core structure

  1. Copy the sitecore_configs (C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr\configsets\sitecore_configs) folder and paste it in C:\Bitnami\solr-6.2.1-2\apache-solr\server\solr. Rename it to the sitecore_web_index.
  2. For each Sitecore index, we need to repeat above step 1 until we have a set of config directories with the following names:
    • sitecore_web_index
    • sitecore_master_index
    • sitecore_core_index
    • sitecore_analytics_index
    • social_messages_web
    • social_messages_master
    • sitecore_marketing_asset_index_master
    • sitecore_marketing_asset_index_web
    • sitecore_testing_index
    • sitecore_suggested_test_index
    • sitecore_fxm_master_index
    • sitecore_fxm_web_index
    • sitecore_list_index
    • sitecore_marketingdefinitions_master
    • sitecore_marketingdefinitions_web
  3. Once you have configured all the directories, navigate to the Solr admin page.
  4. After login, navigate to Core Admin page and click on Add Core button.
  5. Fill in the 'name' and 'instanceDir' fields with sitecore_web_index, and press the "Add Core" button to add the core into Solr. 
  6. You should be able to see that sitecore_web_index core is now present in the list of cores available in your Solr instance.
  7. Repeat these steps for all directories created earlier so that we'll have a Solr core for each directory we created.

That's it! Solr is ready to be used with Sitecore. Comments and suggestions are most welcome. Happy coding!


Post a Comment