Sitecore Reindexing Module For Lucene and Solr

This module will add a shortcut in Context Menu to force Lucene Indexer to re-index the item.

Sitecore.SharedSource.IndexThis.Commands.config file

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <commands>
      <command name="SitecoreSharedSourceIndexThis:IndexOnlyThis" type="Sitecore.SharedSource.IndexThis.IndexOnlyThis, Sitecore.SharedSource.IndexThis"/>
      <command name="SitecoreSharedSourceIndexThis:IndexThisAndDescendants" type="Sitecore.SharedSource.IndexThis.IndexThisAndDescendants, Sitecore.SharedSource.IndexThis"/>
    </commands>
  </sitecore>
</configuration>

The IndexThisAndDescendants class


namespace Sitecore.SharedSource.IndexThis
{
    using System.Linq;
    using Data.Items;
    using Diagnostics;
    using Shell.Framework.Commands;

    internal class IndexThisAndDescendants : Command
    {
        /// <summary>
        /// Executes the command in the specified context.
        /// </summary>
        /// <param name="commandContext">The command context.</param>
        public override void Execute(CommandContext commandContext)
        {
            Assert.ArgumentNotNull(commandContext, "commandContext");

            if (commandContext.Items.Length >= 1)
            {
                Item item = commandContext.Items[0];

                if (item != null)
                {
                    Item[] descendants = item.Axes.GetDescendants();

                    Log.Info(string.Format("About to run Index This And Descendants of item: '{0}'.", item.Paths.FullPath), this);

                    item.Database.Engines.HistoryEngine.RegisterItemSaved(item, null);

                    if (descendants != null && descendants.Any())
                    {
                        foreach (Item descendant in descendants)
                        {
                            descendant.Database.Engines.HistoryEngine.RegisterItemSaved(descendant, null);
                        }
                    }
                }
            }
        }
    }
}

The IndexOnlyThis class


namespace Sitecore.SharedSource.IndexThis
{
    using Data.Items;
    using Diagnostics;
    using Shell.Framework.Commands;

    internal class IndexOnlyThis : Command
    {

        /// <summary>
        /// Executes the command in the specified context.
        /// </summary>
        /// <param name="commandContext">The command context.</param>
        public override void Execute(CommandContext commandContext)
        {
            Assert.ArgumentNotNull(commandContext, "commandContext");

            if (commandContext.Items.Length >= 1)
            {
                Item item = commandContext.Items[0];

                Log.Info(string.Format("About to run Index This item: '{0}'.", item.Paths.FullPath), this);

                if (item != null)
                    item.Database.Engines.HistoryEngine.RegisterItemSaved(item, null);
            }
        }

    }
}

IndexThis

IndexThis3

IndexThis4

IndexThise
Link to Sitecore Market Place
https://marketplace.sitecore.net/en/Modules/Sitecore_SharedSource_IndexThis.aspx

GitHub
https://github.com/MortazaKamalNourestani/Sitecore.SharedSource.IndexThis

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s