addFieldToDocument(fieldName, type, tagValue);
}
}
private void addFieldToDocument(String fieldName, Descriptors.FieldDescriptor.Type type, Object value) {
LuceneOptions luceneOptions = STORED_NOT_ANALYZED;
if (value == null) {
value = QueryFacadeImpl.NULL_TOKEN; //todo [anistor] do we need a specific null token for numeric fields?
luceneOptions = NOT_STORED_NOT_ANALYZED;
}
String fn = getFullFieldName(fieldName); //todo [anistor] should we index with fieldNumber instead of fieldName?
//todo [anistor] string vs numeric. use a proper way to transform to string
switch (type) {
case DOUBLE:
case FLOAT:
case INT64:
case UINT64:
case INT32:
case FIXED64:
case FIXED32:
case UINT32:
case SFIXED32:
case SFIXED64:
case SINT32:
case SINT64:
case ENUM:
luceneOptions.addNumericFieldToDocument(fn, value, document);
break;
case BOOL:
luceneOptions.addNumericFieldToDocument(fn, ((Boolean) value) ? TRUE_INT : FALSE_INT, document);
break;
default:
luceneOptions.addFieldToDocument(fn, String.valueOf(value), document);
}
}