public static void main(String[] args) throws Exception { // TODO Auto-generated method stub String collectionName = "schemaless_search"; // solr服务器的IP CloudSolrClient client = new CloudSolrClient("172.24.133.13"); CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete(); // 如果存在schemaless_search文件夹则先删除 delete.setCollectionName(collectionName); CollectionAdminResponse response; try { response = delete.process(client); System.out.println(response); } catch (Exception e) { e.printStackTrace(); } CollectionAdminRequest.Create create = new CollectionAdminRequest.Create(); create.setCollectionName(collectionName); // 目录/configs/solrcloud/schemaless_search下找到文件并加载 create.setConfigName("solrcloud/" + collectionName); create.setNumShards(2); create.setMaxShardsPerNode(2); create.setReplicationFactor(2); response = create.process(client); client.close(); }
到目前为止所有的配置都完成了,访问solr服务器的可以看到下图。
2015-09-17 20:36:22
在 Ubuntu 12.04 LTS 上通过 Tomcat 部署 Solr 4