code: private static int index(File indexDir, File dataDir) 
          throws IOException {
          if (!dataDir.exists() || !dataDir.isDirectory()) {
              throw new IOException(dataDir
                      + " does not exist or is not a directory");
          }
  
          IndexWriter writer = new IndexWriter(indexDir,
                      new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
          writer.setUseCompoundFile(false);
  
          indexDirectory(writer, dataDir);
  
          int numIndexed = writer.numDocs();
          writer.optimize();
          writer.close();
          return numIndexed;
      }
docs: creates the index files