try {
BytesRef term = termsEnum.next();
if (term != null) {
BytesRef text = new BytesRef();
text.copyBytes(term);
TermStats ts = new TermStats();
ts.field(field).text(text).docFreq(termsEnum.docFreq());
tiq.insertWithOverflow(ts);
} else {
break;
}
} catch (IOException e) {