Question

We are trying to build a SOLR index with data coming from 2 different databases,

Looking at that http://wiki.apache.org/solr/DataImportHandler#Multiple_DataSources, it seems it should be possible but we are having issues.

 <dataConfig>
  <dataSource 
    name="ds-1"
    type="JdbcDataSource" 
    driver="Driver"
    url="jdbc_url1" 
    user="user1" 
    password="pass1"/>

<dataSource
    name="ds-2"
    type="JdbcDataSource" 
    driver="Driver"
    url="jdbc_url2" 
    user="user2" 
    password="pass2"/>

   <document>

 <entity name="entity1" datasource="ds-1" query="SELECT YYY  FROM TABLE">
      <field column="YYY" name="YYY"/>
    </entity>

 <entity name="entity2" datasource="ds-2" query="SELECT ZZZ FROM TABLE">
      <field column="ZZZ" name="ZZZ"/>
    </entity>

  </document>
</dataConfig>

When trying to run the indexer, it works for the first entity/query/ds and then fail with org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT ZZZ FROM TABLE

It seems it's trying to execute query2 on the ds-1...

We also played changing the order of the datasources and/or entity definition, and it seems it can always only index the first one.

Are we doing something wrong? do we have wrong expectation of what SOLR can do?

Thanks for the help

Was it helpful?

Solution

I believe your problem is just a case issue. datasource should be dataSource, as I recall Solr XML configuration attributes are case-sensitive. With the current configuration, dataSource would not be actually defined, so the handler will use the first data source that has been defined (single data source mode).

You should change it to:

<entity name="entity1" dataSource="ds-1" query="SELECT YYY FROM TABLE">
  <field column="YYY" name="YYY"/>
</entity>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top