我在本地主機上安裝了solr。Solr 6.0.0 - SolrCloud java示例
我開始標準solr雲示例與嵌入式zookeepr。
集合:gettingstarted 碎片:2 複製:2
500條記錄/文檔處理時間了115秒[本地主機傢俱測試] - 這是爲什麼採取這麼多的時間來處理只是500條記錄。 是有改善這對一些的毫秒的方式/ nanosecs
注:
我已經測試遠程機器上的相同的solr例如,本地主機上遠程solr的[內部的java評論]具有數據索引
我開始我的soller myCloudData集合與Ensemble單zookeepr。
2 Solr的節點, 1合奏飼養員獨立
集合:myCloudData, 碎片:2, 複製:2
Solr的colud Java代碼
package com.test.solr.basic;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.common.SolrInputDocument;
public class SolrjPopulatorCloudClient2 {
public static void main(String[] args) throws IOException,SolrServerException {
//String zkHosts = "64.101.49.57:2181/solr";
String zkHosts = "localhost:9983";
CloudSolrClient solrCloudClient = new CloudSolrClient(zkHosts, true);
//solrCloudClient.setDefaultCollection("myCloudData");
solrCloudClient.setDefaultCollection("gettingstarted");
/*
// Thread Safe
solrClient = new ConcurrentUpdateSolrClient(urlString, queueSize, threadCount);
*/
// Depreciated - client
//HttpSolrServer server = new HttpSolrServer("http://localhost:8983/solr");
long start = System.nanoTime();
for (int i = 0; i < 500; ++i) {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("cat", "book");
doc.addField("id", "book-" + i);
doc.addField("name", "The Legend of the Hobbit part " + i);
solrCloudClient.add(doc);
if (i % 100 == 0)
System.out.println(" Every 100 records flush it");
solrCloudClient.commit(); // periodically flush
}
solrCloudClient.commit();
solrCloudClient.close();
long end = System.nanoTime();
long seconds = TimeUnit.NANOSECONDS.toSeconds(end - start);
System.out.println(" All records are indexed, took " + seconds + " seconds");
}
}
感謝您指點我。我正忙於設置2個Solr實例,1個zookeeper實例,所以我用zookeeper znode來解決solr問題。我沒有看代碼深層驅動。謝謝,這已解決。 –