Example usage for org.apache.solr.client.solrj.embedded EmbeddedSolrServer add

List of usage examples for org.apache.solr.client.solrj.embedded EmbeddedSolrServer add

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.embedded EmbeddedSolrServer add.

Prototype

public UpdateResponse add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException 

Source Link

Document

Adds a collection of documents

Usage

From source file:fr.jetoile.hadoopunit.component.SolrBootstrapTest.java

License:Apache License

private void injectIntoSolr(EmbeddedSolrServer client) throws SolrServerException, IOException {
    for (int i = 0; i < 1000; ++i) {
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("cat", "book");
        doc.addField("id", "book-" + i);
        doc.addField("name", "The Legend of the Hobbit part " + i);
        client.add(doc);
        if (i % 100 == 0)
            client.commit(); // periodically flush
    }//from   w ww  .ja  va2s . c  om
    client.commit();
}