#Sitecore Lucene to SOLR Index Upgrade Tips

Recently I did a Lucene to SOLR upgrade. Even though SOLR has been out a while you may still run into instances that you may need to upgrade. This I hope gives you a small guide on some of the things you need to do other than installing the SOLR server.

1. Turn on switch and rebuild on indexes. You can find more information about that here. Don’t forget to add your custom indexes as well.

2. Convert string to string[]. I ran into an issue where a field was coming back with a null. Looking at the SOLR server and doing a query I found that the following would come back as null.

["27ae232e906349b083d612f2ebb7a173", "3fd1ef6aac954936bb8133d5f60ebfee", "9b8e4140b9fe4ecb99c41e0454b31b2e"]

Looking at it further found that the following code needed to be changed.

From:
  [IndexField("tags")]
  public string Tags { get; set; }
To:
  [IndexField("tags")]
  public string[] Tags { get; set; }

Basically the string needed to be a string array.

3. Make sure you check the class references.

From:
Sitecore.ContentSearch.LuceneProvider.LuceneSearchIndex, Sitecore.ContentSearch.LuceneProvider
To:
Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider

4. Don’t forget to rebuild the indexes and make sure everything you expect is there.

On a side not every time I hear SOLR I think of this movie.

Keeping #Sitecore #SOLR Index Names Unique for Multiple Projects

One of the things I recently ran into was what should you do if you have multiple projects with the same SOLR index name. SOLR does not allow you to have the same name for an index. For instance you can’t have more than one sitecore_master_index. You will be warned and unable to if you try and create one with the same name. Also if you rebuild the indexes it will overwrite the index data for the other site you were working on. So I went on Sitecore Slack looking for help. Where Sitecorey gave me a great idea. Basically you would prefix the configuration entry core with the name of the site in each index file. See below for an example.

Your index name should reflect that name as well in the SOLR index directory.

Now this did solve the issue of having multiple indexes, but a few people on the team wanted to take it a step further. They wanted to see indexes prefixed with site name from the control panel index rebuild. So I created a config transform this time for it. Keep in mind this is always a smart idea to keep the original files safe. Basically I just replaced the id value.

From my understanding the SIM installer can also help with the prefixing of index names. I haven’t used it for that yet as my site was already installed, but in the future that is something I will consider. Let me know if you have any questions.

Making the #Sitecore Switch from #Lucene to #SOLR with Custom Indexes

Recently I did my first conversion from Lucene to SOLR. With Lucene being phased out in Sitecore 9 this will probably be more common. You can find a lot of different installation guides in installing SOLR, but there are a few things that tripped me up that I want to prevent others from having to deal with.

Avoid Pitfalls

  • Make sure every Lucene config is disabled. Even the ones in the sub folders.
  • Make sure all the SOLR configs are enabled even the ones in the sub folders.
  • Make sure you don’t have any Cores with the same name inside the core.properties file. I had Sitecore_Master_Index in more than one file and all my Cores would disappear every time I restarted until I corrected the name.

Custom Indexes Differences

Some of this is obvious as you can replace Lucene with Solr, but some were not so obvious to me and I had to do some research and ask for help. I highlighted the less obvious ones.

From this:

<index
id=acme_widgetgroups_index” type=Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider>

To this:

<index
id=acme_widgetgroups_index” type=Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider>

From this:

<configuration
ref=contentSearch/indexConfigurations/defaultLuceneIndexConfiguration>

To this:

<configuration
ref=contentSearch/indexConfigurations/defaultSolrIndexConfiguration>

From this:

<fieldMap
type=Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch>

To this:

<fieldMap
ref=contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap>

From this:

<field fieldName=widgetfilters” storageType=YES” indexType=TOKENIZED” vectorType=NO” boost=1f” type=System.String” settingType=Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider />

To this:

<field fieldName=widgetfilters” returnType=string />

From this:

<documentOptions
type=Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilderOptions, Sitecore.ContentSearch.LuceneProvider>

To this:

<documentOptions
type=Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider>

I hope this helps you as you do your conversion. If you have any questions, feel free to ask.