In fact, this can be done using the standard Solr configuration.
First you need to define your data sources in the solrconfig.xml file [See Adding a data source to Solrconfig]
Secondly, you can export DIH configurations to a separate file using XInclude
I use this approach both to use local configuration files and to centralize connections across different kernels.
Example: In the solrconfig.xml file add:
<xi:include href="../../common-config/local.dih.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
local.dih.xml will look something like this:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> <lst name="datasource"> <str name="name">mongo</str> <str name="type">MongoDataSource</str> <str name="database">myMongoDb</str> </lst> <lst name="datasource"> <str name="name">psql</str> <str name="driver">org.postgresql.Driver</str> <str name="type">JdbcDataSource</str> <str name="url">jdbc:postgresql://localhost:5432/myPsqlDb</str> <str name="user">dbUser</str> <str name="password">dbPassword</str> </lst> </lst> </requestHandler>
source share