You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by pavan patharde <pa...@gmail.com> on 2014/07/17 06:29:38 UTC
Script Transformer Help
Hi All,
I have data-config.xml as below:Script Transformer is omitted.
<dataConfig>
<dataSource driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:/temp/example/ex" user="sa" />
<script><![CDATA[ function f1(row) {
row.put('message', 'Hello World!'); return
row; } ]]></script>
<document name="products">
<entity name="item" query="select NAME,BSIN from items"
transformer="script:f1">
<field column="NAME" name="id" />
<field column="BSIN" name="bsin" />
<entity name="brands" query="select brandname from brand where
bsin='${item.BSIN}'" >
<field name="brand" column="BRAND" />
<field name="cname" column="namedesc" />
</entity>
</entity>
</document>
</dataConfig>
I am able to access NAME and BSIN in the function f1. I am not able to
access the brand and cname. Is there any way i can access brand and cname
from child entity in script transformer ?
Thanks in advance.
Regards,
Pavan .P.Patharde
Re: Script Transformer Help
Posted by pavan patharde <pa...@gmail.com>.
Thats a good idea Alexandre. I will try it and update the results.. Thanks.
Pavan .P.Patharde
Phone:9844626450
On Thu, Jul 17, 2014 at 10:08 AM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:
> Have you tried putting the transformer on the inner entity definition?
> It's like a nested loop and you just put it in the outer loop.
>
> Regards,
> Alex.
> Personal: http://www.outerthoughts.com/ and @arafalov
> Solr resources: http://www.solr-start.com/ and @solrstart
> Solr popularizers community: https://www.linkedin.com/groups?gid=6713853
>
>
> On Thu, Jul 17, 2014 at 11:29 AM, pavan patharde
> <pa...@gmail.com> wrote:
> > Hi All,
> >
> > I have data-config.xml as below:Script Transformer is omitted.
> > <dataConfig>
> > <dataSource driver="org.hsqldb.jdbcDriver"
> > url="jdbc:hsqldb:/temp/example/ex" user="sa" />
> >
> > <script><![CDATA[ function f1(row) {
> > row.put('message', 'Hello World!'); return
> > row; } ]]></script>
> >
> >
> > <document name="products">
> > <entity name="item" query="select NAME,BSIN from items"
> > transformer="script:f1">
> > <field column="NAME" name="id" />
> > <field column="BSIN" name="bsin" />
> >
> > <entity name="brands" query="select brandname from brand where
> > bsin='${item.BSIN}'" >
> > <field name="brand" column="BRAND" />
> > <field name="cname" column="namedesc" />
> > </entity>
> >
> > </entity>
> > </document>
> > </dataConfig>
> >
> > I am able to access NAME and BSIN in the function f1. I am not able to
> > access the brand and cname. Is there any way i can access brand and cname
> > from child entity in script transformer ?
> > Thanks in advance.
> >
> > Regards,
> > Pavan .P.Patharde
>
Re: Script Transformer Help
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Have you tried putting the transformer on the inner entity definition?
It's like a nested loop and you just put it in the outer loop.
Regards,
Alex.
Personal: http://www.outerthoughts.com/ and @arafalov
Solr resources: http://www.solr-start.com/ and @solrstart
Solr popularizers community: https://www.linkedin.com/groups?gid=6713853
On Thu, Jul 17, 2014 at 11:29 AM, pavan patharde
<pa...@gmail.com> wrote:
> Hi All,
>
> I have data-config.xml as below:Script Transformer is omitted.
> <dataConfig>
> <dataSource driver="org.hsqldb.jdbcDriver"
> url="jdbc:hsqldb:/temp/example/ex" user="sa" />
>
> <script><![CDATA[ function f1(row) {
> row.put('message', 'Hello World!'); return
> row; } ]]></script>
>
>
> <document name="products">
> <entity name="item" query="select NAME,BSIN from items"
> transformer="script:f1">
> <field column="NAME" name="id" />
> <field column="BSIN" name="bsin" />
>
> <entity name="brands" query="select brandname from brand where
> bsin='${item.BSIN}'" >
> <field name="brand" column="BRAND" />
> <field name="cname" column="namedesc" />
> </entity>
>
> </entity>
> </document>
> </dataConfig>
>
> I am able to access NAME and BSIN in the function f1. I am not able to
> access the brand and cname. Is there any way i can access brand and cname
> from child entity in script transformer ?
> Thanks in advance.
>
> Regards,
> Pavan .P.Patharde