How to do Solr Dataimport (i.e from RDBMS) using Java API?

我的未来我决定 提交于 2019-12-02 04:00:49

A little late answer, but it is possible, at least with Solr 7.1 (did not try previous version).

If you check at the http://yoursolrhostsolr/#/yourcore/dataimport//dataimport there is the possibility of executing an import with a custom data-config, by clicking on the debug mode.

By looking at the logs, you can see what commands the admin interfaces sends to solr. It calls the /dataimport handler passing a dataConfig=xml file as an argument.

So it can be done like this with SolrJ:

ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/dataimport");
params.set("command", "full-import");
params.set("dataConfig", <the data-import xml as string>);
solrClient.query(params);

By passing a dataConfig, the dataImportHandler ignores the configured data-import.xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!