Developer forum

Forum » Development » Repositories and indexing custom-indexes from Code-behind

Repositories and indexing custom-indexes from Code-behind

Kim Søjborg Pedersen
Reply

Okay, I've already been told not to go this way, as it can't be done, but I'm curious anyway.

I have created a custom index on the table AccessUserAddress and I need to update the index from code-behind or a workaround so that the index is updated every time a user adds an address.

Source
https://doc.dynamicweb.com/documentation-9/repositories/indexing/custom-indexes


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Kim,

Maybe you can make a request to the Activation URL of a scheduled task that rebuilds the index?

One of the limitations of Custom indexes is the ability to run an Update of the index instead of a Rebuild.

There are a couple of threads on the forum around this subject. This one helped me:https://doc.dynamicweb.com/forum/integration/integration/sql-index-builder-partial-index

It would be interesting to find out if there are any alternatives.

Adrian

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Or handle the UserSaved / AddressSave subscriber and update the index from code? Something like:

Dynamicweb.Indexing.IndexHelper.BuildIndexInstances(repository, indexName, buildName);

But as Adrian says, therer's not partial option but if needed you could build your own index builder and handle it there maybe

Imar

 

 
Kim Søjborg Pedersen
Reply

Hi Adrian,

Thanks for the tip, it's a super useful thread and I think it can lead me to a solution

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

In control panel, users, in the bottom of settings, you can activate a rebuild of the user index when users change:

https://doc.dynamicweb.com/documentation-9/platform/advanced-settings/control-panel#11139

It will trigger a rebuild on these events:

  •     [Subscribe(UserManagementNotifications.UserSaved)]
  •     [Subscribe(UserManagementNotifications.UserDeleted)]
  •     [Subscribe(UserManagementNotifications.GroupSaved)]
  •     [Subscribe(UserManagementNotifications.GroupDeleted)]
  •     [Subscribe(UserManagementNotifications.UserAddressOnAfterSave)]
  •     [Subscribe(UserManagementNotifications.UserAddressOnAfterDelete)]
 
Kim Søjborg Pedersen
Reply

Hi Nicolai

Thanks for the triggers, I wasn't aware that it was precisely these events that triggered it. It is interesting that UserAddressOnAfterSave and UserAddressOnAfterDelete also trigger an update on the user index, because I don't think you can retrieve data from AccessUserAddress through the users index

 

You must be logged in to post in the forum