SchemaField sfield = schema.getFieldOrNull(fieldName);
if (sfield.getType() instanceof EmbeddedIndexedIntField) {
EmbeddedIndexedIntField eiif = (EmbeddedIndexedIntField)sfield.getType();
EmbeddedSortField sf = new EmbeddedSortField(fieldName,
tok.nextToken(),
Field.Store.YES,
Field.Index.NO,
eiif.getFieldNumber());
document.add(sf);
} else {
Field f = sfield.createField(tok.nextToken(), 1.0f);
if (f != null) { // null fields are not added
document.add(f);
}
}
} else {
field = new Field(fieldName, tok.nextToken(), Store.YES, Index.ANALYZED);
document.add(field);
}
}
} else {
// update logic
if(schema != null){
SchemaField sfield = schema.getFieldOrNull(fieldName);
if (sfield.getType() instanceof EmbeddedIndexedIntField) {
EmbeddedIndexedIntField eiif = (EmbeddedIndexedIntField)sfield.getType();
EmbeddedSortField sf = new EmbeddedSortField(fieldName,
fieldString,
Field.Store.YES,
Field.Index.NO,
eiif.getFieldNumber());
document.add(sf);