code: public CompletableFuture<Boolean> reindexWorkspace(final boolean dropExisting, int nThreads) throws IllegalStateException
     {
        // checks
        if (handler == null || handler.getIndexerIoModeHandler() == null || changesFilter == null)
        {
           throw new IllegalStateException("Index might have not been initialized yet.");
        }
        if (handler.getIndexerIoModeHandler().getMode() != IndexerIoMode.READ_WRITE)
        {
           throw new IllegalStateException(
              "Index is not in READ_WRITE mode and reindexing can't be launched. Please start reindexing on coordinator node.");
        }
        if (isSuspended.get() || !handler.isOnline())
        {
           throw new IllegalStateException("Can't start reindexing while index is "
              + ((isSuspended.get()) ? "SUSPENDED." : "already OFFLINE (it means that reindexing is in progress).") + ".");
        }
  
        LOG.info("Starting hot reindexing on the " + handler.getContext().getRepositoryName() + "/"
           + handler.getContext().getContainer().getWorkspaceName() + ", with" + (dropExisting ? "" : "out")
           + " dropping the existing indexes.");
  
        // starting new thread, releasing JMX call
        ExecutorService executorService = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable,
                "HotReindexing-" + handler.getContext().getRepositoryName() + "-"
                        + handler.getContext().getContainer().getWorkspaceName()));
        CompletableFuture<Boolean> reindexFuture = CompletableFuture.supplyAsync(() -> doReindexing(dropExisting, nThreads), executorService);
        reindexFuture.thenRun(() -> executorService.shutdown());
        return reindexFuture;
     }
docs: Perform hot reindexing of the workspace
  @param dropExisting use the same index directory  (if "true") and all queries will throw
  an exception while task is running. Otherwise (if "false") Server can continue
  working as expected while index is recreated (the new index is created under
  a new index folder).
  @param nThreads indexing Thread Pool Size, default value is 1.
  @return a Future which can be used to get the result of the reindexing (true means successful)
  @throws IllegalStateException