- indexing text files local to the server that Solr is running on using the update handler
- indexing data using an app using SolrJ that is running on the same server as Solr
- indexing data using an app using SolrJ that is on a different machine on the same network that the Solr server is on
The method looks like this:
public static void IndexValues(TestRecord[] testRecords)
throws IOException, SolrServerException {
HttpSolrServer server = new HttpSolrServer("http://localhost:8983/solr");
for(int i = 0; i < testRecords.length; ++i) {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", testRecords[i].getId());
for (Integer value : testRecords[i].getLookupIds()) {
doc.addField("lookupids", value);
}
server.add(doc);
if(i%100==0) server.commit(); // periodically flush
}
server.commit();
}
No comments:
Post a Comment