How to monitor the process of mass indexing?

Good morning,
use hibernate search 6 and i want to monitor the process of mass indexing and the statistics?
How to use .monitor(MassIndexingMonitor)

        final SearchSession searchSession = Search.session(em);
		final MassIndexer indexer = searchSession.massIndexer()
				.purgeAllOnStart(true)
				.mergeSegmentsAfterPurge(true)
				.batchSizeToLoadObjects(12)
				.threadsToLoadObjects(16)
				.typesToIndexInParallel(1)
				.idFetchSize(100);
		indexer.startAndWait();

Thank you !

Hey Tony,

There is a built-in monitor, that would log the indexing progress. If you’d want to have something more custom, as you’ve mentioned in the question - there is that method on a mass indexer .monitor(MassIndexingMonitor). You’d need to implement the org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor interface. You could take a look at the implementation of the default log one for some idea how it can be done. The most important thing to keep in mind when implementing the interface: “Implementations must be threadsafe”.

@Tony please be thoughtful of the time it takes others to answer your questions.

  1. If you know you need to use a given method .monitor, first read the javadoc corresponding entry in the reference documentation.
  2. If that doesn’t clear things up, ask a precise question about what you don’t understand specifically. Not “explain all this to me”.