Skip to content

Instantly share code, notes, and snippets.

@kenichiro22
Created July 20, 2012 03:41
Show Gist options
  • Save kenichiro22/3148507 to your computer and use it in GitHub Desktop.
Save kenichiro22/3148507 to your computer and use it in GitHub Desktop.
Request data import form Solrj
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
public class SolrDataImportClient {
private SolrServer server;
public SolrDataImportClient(SolrServer server) {
this.server = server;
}
public void fullImport(String... entities) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/dataimport");
params.set("command", "full-import");
if (entities != null && entities.length > 0) {
NamedList<String> list = new NamedList<String>();
for (String e : entities) {
list.add("entity", e);
}
params.add(SolrParams.toSolrParams(list));
}
try {
server.query(params);
} catch (SolrServerException e) {
e.printStackTrace();
}
}
public void deltaImport() {
throw new UnsupportedOperationException("Not implemented yet.");
}
}
@bdulac
Copy link

bdulac commented Nov 18, 2014

Hi, I am not sure to understand what entities you are registering in your params... I was convinced that the imported entities had to be registered in the data-config.xml. If the extracted entities could be set up dynamically, this could speed-up my indexing process (currently 24h for 13M documents). Could you tell me more about your experience ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment