Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Lucene. Show all posts
Showing posts with label Lucene. Show all posts

Monday, July 10, 2017

Fix : 'Lucene.Net.Index.MergePolicy.MergeException' occurred in Lucene.Net.dll

If you are using Lucene search in your Sitecore project, you may receive Visual Studio Just-In-Time Debugger window which ask you for debugging.

When you debug you may encountered that there is an exception 'Lucene.Net.Index.MergePolicy.MergeException' in Lucene.Net.dll.

What does 'Lucene.Net.Index.MergePolicy.MergeException' mean?

This issue is related with your current Sitecore indexing and current indexes are not in well format. This typically happen when you copy full website from one developer machine to another. Indexes on new developer machine will not be in sync with its Sitecore instance.

How to fix it?

Simply delete all directories and files from "Data\indexes" folder and regenerate indexes from Sitecore Control Panel. 

I hope you like this Sitecore tip. Stay tuned for more Sitecore related tips.

Till that happy Sitecoring :)

Please leave your comments or share this tip if it’s useful for you.

Friday, October 28, 2016

All About indexing an external database in Sitecore

This post is about indexing an External Database in Sitecore.

Flow of external indexing
Flow of external indexing

So will index data of external database tables and use LUCENE search to get result from index files. If you are new to LUCENE search, please refer my article on Lucene search.

There is one great post on the same topic by Cameron Palmer.

I setup most of the things according to this post and its work like a charm.

However for Sitecore 8.0, I need to do below changes.

  • You need to add reference of Sitecore.ContentSearch.dll, Sitecore.ContentSearch.Linq.dll, Sitecore.ContentSearch.Linq.Lucene.dll and Sitecore.Kernel.dll.
  • I added my fields in "<fieldNames hint="raw:AddFieldByFieldName">" section in Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.
  • I created new config file "People.Index.config" in "Include" folder as

<?xml version="1.0"?>
<configuration xmlns:patch="">
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="People_Index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
            <param desc="name">$(id)</param>
            <param desc="folder">$(id)</param>
            <!-- This initializes index property store. Id has to be set to the index id -->
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these is controls the execution order -->
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
            <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
              <policies hint="list:AddCommitPolicy">
                <policy type="Sitecore.ContentSearch.ModificationCountCommitPolicy, Sitecore.ContentSearch">
            <!--<locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <locations hint="list:AddCrawler">
              <crawler type="Testsite.ASPNET.UI.PeopleCrawler, Testsite.ASPNET.UI">

You need to change two yellow highlighted things in this "People.Index.config" file as
  • <index id="People_Index" name
  • Class type details with assmbly name as <crawler type="Testsite.ASPNET.UI.PeopleCrawler, Testsite.ASPNET.UI">

That's it from Sitecore point of view.

After this next challenge is how to rebuild/refresh index for any DML operation done on external database tables. For this you can refer my article "Rebuild Sitecore index on real time basis from external system".

Index rebuild process takes time on Sitecore side. So you must call index rebuild method in async function in C#.

I hope you like this Sitecore lesson. Stay tuned for more Sitecore related articles.

Till that happy sitecoring :)

Please leave your comments or share this article if it’s useful for you.