Type: New Feature
Affects Version/s: None
Fix Version/s: None
I use DIH to index nested documents.
I have couple of use cases where field values on parent document depend on children documents values. The simplest one - I need to "propagate" values from all children documents to new field on parent document. It could be a little bit tricky with current DIH architecture when you can apply transformation for "plain" documents which considered as a plain map. See org.apache.solr.handler.dataimport.Transformer (You have to use some kind of "transient fields" in your data-config, this fields are populated from child sources, so sometimes you have to read child sources twice (or more times) for this. Maybe I do it wrong?)
I decided that maybe it makes sense to be able to apply transformation after nested documents were converted from collection of maps into good old hierarchical SolrInputDocument.
So this initial patch was created:
- It introduces concept of DocumentTransformer with Java interface
- This interface should be implemented by clients transformers. One simple example of such transformer, PropagationDocumentTransformer, is implemented. It parametrised by two field names - child and parent, and copied values from children documents to parent document.
- This kind of transformer should be added into data-config.xml to corresponding parents entry: