Skip to content
The Bits That Byte
  • About
August 28, 2019 / Sitecore

Sitcore 9 SolrCloud Custom Index/Alias Error

If you are adding custom Solr collections/indexes to SolrCloud in Sitecore 9, it is important to note that the parameter order matters in your patch config (always use a patch config). Without the proper order, you are likely to receive the following error:

The remote server returned an error: (400) Bad Request

[SolrConnectionException: <?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">41</int></lst><str name="Operation createalias caused exception:">org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Can't create collection alias for collections='mycustom_web_index_MainAlias', 'mycustom_web_index_MainAlias' is not an existing collection or alias</str><lst name="exception"><str name="msg">Can't create collection alias for collections='mycustom_web_index_MainAlias', 'mycustom_web_index_MainAlias' is not an existing collection or alias</str><int name="rspCode">400</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.common.SolrException</str></lst><str name="msg">Can't create collection alias for collections='mycustom_web_index_MainAlias'

An example patch config that would generate such an error has the collection parameters first, when it needs the alias parameters first:

Important: This patch example is wrong per Sitecore as it needs the parameters in another order (more on the solution below!)

<index id="mycustom_web_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrCloudSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="collection">$(id)</param>
            <param desc="rebuildcollection">$(id)_rebuild</param>
            <param desc="mainalias">$(id)_MainAlias</param>
            <param desc="rebuildalias">$(id)_RebuildAlias</param> 

How to Fix the “Can’t Create Collection Alias for Collections” Error

The Sitecore documentation located at the following clearly defines a few key items: https://doc.sitecore.com/developers/90/platform-administration-and-architecture/en/switch-solr-indexes.html#UUID-7ae69678-7ac3-d0db-09d2-3937aacdf677_N1530083724083

  • You need to have the ContentSearch.Solr.EnforceAliasCreation setting to true. This should be within a patch file and can look something like the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"
               xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore search:require="Solr">
    <settings>
      <setting name="ContentSearch.Solr.EnforceAliasCreation" set:value="true" role:require="ContentManagement or Standalone" />
    </settings>
  </sitecore>
</configuration>
  • You need to ensure that the patch file used on the CMS is different than the CDS (including the name spaces). The example patch for the CMS should look as follows (note: Sitecore does not provide a full example in their documentation… including that you need the name parameter in your include file).

    Important: Only change the index id= line as Sitecore appears to be looking for the _MainAlias and _RebuildAlias names (much like how it looks for the xdb_internal alias and if you attempt a different alias name it fails).
<index id="mycustom_web_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrCloudSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>            
            <param desc="mainalias">$(id)_MainAlias</param>
            <param desc="rebuildalias">$(id)_RebuildAlias</param>            
            <param desc="collection">$(id)</param>
            <param desc="rebuildcollection">$(id)_rebuild</param>
	    <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
  • For the CD Server, the patch file section would look something like the following. Note that the name space is different:
<index id="sitecore_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
  <param desc="name">$(id)</param>
  <param desc="core">$(id)_MainAlias</param>
  <param ref="contentSearch/indexConfigurations/databasePropertyStore" 
desc="propertyStore" param1="$(id)" />
  • Make sure that you define an active index update strategy in your patch config when using the SwitchOnRebuildSolrCloudSearchIndex

Post navigation

Previous Post:

Marketing Definitions error deploying the definitions in Sitecore PaaS 9.0.2 and 9.1.0

Next Post:

How to Manage Log Retention in Sitecore 9 (including xConnect)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sitecore Technology MVP

Categories

  • AngularJS
  • Azure
  • CSS3
  • HTML5
  • Hyper-V
  • JavaScript
  • jQuery
  • OneDrive
  • PowerShell
  • Responsive Web Design
  • Search
  • SEO
  • SharePoint
  • Sitecore
  • SQL 2008 R2
  • SQL 2012
  • Tech Review
  • Tech Toy
  • Technical Resources
  • Uncategorized
  • Visual Studio
  • Web Content Management
  • Windows 8
  • Windows 8 App
  • Windows App
  • Windows Server 2008 R2
  • Workflow

Recent Posts

  • Sitecore Release Governance for Better Production Stability
  • 11 Tips for a More Stable Sitecore PaaS Environment
  • Sitecore Commerce 10.0.0 Bootstrap 404 Error and Other Changes
  • How to Run Cost Effective Sitecore Environments in Azure
  • Autofail: A Big Azure Autoscale Limitation and What To Do

Blogroll

  • Colins Sitecore Tech Blog
  • Sitecore Architecture – Grant's Sitecore Rants
April 2021
M T W T F S S
 1234
567891011
12131415161718
19202122232425
2627282930  
« Mar    
© 2021 thebitsthatbyte.com - Powered by SimplyNews