for (FieldInfo fi : fieldInfos) {
String name = fi.name;
IndexableField[] fs = doc.getFields(name);
if (fs != null && fs.length > 0) {
for (IndexableField f : fs) {
IndexableFieldToXContent x = new IndexableFieldToXContent().field(f);
x.toXContent(builder, ToXContent.EMPTY_PARAMS);
}
}
}
}
builder.endArray();