lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng Zhang <zhangyongji...@yahoo.com>
Subject Challenge: Is dynamic data source possible for DataImportHandler JdbcDataSource?
Date Fri, 01 Jun 2012 00:59:29 GMT
Hi,

The challenge I'm facing is some sort of dynamic data source. Your valuable input is highly
appreciated.

Below is my data-config.xml. I have one user database and two company databases. The user
table in the user database has four columns which are id + name + company_dbname + company_id.
Depending on the company_dbname, I need to look up either companydb0 or companydb1 to get
the company name by the company_id. 

<dataConfig>
    <dataSource type="JdbcDataSource"
        name="userdb"
        driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://db0.com:3306/user"
        user="xxx"
        password="calltextual" batchSize="-1"/>

    <dataSource type="JdbcDataSource"
        name="companydb0"
        driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://companydb0.com:3306/company"
        user="xxx"
        password="calltextual" batchSize="-1"/>

    <dataSource type="JdbcDataSource"
        name="companydb1"
        driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://companydb1.com:3306/company"
        user="xxx"
        password="calltextual" batchSize="-1"/>

    <document name="USERS">
        <entity name="USER" dataSource="userdb"
            query="SELECT id, name, company_dbname, company_id from user ">
            <field column="id" name="id" />
            <field column="name" name="name" />
            <entity name="company" dataSource="${USER.company_dbname}"
                query="SELECT name from company
                WHERE id = '${PG0.company_id}' ">  
                <field column="name" name="company_name" />
            </entity>
        </entity>
    </document>
</dataConfig>

Is it doable to set the data source dynamically for the child entity? In my case, I would
like to set company entity dataSource to "${USER.company_dbname}"  which is returned from
USER entity query.

If it's not doable with current implementation, I would like to download the source code and
customize it for my needs. Which source java file I should start with?

Many many thanks,

Kevin
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message