void clearIndicesIfNecessary() {
    waitUntilIndicesAreInitialized();
    for (ID<?, ?> indexId : getState().getIndexIDs()) {
      try {
        RebuildStatus.clearIndexIfNecessary(indexId, () -> clearIndex(indexId));
      }
      catch (StorageException e) {
        LOG.error(e);
        requestRebuild(indexId, e);
      }
    }
  }
void clearIndicesIfNecessary()