code: private void createIndex(final NodeDataIndexingIterator iterator, NodeData rootNode, final AtomicLong count,
        final AtomicLong processed) throws RepositoryException, InterruptedException, IOException
     {
        for (NodeDataIndexing node : iterator.next())
        {
           processed.incrementAndGet();
           if (stopped.get() || Thread.interrupted())
           {
              throw new InterruptedException();
           }
  
           if (indexingTree.isExcluded(node))
           {
              continue;
           }
  
           if (!node.getQPath().isDescendantOf(rootNode.getQPath()) && !node.getQPath().equals(rootNode.getQPath()))
           {
              continue;
           }
  
           executeAndLog(new AddNode(getTransactionId(), node, true));
           if (count.incrementAndGet() % 1000 == 0)
           {
              if (nodesCount == null)
              {
                 LOG.info("indexing... {} ({})", node.getQPath().getAsString(), count.get());
              }
              else
              {
                 DecimalFormat format = new DecimalFormat("###.#");
                 LOG.info("indexing... {} ({}%)", node.getQPath().getAsString(),
                    format.format(Math.min(100d * processed.get() / nodesCount.get(), 100)));
              }
           }
  
           synchronized (this)
           {
              checkVolatileCommit();
           }
        }
     }
docs: Create index.
  
  @param iterator
  the NodeDataIndexing iterator
  @param rootNode
  the root node of the index
  @param count
  the number of nodes already indexed.
  @throws IOException
  if an error occurs while writing to the index.
  @throws RepositoryException
  if any other error occurs
  @throws InterruptedException
  if the task has been interrupted