public static void beforeWrite(Cache cache, final Consumer<Object> beforeWrite) {
    GemFireCacheImpl gemfireCache = (GemFireCacheImpl) cache;
    gemfireCache.addRegionListener(new SpyRegionListener(beforeWrite));
  }
Allows spying on operations that happen to an the regions underlying a lucene index.
geode-lucene/geode-lucene-test/src/main/java/org/apache/geode/cache/lucene/test/IndexRegionSpy.java