June 26, 2015

Run Multiple Solr Instances for Sitecore

By: Craig Taylor
June 26, 2015

Run Multiple Solr Instances for Sitecore

At Arke, we have recently made the switch to recommending Solr as the 'default' indexing solution for Sitecore rather than Lucene.  If you're wondering which to use on your project, please see Sitecore's document on when to use Solr over Lucene.

Switching to Solr

There was a little pain involved in switching from Lucene to Solr for an active project, but luckily, my co-worker, Patrick Perrone had already been down the path of getting Solr running on his Windows machine and provided an excellent step-by-step guide on how to make it work.  If you haven't already, see his 3-part series on Making Sitecore 8 and Solr Work Together.

Thanks to Patrick, getting Solr running was a breeze.  This worked great for my active project, but now I'm starting up new projects where Solr will be the indexing mechanism from day 1.  How will I separate client Solr cores from one another?

Installing Multiple Instances of Solr on your (Windows) Machine

Patrick's install guide works great when you're only going to be running a single instance of Solr, but in order to get a second instance of Solr running on my machine, I had to make some minor modifications.

Note: These steps assume you already have a solr instance up and running with the proper Sitecore-generated schemas.  If you haven't followed all the steps to get Solr running with Sitecore, please do those first to save a bit of configuration time on your cores later.

  1. Stop your Tomcat service.

  2. I installed my Solr directory at C:\Solr and all my standard Sitecore and custom cores were then in directories under there.  In order to clean things up, I created a new folder named ClientName1 that would now contain the cores for that client.  Go ahead and create a folder named ClientName2 while you're here for the project you are starting up.

  3. Once created, pull all the content from the root of C:\Solr into this new ClientName1 folder.

  4. Since the original cores were already configured to work with Sitecore, it's a simple matter of copy/pasting all the cores into a second client folder.  Copy all the files from the root of ClientName1 and paste them into ClientName2.  At this time, you should remove any custom cores that were defined specifically for client 1.  You can leave all the Sitecore cores as we're going to rebuild them as a final step anyways to get client 2 data into them.  Your Solr root should now just have client folders in it, nice and clean-like.

  5. Go into your 'Monitor Tomcat' tool and remove the Java Options you set as part of the initial configuration of Solr.  In my case, I removed Dsolr.solr.home=C:\Solr  This option tells Tomcat where the home Solr directory is, but it assumes there is only one instance running.  Our next steps will define the multiple home directories.

  6. Move the solr.war file out of the root of your ...\Tomcat 8.0\webapps\ directory.  In my case, I moved the solr.war file up one directory from C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps to C:\Program Files\Apache Software Foundation\Tomcat 8.0\  Having the war file in the webapps directory is another indicator to Tomcat that it's only running a single instance and it will ignore the configuration files we are going to set in the next step.

  7. Go to your \Tomcat 8.0\conf\Catalina\localhost directory and create new XML config files for each client.  I named mine solr-<clientNameX>.xml  Note that this filename will be how you access your Solr cores in the browser.  In this case, I'll access my two clients by http://tomcat:8081/solr-clientName1 and http://tomcat:8081/solr-clientName2.  You can name them whatever you like, but the contents should look like this:

    <Context docBase="C:\Program Files\Apache Software Foundation\Tomcat 8.0\solr.war" debug="0" crossContext="true" >
        <Environment name="solr/home" type="java.lang.String" value="C:\solr\ClientName1" override="true" />
    </Context>
    

    Here, you are referencing the path to the solr.war file that we moved and are setting the Solr home directory to where all your cores are for this client.

  8. Copy the XML file you just created and paste it to create the XML file for ClientName2. Edit the file and change the path to from the C:\solr\ClientName1 directory to the ClientName2 directory.

  9. Start your Tomcat service back up.

  10. Navigate to http://tomcat:8081/solr-clientname1 and http://tomcat:8081/solr-clientname2 and verify that both instances are running. (using the port number used when configuring Solr and the file names for the XML configs you defined)

  11. Edit your ContentSearch.Solr.ServiceBaseAddress setting in the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file to point to the correct new instance of Solr.

  12. Once running, go back to your Sitecore instances and rebuild your indexes!
You can now safely run Solr on multiple projects and have confidence that each client's cores will not be mixed up with one another.

June 18, 2015

Sitecore 8 Bug: Link Sets Anchor Target to Active Browser

By: Craig Taylor
June 18, 2015

Links be broke
We recently ran into an issue while trying to render links set in Sitecore 8 (Update 3, to be specific).  When using the "General Link" field to insert a link, we discovered that the "target" options for the link were incorrect.  The options provided out of the box were "Active Browser", "Custom" and "New Browser":

Original Link Target Options


One would assume that "Active Browser" would set the target of the anchor tag to "_self" or "_top" so that it opens in the same window.  Unfortunately, what happens is that Sitecore literally puts "Active Browser" in the target attribute, which is not valid and ends up actually opening a new window/tab.

Workaround/Fix

I opened a support ticket with Sitecore and they acknowledged this as a bug and it should be fixed in a future release.

In the meantime, you can adjust the settings of the "Link Details" box to display new target options as follows:

  1. In the "Core" database, navigate to the "/sitecore/client/Applications/Dialogs/InsertLinkViaTreeDialog/PageSettings/TargetsSearchPanelConfig" item.
  2. In the "Root" field of the "Filters" section, specify the "sitecore/client/Business Component Library/System/Texts/Targets" item. (default is "sitecore/client/Applications/Dialogs/InsertLinkViaTreeDialog/PageSettings/Targets")
Now, when you insert a link, you see target options that will work when rendered in the browser: "_blank", "_parent" and "_top":

Updated Link Target Options
Note: If you already had links set to "Active Browser", leaving the default of "SelectTarget" will still render the target as "Active Browser."  You need to open the "Insert Link" option, select "Insert" and then save the item for it to use the proper value.