How do I exclude the current user from the search? In a normal Views user search, you can simply add a User: Current filter to remove the logged-in user from the search results.

I have a Search API Views search of a Solr index of users, and I want to do the same thing.  However, the User:Current filter is not available.  How can I achieve the same function?
You could write a simple module using hook_views_pre_view.


Be sure to index the User ID
Under Filter Criteria, add Indexed User: User ID, and set it to NOT EQUAL TO and use 0 (anonymous user, which will never be in this list).
Using MY_MODULE_views_pre_view with the global user value, replace 0 with the UID of the current user.


function MY_MODULE_views_pre_view(&$view) {
  global $user;
  if ($view->name == 'VIEW_NAME') {
    if ($user->uid) {
      $view->display['default']->handler->options['filters']['uid']['value'] = $user->uid;
    }
  }
}