On 4 June 2013 16:03, Gora Mohanty <g...@mimirtech.com> wrote:
> On 4 June 2013 14:14, sodoo <first...@yahoo.com> wrote:
>>
>> Hi,
>>
>> My english is bad. But I try to explain do this.
>>
>> I have a 5 table in MySQL db. I try make data-config.xml. Then my
>> data-config.xml is below.
>>
>> <dataConfig>
>>          <dataSource type="JdbcDataSource"
>>                           name="ds-1"
>>               driver="com.mysql.jdbc.Driver"
>>               url="jdbc:mysql://localhost/testdb"
>>               user="root"
>>               password="*******"/>
>>           <document>
>>             <entity name="admin" query="select *from admin"
>> dataSource="ds-1">
>>                         <field column="id" name="id" />
>>                         <field column="name" name="name" />
>>                         <field column="mail" name="mail" />
>>                 </entity>
>>
>>                 <entity name="checklist" query="select *from checklist"
>> dataSource="ds-1">
>>                         <field column="check_id" name="check_id" />
>>                         <field column="title" name="title" />
>>                         <field column="connect" name="connect" />
>>                 </entity>
>>
>>                 <entity name="account" query="select *from account"
>> dataSource="ds-1">
>>                         <field column="account_id" name="account_id" />
>>                         <field column="name" name="name" />
>>                         <field column="code" name="code" />
>>                 </entity>
>>         </document>
>> </dataConfig>
>>
>> Then I register schema.xml to these fields. But I have a unique key
>> problem?
>>
>> default is uniquekey=>id. But my 5 table unique keys are check_id,
>> account_id, store_id etc. All unique keys are auto increment.
> [...]
>
> As all of your entities are unrelated, this is easy to do.
> Just change the name attribute for each entity, e.g.,
>   <field column="id" name="id" />
> for the first,
>   <field column="check_id" name="id" />
> for the second, and so on.

This will only work if your table IDs are different. Missed
the part where you said that they auto-increment. In that
case, you will have to make the IDs unique somehow,
say make the "id" field in schema.xml a string instead of
an integer, and add a prefix to it, either in the SELECT
statement or through a Solr transformer.

Regards,
Gora

Reply via email to