List of usage examples for org.apache.solr.client.solrj.request UpdateRequest commit
public UpdateResponse commit(SolrClient client, String collection) throws IOException, SolrServerException
From source file:org.deeplearning4j.nn.dataimport.solr.client.solrj.io.stream.TupleStreamDataSetIteratorTest.java
License:Apache License
@BeforeClass public static void setupCluster() throws Exception { final int numShards = 2; final int numReplicas = 2; final int maxShardsPerNode = 1; final int nodeCount = (numShards * numReplicas + (maxShardsPerNode - 1)) / maxShardsPerNode; // create and configure cluster configureCluster(nodeCount).addConfig("conf", configset("mini")).configure(); // create an empty collection CollectionAdminRequest.createCollection("mySolrCollection", "conf", numShards, numReplicas) .setMaxShardsPerNode(maxShardsPerNode).process(cluster.getSolrClient()); // compose an update request final UpdateRequest updateRequest = new UpdateRequest(); final List<Integer> docIds = new ArrayList<Integer>(); for (int phase = 1; phase <= 2; ++phase) { int docIdsIdx = 0; if (phase == 2) { Collections.shuffle(docIds); }//from ww w . j a v a2 s .c om final int increment = 32; for (int b = 0; b <= 256; b += increment) { if (256 == b) b--; for (int g = 0; g <= 256; g += increment) { if (256 == g) g--; for (int r = 0; r <= 256; r += increment) { if (256 == r) r--; if (phase == 1) { docIds.add(docIds.size() + 1); continue; } final float luminance = (b * 0.0722f + g * 0.7152f + r * 0.2126f) / (255 * 3.0f); // https://en.wikipedia.org/wiki/Luma_(video) final SolrInputDocument doc = sdoc("id", Integer.toString(docIds.get(docIdsIdx++)), "channel_b_f", Float.toString(b / 255f), "channel_g_f", Float.toString(g / 255f), "channel_r_f", Float.toString(r / 255f), "luminance_f", Float.toString(luminance)); updateRequest.add(doc); ++numDocs; } } } } // make the update request updateRequest.commit(cluster.getSolrClient(), "mySolrCollection"); }