Created
July 20, 2012 03:41
-
-
Save kenichiro22/3148507 to your computer and use it in GitHub Desktop.
Request data import form Solrj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?