index.execute(new Esi4JOperation<Void>() {
@Override
public Void execute(Client client, String indexName, Esi4JOperation.OperationContext context) {
final TypeMapping mapping = context.findTypeMapping(rebuildSession.getType());
ModuleIdAndVersionStream moduleStream = new ModuleIdAndVersionStream(rebuildSession,
DEFAULT_BATCH_SIZE, mapping);
IdAndVersionFactory factory = new MappedObjectIdAndVersionFactory(mapping);
ElasticSearchSorter elasticSearchSorter = new ElasticSearchSorter(createSorter(factory));
IteratorFactory iteratorFactory = new IteratorFactory(factory);
String workingDirectory = SystemUtils.getJavaIoTmpDir().getAbsolutePath();
ElasticSearchIdAndVersionStream esStream = new ElasticSearchIdAndVersionStream(
new ElasticSearchDownloader(client, indexName, "_type:" + mapping.getTypeAlias(), factory),
elasticSearchSorter, iteratorFactory, workingDirectory);
BulkIndexHelper bulkHelper = new BulkIndexHelper().setMaxRunning(2);
bulkHelper.setResponseHandler(new BulkIndexHelper.IResponseHandler() {
@Override
public void handle(String id, String type) {
if ("delete".equals(type)) {
onDelete(mapping.getTypeClass(), mapping.toId(id));
} else {
onIndex(mapping.getTypeClass(), mapping.toId(id));
}
}
});