Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr - How can I receive notifications of failed imports from my DataImportHandler?

Our solr indexes are refreshed according to a schedule, as well as arbitrarily as needed by means of a DataImportHandler full import. We've had several occasions where the import fails for various reasons.

How can I receive a notification (preferably email) that an error has occured while performing an import with a DataImportHandler?

like image 953
STW Avatar asked Feb 01 '12 14:02

STW


1 Answers

There is no easy config solution. But an alternative exists you might have to do little work.

You could register EventListener with DIH in data-config to listen for events EventListener.

Refer Wiki

<dataConfig>
  <document onImportStart ="com.foo.StartEventListener" onImportEnd="com.foo.EndEventListener">
   ....
   </document>
</dataConfig>

Your EventListener gives you access to Context Object, which provides access to most of DataImportHandler Objects & Event Statistics.

For instance, onImportEnd event your com.foo.EndEventListener could you use Context object handle to get Staistics such # of DocsSkipped , # of DocsFailed ... Context is a valuable object that exposes lot of DIH internals. It is up to your event listener to do what it needs to do with this information.

Perhaps a caveat, the DIH notification is mostly after the fact, you won't notified of events as it happens, you have to wait for the import process to complete for DIH to notify your listener or may be there is a workaround.

  • EventListener
  • Context
like image 83
mailboat Avatar answered Sep 16 '22 20:09

mailboat