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 Mark Ellul <ma...@catalystic.com> on 2009/11/05 13:15:05 UTC

Newb Question about the TemplateTransformer

Hi,

I have read on the wiki that its possibile to concatenate values using a
TemplateTransformer.

Basically I have a Parent Table, and Child Table, I need to create a
children field (in my Parent Document) which has all the ids of the Parent's
child rows in a comma separated string.

Is this possible with the TemplateTransformer?

if so can you please give me an snippet?

Thanks and Regards

Mark

Re: Newb Question about the TemplateTransformer

Posted by Lance Norskog <go...@gmail.com>.
I think you need custom code for this. You can write plugins in Java,
or (in Java 1.6) any of the Java-based scripting languages like
JavaScript.

http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer

On Thu, Nov 5, 2009 at 8:54 AM, Mark Ellul <ma...@catalystic.com> wrote:
> Hi Noble,
>
> Thanks for the response...
>
> My data config is below... Basically I have a List table and a Tweeter
> table...
>
> In the document I want a field called list_members which is a csv string of
> all the rows where tweeter has the particular list id.
>
> Do you understand what I mean?
>
> Regards
>
> Mark
>
> <dataConfig>
>        <dataSource driver="org.postgresql.Driver"
>         url="jdbc:postgresql://api.tlists.com:5432/tlists"
>         user="tlists_dev"
>         password="foocarrot4"
>        readOnly="true" autoCommit="false"
> transactionIsolation="TRANSACTION_READ_COMMITTED"
> holdability="CLOSE_CURSORS_AT_COMMIT"
>         />
>        <document name="ListDocument">
>             <entity name="List" query="select id , twitter_id, name, slug,
> subscriber_count, member_count, uri, mode, curator_id,
> curator_screen_name_lower, curator_followers_count, description,
>                                         join_policy, lang,
>  composite_terms, tweets_per_day, balance, cohesion, semantic_affinity,
> social_affinity, authority, composite_topics, created_on
>                                        from api_list;"
> transformer="TemplateTransformer">
>                 <field name="model" template="List" column="name"/>
>                <field name="site_id" template="1" column="id" />
>                <field name="id" column="id" />
>                <entity name="curator_id" transformer="TemplateTransformer"
> query=" select id from api_tweeter where " template=""
> -->
> </document>
> <!-- <document name="tweeter">
> </document> -->
> </dataConfig>
> ~
>
>
> 2009/11/5 Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>
>
>> there is no parent document or child document there is only one.
>> maybe you can paste your data-config
>>
>> On Thu, Nov 5, 2009 at 5:45 PM, Mark Ellul <ma...@catalystic.com> wrote:
>> > Hi,
>> >
>> > I have read on the wiki that its possibile to concatenate values using a
>> > TemplateTransformer.
>> >
>> > Basically I have a Parent Table, and Child Table, I need to create a
>> > children field (in my Parent Document) which has all the ids of the
>> Parent's
>> > child rows in a comma separated string.
>> >
>> > Is this possible with the TemplateTransformer?
>> >
>> > if so can you please give me an snippet?
>> >
>> > Thanks and Regards
>> >
>> > Mark
>> >
>>
>>
>>
>> --
>> -----------------------------------------------------
>> Noble Paul | Principal Engineer| AOL | http://aol.com
>>
>



-- 
Lance Norskog
goksron@gmail.com

Re: Newb Question about the TemplateTransformer

Posted by Mark Ellul <ma...@catalystic.com>.
Hi Noble,

Thanks for the response...

My data config is below... Basically I have a List table and a Tweeter
table...

In the document I want a field called list_members which is a csv string of
all the rows where tweeter has the particular list id.

Do you understand what I mean?

Regards

Mark

<dataConfig>
        <dataSource driver="org.postgresql.Driver"
         url="jdbc:postgresql://api.tlists.com:5432/tlists"
         user="tlists_dev"
         password="foocarrot4"
        readOnly="true" autoCommit="false"
transactionIsolation="TRANSACTION_READ_COMMITTED"
holdability="CLOSE_CURSORS_AT_COMMIT"
         />
        <document name="ListDocument">
             <entity name="List" query="select id , twitter_id, name, slug,
subscriber_count, member_count, uri, mode, curator_id,
curator_screen_name_lower, curator_followers_count, description,
                                         join_policy, lang,
 composite_terms, tweets_per_day, balance, cohesion, semantic_affinity,
social_affinity, authority, composite_topics, created_on
                                        from api_list;"
transformer="TemplateTransformer">
                 <field name="model" template="List" column="name"/>
                <field name="site_id" template="1" column="id" />
                <field name="id" column="id" />
                <entity name="curator_id" transformer="TemplateTransformer"
query=" select id from api_tweeter where " template=""
-->
</document>
<!-- <document name="tweeter">
</document> -->
</dataConfig>
~


2009/11/5 Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>

> there is no parent document or child document there is only one.
> maybe you can paste your data-config
>
> On Thu, Nov 5, 2009 at 5:45 PM, Mark Ellul <ma...@catalystic.com> wrote:
> > Hi,
> >
> > I have read on the wiki that its possibile to concatenate values using a
> > TemplateTransformer.
> >
> > Basically I have a Parent Table, and Child Table, I need to create a
> > children field (in my Parent Document) which has all the ids of the
> Parent's
> > child rows in a comma separated string.
> >
> > Is this possible with the TemplateTransformer?
> >
> > if so can you please give me an snippet?
> >
> > Thanks and Regards
> >
> > Mark
> >
>
>
>
> --
> -----------------------------------------------------
> Noble Paul | Principal Engineer| AOL | http://aol.com
>

Re: Newb Question about the TemplateTransformer

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>.
there is no parent document or child document there is only one.
maybe you can paste your data-config

On Thu, Nov 5, 2009 at 5:45 PM, Mark Ellul <ma...@catalystic.com> wrote:
> Hi,
>
> I have read on the wiki that its possibile to concatenate values using a
> TemplateTransformer.
>
> Basically I have a Parent Table, and Child Table, I need to create a
> children field (in my Parent Document) which has all the ids of the Parent's
> child rows in a comma separated string.
>
> Is this possible with the TemplateTransformer?
>
> if so can you please give me an snippet?
>
> Thanks and Regards
>
> Mark
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com