Using Solr or Lucene in Sitecore

Sitecore supports both Lucene and Solr search engines. As a developer, there is always a confusion of Using Solr or Lucene in Sitecore during development. However, these are the 2 most popular search engines available which are used widely.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.

The search engines that are used for these two different kinds of databases do not have to be the same instance of either Lucene or Solr, and they do not even have to both be either Lucene or Solr.

When visitors search for content, they use a search engine. Therefore, this search engine must be available from the Internet. On the other hand, the search engine that Sitecore uses for the operational databases does not have to be available from the Internet.

In most situations, you have a choice between using Solr or Lucene in Sitecore.

Note

There is one situation where you cannot choose between search engines but must use Solr. If the operational indexes are on a different server than the server that hosts the services and interfaces that access these indexes, you must always use Solr. All these services depend on search for the data they need. Solr supports calls over HTTP(S), whereas calls to a Lucene index must be made from the same machine that hosts the index itself.

Using Solr or Lucene in Sitecore

The general reasons for using Solr instead of Lucene are:

  • When you need to index large numbers of items (50,000 and up), Solr performs better.
  • Solr is more robust. If your site depends on search as the primary interface, consider using Solr.
  • If you use multiple content delivery servers (or plan to do so later), use Solr. Solr works automatically in such an environment. You could use Lucene, but you have to make sure that indexes are synchronized across servers yourself.You should, therefore, use Solr if you plan to scale your site (have a distributed setup with multiple servers).
  • Notice that Solr uses slightly different analyzers and scoring mechanisms so your search results may be slightly different compared to Lucene.

Later point in case if you want to move from Lucene to Solr, the code, and the LINQ queries remain the same, however, there are differences in configuration files which needs to be taken care.  Finally, after the configuration changes, you will also have to rebuild indexes. The move is possible, but it is not a trivial task. Hence, it is always better to make a choice whether Using Solr or Lucene in Sitecore before beginning of the project.

If you do move from Lucene to Solr, be aware that Lucene and Solr score search results in slightly different ways (which can look like there is something wrong unless you know this).

You can mix Lucene and Solr, and, for example, use Solr for xDB and Lucene for content search at the same time. If an index is small, it is much easier to manage as a Lucene index because there is little to no overhead to set it up.

In most cases, though, it is simpler to move everything to Solr once you need to use Solr for the operational databases.

1 comment
  1. Great blog you have !

    Can you please put a basic article about creating a bucket item and search its content programmatically using Lucene ?

    Thanks

Leave a Reply

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

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like