The main features of SolrCloud are:

Key features include powerful full-text search, click display, face search, dynamic clustering, database integration, rich document (such as Word, PDF) processing, and spatial search, and it has a high degree of scalability, providing fault tolerant distributed search and indexing.

1) Centralized configuration information 2) automatic fault tolerance 3) near real-time search 4) automatic load balancing during queries

Figure 1. Rough structure diagram of Collection

! [osjp-vertx-fig1-thumb-100159570-orig](<br>
1, 2, download, download 3, download at

Here’s where I start my learning journey:

Start by copying three tomcats such as tomcat-server_1 port: 8080 tomcat-server_2 port: 8090 tomcat-server_3 port: 8100

One, in the reproduction solr – 4.7.0 respectively. The following example/webapps solr war decompression is copied to the tomcat server_1, tomcat server_2, tomcat – server_3 webapp for solr below, Create three folders (solr_home_1, solr_home_2, and solr_home_3) for storing solr data. Solr_home_1, solr_home_2, solr_home_3, solr_home_3 Figure 2:

! [osjp-vertx-fig1-thumb-100159570-orig](<br>

Solr_home_1, solr_home_2, solr_home_3, solr_home_3

<solr> < solrCloud > < STR name="host">${host:}</ STR > <int name="hostPort">${jetty.port:8080}</int>// Tomcat port < STR name="hostContext">${hostContext:solr}</str> <int name="zkClientTimeout">${zkClientTimeout:30000}</int> <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool> </solrcloud> <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory"> <int name="socketTimeout">${socketTimeout:0}</int> <int Name ="connTimeout">${connTimeout:0}</int> </shardHandlerFactory> </solr>

Three, respectively into the tomcat – server_1, tomcat server_2, tomcat server_3 webapp below the solr below, and then go to the WEB – a WEB under the INF. XML, respectively, the following list:

<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>D:/solrCloud/solr_home_1</env-entry-value>// <env-entry-type>java.lang.String</env-entry-type> </env-entry> <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>D:/solrCloud/solr_home_2</env-entry-value>// Env-entry-value >// <env-entry-type>java.lang.String</env-entry-type> </env-entry> <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>D:/solrCloud/solr_home_3</env-entry-value>// Define the address of the solr index <env-entry-type>java.lang.String</env-entry-type> </env-entry>

Catalina. bat in bin of tomcat-server_1, tomcat-server_2, tomcat-server_3

set java_opts=-Dsolr.home=d:/solrCloud/solr_home_1 -Dbootstrap_confdir=D:/solrCloud/solr_home_1/collection1/conf Set jAVA_OPTS = -dSolr. Home = D :/solrCloud/solr_home_2 - DzkHost = set JAVA_OPTS = - Dsolr. Home = d: / solrCloud/solr_home_3 - DzkHost =

5. Duplicate three ZOO for example:

ZK-server_1 port: 2181 ZK-server_2 port: 2182 ZK-server_3 port: 2182 ZK-server_3 port: 2181 ZK-server_2 port: 2182 ZK-server_3 port: Create two folders under zk-server_1, zk-server_2 and zk-server_3 as data and logs, respectively, to store data and logs. "Myid" = "myid"; "myid" = "myid"; D:\solrCloud\zk-server_1\conf\zoo.cfg: dataDir=D:/solrCloud/zk-server_1/data dataLogDir=D:/solrCloud/zk-server_1/logs clientPort=2181 Server.1 = 127.0.1:2888:3888 Server.2 = Server.3 = The other two configurations are as above.

Figure 3:

! [osjp-vertx-fig1-thumb-100159570-orig](<br> Let's start zk_server1, zk_server2, zk_server3. The diagram below:

Figure 4:

! [osjp vertx - fig1 - thumb - 100159570 - orig] ( < br > starts up, the first error is because can't find the other two zk, complains. This is not important, three start good will not report an error. < br > here we start tomcat server_1, tomcat server_2, tomcat - server_3. <br>

Figure 5:

! [osjp-vertx-fig1-thumb-100159570-orig](

Figure 6:

! [osjp-vertx-fig1-thumb-100159570-orig](

create Node=2&collection.configName=myconf

Reload interface


Listing 1. SolrCloud. Java

    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Map;
    import org.apache.solr.client.solrj.SolrQuery;
    import org.apache.solr.client.solrj.SolrServer;
    import org.apache.solr.client.solrj.SolrServerException;
    import org.apache.solr.client.solrj.impl.CloudSolrServer;
    import org.apache.solr.client.solrj.response.QueryResponse;
    import org.apache.solr.common.SolrDocument;
    import org.apache.solr.common.SolrDocumentList;
    import org.apache.solr.common.SolrInputDocument;
    public class SolrCloud {
            private static CloudSolrServer cloudSolrServer;
            private static synchronized CloudSolrServer getCloudSolrServer(final String zkHost) {
            if (cloudSolrServer == null) {
                try {
                        cloudSolrServer = new CloudSolrServer(zkHost);
                    } catch (Exception e) {

        return cloudSolrServer;
    private void addIndex(SolrServer solrServer) {
        try {
            SolrInputDocument doc1 = new SolrInputDocument();
            doc1.addField("id", "421245251215121452521251");
            doc1.addField("title", "张三");
            SolrInputDocument doc2 = new SolrInputDocument();
            doc2.addField("id", "4224558524254245848524243");
            doc2.addField("title", "李四");

            SolrInputDocument doc3 = new SolrInputDocument();
            doc3.addField("id", "4543543458643541324153453");
            doc3.addField("title", "王五");

            Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();


        } catch (SolrServerException e) {
            System.out.println("Add docs Exception !!!");
        } catch (IOException e) {
        } catch (Exception e) {
            System.out.println("Unknowned Exception!!!!!");

   // 搜索
    public void search(SolrServer solrServer, String String) {
        SolrQuery query = new SolrQuery();
        try {
            QueryResponse response = solrServer.query(query);
            SolrDocumentList docs = response.getResults();
            for (SolrDocument doc : docs) {
                for (Map.Entry<String, Object> entry : doc) {
        } catch (SolrServerException e) {
        } catch (Exception e) {
            System.out.println("Unknowned Exception!!!!");
    public void deleteAllIndex(SolrServer solrServer) {
        try {
            solrServer.deleteByQuery("*:*");// delete everything!
        } catch (SolrServerException e) {
        } catch (IOException e) {
        } catch (Exception e) {
            System.out.println("Unknowned Exception !!!!");

    public static void main(String[] args) {
        final String zkHost = ",,";
        final String defaultCollection = "collection1";
        final int zkClientTimeout = 20000;
        final int zkConnectTimeout = 1000;

        CloudSolrServer cloudSolrServer = getCloudSolrServer(zkHost);
        System.out.println("The Cloud SolrServer Instance has benn created!");
        System.out.println("The cloud Server has been connected !!!!");
        SolrCloud test = new SolrCloud();
         test.addIndex(cloudSolrServer);, "id:*");
         test.deleteAllIndex(cloudSolrServer);, "id:*");


Build the Web server and messaging system using VERT.x

Application of RabbitMQ in Distributed System

The author information (the force spectrum SuYun LeapCloud _ cloud services research and development team members: JinYang Zhang starting address:

Welcome to WeChat Subscription Number: From Mobile to the Cloud (MaxLeap – Making Mobile Development Faster)

Welcome to join our LEAPCloud activity QQ group: 555973817, we will do technology sharing activities from time to time. If you need to reprint, please pay attention to bring the author’s information column and this We Media official number: LEAP-LEAPCLOUD, respect the original author’s labor achievements ~ thanks for your cooperation ~