Hello Irina,

I looked through DIH sources, it seems like you exceed its' design. Such
leakages are not possible in it. I can only suggest to call private method
through reflection.
org.apache.solr.handler.dataimport.ContextImpl.getDocument().
Perhaps, you can pass some state for Transformers via
Context.setSessionAttribute(String, Object, Context.SCOPE_DOC).
Nevertheless, it sounds like deeper level of customization see
FieldMutatingUpdateProcessorFactory
https://cwiki.apache.org/confluence/display/solr/Update+Request+Processors


On Fri, Sep 4, 2015 at 12:49 PM, vatuska <vatu...@yandex.ru> wrote:

> Hello. I work with Solr 4.10.
> I use DIH and some custom java Transformers to synchronize my Solr index
> with the database (MySQL is used)
> Is there any way to change the fields in root entity from the sub entity?
> I mean something like this
>
> public class MySubEntityTransformer extends
> org.apache.solr.handler.dataimport.Transformer {
>     @Override
>     public Object transformRow(Map<String, Object> row, Context context) {
>         Map<String, Object> parentRow = context.getParentContext().....?
>         Object val = row.get("subEnityColumn");
>         if (val != null) {
>             //transform this value some way
>             Object generalValue = parentRow.get("documentField");
>             if (generalValue != null) {
>                   parentRow.put("documentField", generalValue + "_" + val);
>             } else {
>                    parentRow.put("documentField", val);
>             }
>         }
>         return row;
>     }
> }
>
> Or is there any way to apply some kind of the transformation for the root
> entity after all its subentities has been processed?
>
> I can't use the script transformers, because they works many times slower
> than java extensions.
>
>
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Solr-DIH-sub-entity-tp4227167.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mkhlud...@griddynamics.com>

Reply via email to