import java.io.*;
import java.util.*;

import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.standard.*;
import org.apache.lucene.document.*;
import org.apache.lucene.index.*;
import org.apache.lucene.store.*;
import org.apache.lucene.util.*;

// javac -cp build/core/lucene-core-4.8-SNAPSHOT.jar:build/analysis/common/lucene-analyzers-common-4.8-SNAPSHOT.jar core/ManyLuceneFields.java; java -verbose:gc -Xms8g -Xmx8g -cp build/core/lucene-core-4.8-SNAPSHOT.jar:build/analysis/common/lucene-analyzers-common-4.8-SNAPSHOT.jar:core ManyLuceneFields /l/index

public class ManyLuceneFields {
    public static void main(String[] args) throws Exception {
        Directory dir = FSDirectory.open(new File(args[0]));

        Random random = new Random(17);
        IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_48, new StandardAnalyzer(Version.LUCENE_48));
        iwc.setInfoStream(new PrintStreamInfoStream(System.out));
        IndexWriter w = new IndexWriter(dir, iwc);
        long startTime = System.currentTimeMillis();
        for(int i=0;i<100000;i++) {
            Document doc = new Document();
            for(int j=0;j<100;j++) {
                int fieldUpto = random.nextInt(100000);
                doc.add(new StringField(fieldUpto + "_ss", "string", Field.Store.NO));
                doc.add(new IntField(fieldUpto + "_i", i, Field.Store.NO));
                doc.add(new LongField(fieldUpto + "_dt", i, Field.Store.NO));
            }
            w.addDocument(doc);
            if ((i % 10) == 0) {
                double sec = (System.currentTimeMillis() - startTime)/1000.0;
                System.out.println(String.format(Locale.ROOT, "%6.1f sec: %d docs = %.1f dps",
                                                 sec,
                                                 i,
                                                 i/sec));
            }
        }
        w.close();
    }
}
