lb5645284 发表于 2016-12-15 06:41:45

Solr Multicore 试用小记

  
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(这只是默认文件,当然也可以指定别的文件),如:

[*]<?xml version="1.0" encoding="UTF-8" ?>  
[*]  
[*]<solr persistent="false">  
[*]  
[*]  <cores adminPath="/admin/cores">  
[*]    <core name="core0" instanceDir="core0" />  
[*]    <core name="core1" instanceDir="core1" />  
[*]  </cores>  
[*]</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文件,如:

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

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

[*]E:\solr1.3\example\multicore\exampledocs>java -Durl=http://localhost:8080/solr-cores/core0/update -Dcommit=yes -jar post.jar ipod_video.xml  
[*]SimplePostTool: version 1.2  
[*]SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported  
[*]SimplePostTool: POSTing files to http://localhost:8080/solr-cores/core0/update..  
[*]SimplePostTool: POSTing file ipod_video.xml  
[*]SimplePostTool: COMMITting Solr index changes..  
[*]  
[*]E:\solr1.3\example\multicore\exampledocs>java -Durl=http://localhost:8080/solr-cores/core1/update -Dcommit=yes -jar post.jar ipod_other.xml  
[*]SimplePostTool: version 1.2  
[*]SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported  
[*]SimplePostTool: POSTing files to http://localhost:8080/solr-cores/core1/update..  
[*]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
有结果了吧!
页: [1]
查看完整版本: Solr Multicore 试用小记