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 an...@yahoo.se on 2009/03/30 03:45:54 UTC

questions about transformers

Hi:

Not sure how to solve this... 
I have a XML source and 1 table in a db. A specific filed in the XML source has the following

<field column="name" xpath="/RDF/item/name" /> 

and in the table I have, id, name, group (group multivalued in solr term)

What I like to do is every time i find name = "John Doe" in the XML source, I like to add the groups he belongs to from my database is this possible? 

- I been thinking exporting my table as a CSV and use the regex transformer? 

are there any better way of doing this? Custom transformer? sounds hard.

Regards
Anto



      __________________________________________________________
Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo.
http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014

Re: questions about transformers

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
A transformer is the best bet. See here for more details
http://wiki.apache.org/solr/DIHCustomTransformer

A custom Transformer can get hold of a DataSource using
Context#getDataSource(<name>) and run a query.

dataSource.getData() would return an Iterator<Map<String,Object>> ,
here each map is a row of data . In the Map<String,Object>, the key is
the column name and the value is the actual value.

you may also write this transformer in javascript.

do not forget to close the DataSource after use.

--Noble

On Mon, Mar 30, 2009 at 7:15 AM,  <an...@yahoo.se> wrote:
>
> Hi:
>
> Not sure how to solve this...
> I have a XML source and 1 table in a db. A specific filed in the XML source has the following
>
> <field column="name" xpath="/RDF/item/name" />
>
> and in the table I have, id, name, group (group multivalued in solr term)
>
> What I like to do is every time i find name = "John Doe" in the XML source, I like to add the groups he belongs to from my database is this possible?
>
> - I been thinking exporting my table as a CSV and use the regex transformer?
>
> are there any better way of doing this? Custom transformer? sounds hard.
>
> Regards
> Anto
>
>
>
>      __________________________________________________________
> Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo.
> http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014
>



-- 
--Noble Paul