views:

83

answers:

2

I've got a Sitecore application, which creates and uses a number of Lucene indexes through Sitecore's built-in API.

I need to make sure that items in the index are kept up-to-date when they are published. To do this, I've created a Sitecore Hook that detects when and item is saved to the "web" database and reindexes the item. It seems to be working for the most part, but it seems to inexplicibly fail from time to time.

The code I have in the hook looks like:

        item.Database.Indexes.RemoveItem(item, true);
        item.Database.Indexes.UpdateItem(item);

Anyone ever try this before and have a better solution?

A: 

I'd probably look into hooking the Sitecore History Engine into your "web" database, as it already is for "master". Through this, indexing of changed content would happen automatically.

Am not on a pc right now where I can pull up a full example, but you should be able to find the configuration you need, under the "master" database definition in your web.config.

Mark Cassidy
A: 

HistoryEngine config snippet:

<Engines.HistoryEngine.Storage>
    <obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
        <param connectionStringName="$(id)" />
        <EntryLifeTime>30.00:00:00</EntryLifeTime>
    </obj>
</Engines.HistoryEngine.Storage>
Kyle