2

I'm currently trying to index multiple databases (two MySQL and one PostgreSQL) into one same index so as to make a research on a website. I've succeeded in importing each Mysql base separatly on different Core (and different indexes).

Edit : The problem is that I have an id for each table and these ones enter in conflict with each other. How can I say that each database have a different ID for Solr ?

Code:

    <entity name="database1" dataSource="ds-database1" query="SELECT id, my_column FROM table_database1">
        <field column="id" name="id" />
        <field column="my_column" name="ts_my_column" />
    </entity>


    <entity name="database2" dataSource="ds-database2" query="
            SELECT id, column_example
            FROM table_database2" >
        <field column="id" name="id" />
        <field column="column_example" name="ts_columnsexample" />
    </entity>
Ismail H
  • 4,226
  • 2
  • 38
  • 61
  • Just defining all the datasources in the same configuration should work, IIRC. Solr will import all entities by default. – MatsLindh Feb 04 '16 at 10:09
  • I configured two datasources and two entity which work fine each one taken separatly but when both (mysql databases for now) configurations are put in the same xml, only one database is indexed – Ismail H Feb 04 '16 at 11:16
  • I think I got the problem circled. I'm gonna update the question. – Ismail H Feb 04 '16 at 11:19

1 Answers1

3

You can use a TemplateTransformer to add content in front of a value when using DIH, or you can do it in your SQL:

SELECT CONCAT('db_1_', id) AS id ...

.. or you can do it with a ScriptTransformer if you need even more logic around the transformation.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84