I am new to Solr, actually I tried Database table indexing in Solr manually, i.e creating a new data-config.xml and running the full import from Solr webUI, successfully did that.
But now I need to do the same thing in Java. So I need know the following things using Java:
- How to set Solr datasource in Java api
- How to set the entity and query
- How to run full import
Actually, for data import we write a configuration file like below
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test_db"
user="root"
password="cloudera"/>
<document>
<entity name="emp"
query="select id,name from emp">
<field column="id" name="id"/>
<field column="name" name="name"/>
</entity>
</document>
</dataConfig>
and this configuration file information we will provide in solrconfig.xml like below
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
But my requirement is, I don't want to configure any XML file like above, just I want do it all from Java only, so I need to set all the configurations which I have given in above XML from Java code itself, i.e something like below
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("Datasource","JdbcDataSource")
params.set("driver","com.mysql.jdbc.Driver")
params.set("url","jdbc:mysql://localhost:3306/test_db")
params.set("user","cloudera")
params.set("password","cloudera")
params.set("query","select * from emp"),etc.
This is the third time I am posting this question but no one giving me exact solution or just tell me, is it possible or not?