1
votes

We just upgraded our 7.2 to 8.1 which uses lucene search provider. The website relies heavily on lucene for search and indexing the articles so that it can be displayed as a list.

We already have a SOLR instance setup. We need to get this Lucene converted to SOLR. Will appreciate if I get direction on below:

  1. How do we convert the custom computed lucene indexes and fields on to Solr?

  2. Apart from configurations on CORES and end points, are there any code changes etc. that we need to be careful of?

  3. How does the index rebuild event works in terms of SOLR. Do they (CDs) all try to build once or in sequence or only one triggers build.

UPDATE:

I switched to SOLR. I can rebuild all the CORES and web_index shows 11K documents. However the page doesn't return any results. Below is the code snippet, appreciate if I can get help on what I'm doing wrong. THis was working fine with Lucene:

public IEnumerable<Article> GetArticles(Sitecore.Data.ID categoryId)
        {
            List<Article> articles = null;

            var home = _sitecoreService.GetItem<Sitecore.Data.Items.Item>(System.Guid.Parse(ItemIds.PageIds.Home));

            var index = ContentSearchManager.GetIndex(new SitecoreIndexableItem(home));

            using (var context = index.CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
            {
                var query = context.GetQueryable<ArticleSearchResultItem>().Filter(item => item.Category == categoryId);

                var results = query.GetResults();

                articles = new List<Article>();

                foreach (var hit in results.Hits)
                {
                    var article = _sitecoreService.GetItem<Article>(new Sitecore.Data.ID(hit.Document.Id).ToGuid());

                    if (article != null)
                    {
                        if (article.ArticlePage != null && !article.ArticlePage.HideInNavigation)
                        {
                            articles.Add(article);
                        }
                    }
                }
            }

            return articles;
        }
1

1 Answers

5
votes
  1. The actual code for the computed field would probably not change. You would need to test that to make sure, but because Sitecore abstracts away the Lucene and SOLR code, as long as you are just making use of the Sitecore API it should work. You will need to change the config. In the Lucene index you add the computed fields in the defaultLuceneIndexConfiguration section. This will need to change to the defaultSolrIndexConfiguration

  2. Again, as long as you are making us of the Sitecore API exclusively and not using Lucene.net or Solr.net directly - most code should work fine. Some gotcha's that I have found.

    • Lucene is not case sensitive, SOLR is case sensitive. So some queries that may have worked fine on Lucene, may not anymore because of case sensitivity.
    • Be careful of queries that do not set a .Take() limit on them. Sitecore does have a default value for the max rows returned for a query, but on SOLR that can have a much bigger impact on query time than it does for Lucene because of the network round trips.
    • Another thing to think about with SOLR is the number of searches that take place. With Lucene, there is little impact in making many small calls to the index, as its local and on disk so very fast. With SOLR, those calls turn into Network traffic, so a lot of micro calls to the index can have a big performance impact.
    • As mentioned by mikaelnet: SOLR uses dynamic fields in the index. So each field has a suffix based on the field type. This shouldn't be a problem in most cases. The Sitecore API will automatically append the suffix to any IndexField attributes you have. But on occasion, it can get that mapping wrong and you may have to code around that.
  3. The index rebuild is set by your configuration. There are a few index update strategies that you can set:

    • manual: The index is only updated manually.
    • sync: The index is updated when items are modified, created or deleted. This should be the default for the master index on the content authoring server.
    • onPublishEndAsync: This updates the index after a publish job has been completed.

In a multi-server setup, for example: 1 content authoring server and 2 content delivery servers. You should setup the content authoring server or a dedicated indexing server to perform the index updates. The delivery servers should have the update strategies set to manual for all indexes. This stops the indexes being built multiple times by each server.

There are some good articles out there about setting up SOLR with Sitecore. For reference: * http://www.sequence.co.uk/blog/sitecore-8-and-solr/

That should give you an idea of the differences.