code: private void cancelSearch()
    {
      // don't spin forever when canceled
      searchView.getControlPanel().getQueryPanel().setCountIndicatorEnabled(false);
  
      Map<QueryUIState.QueryType, Future<?>> exec = state.getExecutedTasks();
      // abort last tasks if running
      if (exec.containsKey(QueryUIState.QueryType.COUNT)
        && !exec.get(QueryUIState.QueryType.COUNT).isDone())
      {
        exec.get(QueryUIState.QueryType.COUNT).cancel(true);
      }
      if (exec.containsKey(QueryUIState.QueryType.FIND)
        && !exec.get(QueryUIState.QueryType.FIND).isDone())
      {
        exec.get(QueryUIState.QueryType.FIND).cancel(true);
      }
  
      exec.remove(QueryUIState.QueryType.COUNT);
      exec.remove(QueryUIState.QueryType.FIND);
  
    }
docs: Cancel queries from the client side.
  
  Important: This does not magically cancel the query on the server side, so
  don't use this to implement a "real" query cancelation.