How to override existing plugin? Considering Drupal\search_api\Plugin\views\query\SearchApiQuery class, I want to override shouldAbort() method there.

I have tried to create a new plugin class in my custom mod:

namespace Drupal\my_mod\Plugin\views\query;

use Drupal\search_api\Plugin\views\query\SearchApiQuery;

/**
 * Defines a Views query class for searching on Search API indexes.
 *
 * @ViewsQuery(
 *   id = "search_api_query",
 *   title = @Translation("Search API Query"),
 *   help = @Translation("The query will be generated and run using the Search API.")
 * )
 */
class MymodSearchApiQuery extends SearchApiQuery {

  /**
   * @inheritdoc
   */
  public function shouldAbort() {
    //do something fancy
  }
}


But it seems to not work. How can I do it properly?
What you want to do, is to make views use your class instead of the the one solr module provides. Defining your own plugin wont help.

Instead you can use hook_views_plugins_query_alter to specify the plugin class.