private void addFieldValueForNonCollectionObject(Document doc, String indexedFieldName, Object fieldValue, List<String> tokenizedFields) { if (tokenizedFields.size() == 1) { SerializerUtil.addField(doc, indexedFieldName, fieldValue); } else { addFieldValue(doc, indexedFieldName, fieldValue, tokenizedFields.subList(1, tokenizedFields.size())); } }
/** * Recursively serialize each indexed field's value into a field of lucene document. The field * name will be in the same format as its indexed, such as contacts.homepage.content * * @param index lucene index * @param value user object to be serialized into index */ @Override public Collection<Document> toDocuments(LuceneIndex index, Object value) { String[] fields = index.getFieldNames(); Document doc = new Document(); for (String indexedFieldName : fields) { List<String> tokenizedFields = tokenizeField(indexedFieldName); addFieldValue(doc, indexedFieldName, value, tokenizedFields); } if (logger.isDebugEnabled()) { logger.debug("FlatFormatSerializer.toDocuments: " + doc); } return Collections.singleton(doc); }