Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Solr into Sitecore

I have to implement Solr index into Sitecore and I would like to know what is the best approach?

I looked at following approaches:

  1. Capture publish end event (or other events) and then push item to solr index
  2. Implement custom database crawler and get all changes from history table. Then using custom index push data to solr.

Second approach sounds like a way to go (in my opinion). In this case do I need to create a new search index, or search manager?

If anyone's done it before, can you point me into the right direction? Also if you could post some links to articles about sitecore-solr implementation.

UPDATE Ok, after reading sitecore documentation this is what I came up with :

  1. Create your custom SolrConfiguration class where you can set properties like solrserviceurl, add indexes and its definition (custom solr indexes)

  2. Create SolrIndex and add it (in the config file) to your SolrConfiguration. Which instantiating, solrindex should subscribe to AddEntry event of Sitecore History Manager, and communicate with solr crawlers.

  3. Create custom processor and hook into sitecore initialisation pipeline. Processor should initialize SolrConfiguration (from step 1)

  4. Since everything in your config file in will be build using refrection, you can get instance of your cofiguration based on your config file

How does that sound like. Can I have any comments please?

like image 942
Sebastian Siek Avatar asked Aug 21 '12 09:08

Sebastian Siek


People also ask

How Solr works in Sitecore?

Populate an XML schema for SolrThis tool automatically populates Sitecore fields and makes sure all fields that Sitecore needs are present. You can add more fields to this schema by adding fields to the managed-schema file as long as you do not change the system index fields.

Why Solr is used in Sitecore?

General reasons for using Solr or Lucene search engines. Sitecore supports both Lucene and Solr search engines. The search engines are used for searching in the content databases, as well as for searching in a number of operational databases that Sitecore uses for collecting analytics data, test data, and so forth.


1 Answers

We've done this on a few sites and tend to have a new "published" solr index and "unpublished" index

We interrupt:

OnItemSaving

Event to push things into the unpublished index (you may not need this, it depends if you want things in preview mode)

OnPublishItemProcessed

We process additions and updates to the published index here, I'm not sure what we do about deletions here without digging right into the code but certainly deal with deletions on the OnItemDelete (mentioned below)

OnItemDelete

We interrupt here to remove things from the published and non-published index (I think we remove from the published index here because Sitecore makes you publish the parent node in order to publish out deletions to the web database)

I hope that helps, I'd post the code if I could (but I'd be scowled at).

like image 131
Steve Newstead Avatar answered Sep 17 '22 11:09

Steve Newstead