3

I am trying to rebuild commerce index in Sitecore incrementally(so, I don't want to make a full rebuild). Index strategy is set to "manual" at the moment.

I made some changes in catalog(updated relations and data, added/removed products and categories) and now just want to update index correspondingly.

I am tried to use class IndexCustodian(read about this class in the article). However, can't find the detailed documentation for this class with some code examples.

For example, I tried to use IncrementalUpdate method. As a second parameter I used an array of IndexableUniqueId(created on a search result using uniqueid field), but index hasn't been changed.

IEnumerable<IIndexableUniqueId> uniqueIds = foundProducts.Select(x => new IndexableUniqueId<string>(x.UniqueId));
Job job = IndexCustodian.IncrementalUpdate(ContentSearchManager.GetIndex(indexName), uniqueIds);

Another example, I tried to use Refresh method. As a second input parameter I used object of type CommerceIndexableItem which was created for the root sitecore item of my catalog. New products have been added, but existing product has been updated not completely: category relation has been updated, localized string field - hasn't been updated. Removed from catalog products still presented in the index.

Database database = Database.GetDatabase("web");
Item rootFolder = database.GetItem(Paths.DefaultCatalogPath);
CommerceIndexableItem indexableFolder = new CommerceIndexableItem(rootFolder);
Job job = IndexCustodian.Refresh(ContentSearchManager.GetIndex(indexName), indexableFolder);

Will appreciate any example of using of IndexCustodian or any other way which allows to update the index.

Thank you in advance for the help.

Liam
  • 22,818
  • 25
  • 93
  • 157
Max
  • 804
  • 7
  • 19
  • 1
    Typically when I find an undocumented class in sitecore (i.e. most of them) I use a [reflection tool](http://ilspy.net/) to open them up and have a poke about so see what they actually do. Sitecore would actually make this whole process a lot easier if they made their code base open source (like everyone else does these days). – Liam Jan 05 '17 at 11:06
  • As I understand it is suggested to use this class to work with indexes, but there are no any available documentation. My company has some contacts in Sitecore and I hope that finally I will get the answer. Will update this topic anyway. – Max Jan 10 '17 at 08:24

0 Answers0