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 Britske <gb...@gmail.com> on 2008/09/27 23:47:22 UTC

DataImportHandler: way to merge multiple db-rows to 1 doc using transformer?

Looking at the wiki, code of DataImportHandler and it looks impressive. 
There's talk about ways to use Transformers to be able to create several
rows (solr docs) based on a single db row. 

I'd like to know if it's possible to do the exact opposite: to build
customer transformers that take multiple db-rows and merge it to a single
solr-row/document. If so, how?

Thanks, 
Britske
-- 
View this message in context: http://www.nabble.com/DataImportHandler%3A-way-to-merge-multiple-db-rows-to-1-doc-using-transformer--tp19706722p19706722.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DataImportHandler: way to merge multiple db-rows to 1 doc using transformer?

Posted by Jon Baer <jo...@gmail.com>.
If I understand your question right ... you would not need a  
transformer, basically you nest entities under each other ... ie:

<?xml version="1.0"?>
<dataConfig>
<dataSource name="db" type="JdbcDataSource"  
driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/nhldb? 
connectTimeout=0&amp;autoReconnect=true" user="root" password=""  
batchSize="-1"/>
<document name="doc1">
<entity dataSource="db" name="first" pk="ID" query="select col1, col2   
from table1">
   <field column="col1" name="col1"/>
   <field column="col2" name="col2"/>
   <entity dataSource="db" name="second'" query="select col3 from  
table2 where Iid='${first.col1}'"  
processor="org.apache.solr.handler.dataimport.CachedSqlEntityProcessor">
     <field column="col3" name="col3"/>
   </entity>
</entity>
</document>
</dataConfig>

I believe that is the basic steps.  Look up CachedSqlEntityProcessor  
to see if you need it.

- Jon

On Sep 27, 2008, at 5:47 PM, Britske wrote:

>
> Looking at the wiki, code of DataImportHandler and it looks  
> impressive.
> There's talk about ways to use Transformers to be able to create  
> several
> rows (solr docs) based on a single db row.
>
> I'd like to know if it's possible to do the exact opposite: to build
> customer transformers that take multiple db-rows and merge it to a  
> single
> solr-row/document. If so, how?
>
> Thanks,
> Britske
> -- 
> View this message in context: http://www.nabble.com/DataImportHandler%3A-way-to-merge-multiple-db-rows-to-1-doc-using-transformer--tp19706722p19706722.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>


Re: DataImportHandler: way to merge multiple db-rows to 1 doc using transformer?

Posted by Britske <gb...@gmail.com>.
Well, merging from different tables (using pk's, etc. ) is pretty clear from
the Wiki (nice work)
However the difficult part:  currently I have a table called availabilities,
and product (all simplified)
-------------------
| availabilities
-----------------
|productid    k
|factid          k
|providerid   k
|value
--------------------

Each row in this table represents a temporal availability of 1 product of 1
provider. An availability is unique by combination of fields:
productid-providerid-factid.

However the row / document in SOlr needs to represent a product.  I want to
merge these productavailabilities in such a way with product that a product
document contains (among other fields) a field for each 'fact'. The value
for such a fact-field  contains the value of availability.value of the
'best' availability found under constraints productid and factid. 

Note that: 
-there are a lot of facts (resulting in a lot of fact-columns --> 1,000 +) 
-fact-fields are defined as dynamic fields, since possible facts are not
known at design-time.
- I want to use a custom Transformer to calculate what is the 'best'
availability given the factid, productid. 

Currently I have a more or less working home-grown solution, but I would
like to be able to set it up with DataImportHandler. 

thanks for your help,
Britske



Noble Paul നോബിള്‍ नोब्ळ् wrote:
> 
> What is the basis on which you merge rows ? Then I may be able to
> suggest an easy way of doing that
> 
> 
> On Sun, Sep 28, 2008 at 3:17 AM, Britske <gb...@gmail.com> wrote:
>>
>> Looking at the wiki, code of DataImportHandler and it looks impressive.
>> There's talk about ways to use Transformers to be able to create several
>> rows (solr docs) based on a single db row.
>>
>> I'd like to know if it's possible to do the exact opposite: to build
>> customer transformers that take multiple db-rows and merge it to a single
>> solr-row/document. If so, how?
>>
>> Thanks,
>> Britske
>> --
>> View this message in context:
>> http://www.nabble.com/DataImportHandler%3A-way-to-merge-multiple-db-rows-to-1-doc-using-transformer--tp19706722p19706722.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --Noble Paul
> 
> 

-- 
View this message in context: http://www.nabble.com/DataImportHandler%3A-way-to-merge-multiple-db-rows-to-1-doc-using-transformer--tp19706722p19722396.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DataImportHandler: way to merge multiple db-rows to 1 doc using transformer?

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
What is the basis on which you merge rows ? Then I may be able to
suggest an easy way of doing that


On Sun, Sep 28, 2008 at 3:17 AM, Britske <gb...@gmail.com> wrote:
>
> Looking at the wiki, code of DataImportHandler and it looks impressive.
> There's talk about ways to use Transformers to be able to create several
> rows (solr docs) based on a single db row.
>
> I'd like to know if it's possible to do the exact opposite: to build
> customer transformers that take multiple db-rows and merge it to a single
> solr-row/document. If so, how?
>
> Thanks,
> Britske
> --
> View this message in context: http://www.nabble.com/DataImportHandler%3A-way-to-merge-multiple-db-rows-to-1-doc-using-transformer--tp19706722p19706722.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
--Noble Paul

Re: DataImportHandler: way to merge multiple db-rows to 1 doc using transformer?

Posted by Walter Underwood <wu...@netflix.com>.
Make a view in your database and index that. No point in duplicating
database views in Solr. --wunder

On 9/27/08 2:47 PM, "Britske" <gb...@gmail.com> wrote:
> 
> Looking at the wiki, code of DataImportHandler and it looks impressive.
> There's talk about ways to use Transformers to be able to create several
> rows (solr docs) based on a single db row.
> 
> I'd like to know if it's possible to do the exact opposite: to build
> customer transformers that take multiple db-rows and merge it to a single
> solr-row/document. If so, how?
> 
> Thanks, 
> Britske