`

Solr Multicore 试用小记

 
阅读更多

原文出处:http://blog.chenlb.com/2009/01/try-solr-multicore.html

Solr Multicore 是 solr 1.3 的新特性。其目的一个solr实例,可以有多个搜索应用。下面来小试一下。

官方发布的示例。在solr1.3/example/multicore目录(可以认为是multi.home)下,有一个 solr.xml(这只是默认文件,当然也可以指定别的文件),如:

  1. <? xml   version = "1.0"   encoding = "UTF-8"   ?>   
  2.   
  3. < solr   persistent = "false" >   
  4.   
  5.   < cores   adminPath = "/admin/cores" >   
  6.     < core   name = "core0"   instanceDir = "core0"   />   
  7.     < core   name = "core1"   instanceDir = "core1"   />   
  8.   </ cores >   
  9. </ solr >   

这个文件是告诉solr应该加载那些core,些文件里有 core0,core1两个core,对应有两个目录在multi.home目录下。core0(可以类比以前的solr.home)/conf目录下有 schema.xml与solrconfig.xml,可以把实际应用的复制过来。现示例就用官方的了。

部署:复制solr1.3/dist/apache-solr-1.3.0.war放到如tomcat服务器下的webapps下,并改名为 solr-cores.war(当然也可以其它)。在tomcat/conf/Catalina/localhost目录下写一个solr- cores.xml文件,如:

  1. < Context   docBase = "solr-cores.war"   reloadable = "true"   >   
  2.     < Environment   name = "solr/home"   type = "java.lang.String"   value = "E:/solr1.3/example/multicore"   override = "true"   />   
  3. </ Context >   

然后启动tomcat。打看 http://localhost:8080/solr-cores 就可以看到 Admin core0, Admin core1。现在提交数据了。把solr1.3/example/exampledocs/post.jar 复制到 solr1.3/example/multicore/exampledocs目录下。然后分别对两个core提交数据,如下:

  1. E:\solr1.3\example\multicore\exampledocs>java -Durl=http://localhost:8080/solr-cores/core0/update -Dcommit=yes -jar post.jar ipod_video.xml  
  2. SimplePostTool: version 1.2  
  3. SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported  
  4. SimplePostTool: POSTing files to http://localhost:8080/solr-cores/core0/update..  
  5. SimplePostTool: POSTing file ipod_video.xml  
  6. SimplePostTool: COMMITting Solr index changes..  
  7.   
  8. E:\solr1.3\example\multicore\exampledocs>java -Durl=http://localhost:8080/solr-cores/core1/update -Dcommit=yes -jar post.jar ipod_other.xml  
  9. SimplePostTool: version 1.2  
  10. SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported  
  11. SimplePostTool: POSTing files to http://localhost:8080/solr-cores/core1/update..  
  12. SimplePostTool: POSTing file ipod_other.xml  

提交好数据后,就可以查一下。
http://localhost:8080/solr-cores/core0/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on
http://localhost:8080/solr-cores/core1/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on

有结果了吧!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics