use of org.apache.lucene.document.Fieldable in project Solbase by Photobucket.
the class DocumentLoader method mergeOldAndNew.
private Document mergeOldAndNew(Document oldDoc, Document newDoc) {
SolrInputDocument newInputDoc = new SolrInputDocument();
@SuppressWarnings("unchecked") List<Fieldable> newFields = newDoc.getFields();
for (Fieldable field : newFields) {
String fieldName = field.name();
String fieldValue = field.stringValue();
newInputDoc.addField(fieldName, fieldValue);
oldDoc.removeField(fieldName);
}
@SuppressWarnings("unchecked") List<Fieldable> oldFields = oldDoc.getFields();
for (Fieldable field : oldFields) {
String fieldName = field.name();
String fieldValue = field.stringValue();
newInputDoc.addField(fieldName, fieldValue);
}
Document mergedDoc = DocumentBuilder.toDocument(newInputDoc, schema);
return mergedDoc;
}
use of org.apache.lucene.document.Fieldable in project graphdb by neo4j-attic.
the class IndexType method instantiateField.
Fieldable instantiateField(String key, Object value, Index analyzed) {
Fieldable field = null;
if (value instanceof Number) {
Number number = (Number) value;
NumericField numberField = new NumericField(key, Store.YES, true);
if (value instanceof Long) {
numberField.setLongValue(number.longValue());
} else if (value instanceof Float) {
numberField.setFloatValue(number.floatValue());
} else if (value instanceof Double) {
numberField.setDoubleValue(number.doubleValue());
} else {
numberField.setIntValue(number.intValue());
}
field = numberField;
} else {
field = new Field(key, value.toString(), Store.YES, analyzed);
}
return field;
}
use of org.apache.lucene.document.Fieldable in project graphdb by neo4j-attic.
the class IndexType method clearDocument.
private void clearDocument(Document document) {
Set<String> names = new HashSet<String>();
for (Fieldable field : document.getFields()) {
names.add(field.name());
}
names.remove(LuceneIndex.KEY_DOC_ID);
for (String name : names) {
document.removeFields(name);
}
}
Aggregations