if (doc != null) {
StrUtils.splitSmart(doc,",",true);
}
SolrQueryRequest req = lrf.makeRequest();
IndexSchema schema = req.getSchema();
UpdateHandler updateHandler = req.getCore().getUpdateHandler();
String[] fields = {"text","simple"
,"text","test"
,"text","how now brown cow"
,"text","what's that?"
,"text","radical!"
,"text","what's all this about, anyway?"
,"text","just how fast is this text indexing?"
};
/***
String[] fields = {
"a_i","1"
,"b_i","2"
,"c_i","3"
,"d_i","4"
,"e_i","5"
,"f_i","6"
,"g_i","7"
,"h_i","8"
,"i_i","9"
,"j_i","0"
,"k_i","0"
};
***/
long start = System.currentTimeMillis();
AddUpdateCommand add = new AddUpdateCommand();
add.allowDups = !overwrite;
add.overwriteCommitted = overwrite;
add.overwritePending = overwrite;
Field idField=null;
for (int i=0; i<iter; i++) {
if (includeDoc || add.doc==null) {
add.doc = new Document();
idField = new Field("id","", Field.Store.YES, Field.Index.NOT_ANALYZED);
add.doc.add(idField);
for (int j=0; j<fields.length; j+=2) {
String field = fields[j];
String val = fields[j+1];
Fieldable f = schema.getField(field).createField(val, 1.0f);
add.doc.add(f);
}
}
idField.setValue(Integer.toString(i));
updateHandler.addDoc(add);
}
long end = System.currentTimeMillis();
System.out.println("includeDoc="+includeDoc+" doc="+ Arrays.toString(fields));
System.out.println("iter="+iter +" time=" + (end-start) + " throughput=" + ((long)iter*1000)/(end-start));
//discard all the changes
updateHandler.rollback(new RollbackUpdateCommand());
req.close();
}