Solr Multicore 是 solr 1.3 的新特性。其目是一个solr实例,可以有多个搜索应用。
下面着手来将solr给出的一个example跑出来。这篇文章是基于《利用SOLR搭建企业搜索平台 之——运行solr》,有不明白的请参见http://lianj-lee.javaeye.com/blog/424383
1、 找到solr下载包中的example文件夹,在它的下面有个multicore文件夹,将这个文件夹下面的所有东西copy到 c:/solr-tomcat/solr下面。
注意:有一个 solr.xml(这只是默认文件,当然也可以指定别的文件),如:
<solr persistent="false"> <cores adminPath="/admin/cores"> <core name="core0" instanceDir="core0" /> <core name="core1" instanceDir="core1" /> </cores> </solr>
这个文件是告诉solr应该加载哪些core,cores里有 core0,core1。core0(可以类比以前的solr.home)/conf目录下有schema.xml与solrconfig.xml,可以把实际应用
的复制过来。现示例就用官方的了。
2、启动tomcat,访问应用,就可以看到有 Admin core0 和 Admin core1
3、采用上面的默认solr.xml,索引文件将存放在同一个目录下面,在这里将存放在C:/solr- tomcat/solr/data,如果你想更改目录,或者两个应用存放在不同的目录,请参见下面的xml。
<core name="core0" instanceDir="core0"> <property name="dataDir" value="/data/core0" /> </core>
给core添加子元素 property,property的两个属性就不说了,一看就能明白!
solr.core.name -- The core's name as defined in solr.xml
solr.core.instanceDir -- The core's instance directory (i.e. the directory under which that core's conf/ and data/ directory are located)
solr.core.dataDir -- The core's data directory (i.e. the directory under which that core's index directory are located)
solr.core.configName -- The name of the core's config file (solrconfig.xml by default)
solr.core.schemaName -- The name of the core's schema file (schema.xml by default)
4、solr.xml具体含义:
1)solr
The <solr> tag accepts two attributes:
persistent - By default, should runtime core manipulation be saved in solr.xml so that it is available after a restart.
sharedLib - Path to a directory containing .jar files that are added to the classpath of every core. The path is relative to solr.home (where solr.xml sits)
2)cores
The <cores> tag accepts two attribute:
adminPath - Relative path to access the CoreAdminHandler for dynamic core manipulation. For example, adminPath="/admin/cores" configures access via http://localhost:8983/solr/admin/cores . If this attribute is not specified, dynamic manipulation is unavailable.
3)core
The <core> tag accepts two attributes:
name - The registered core name. This will be how the core is accessed.
instanceDir - The solr.home directory for a given core.
dataDir - The data directory for a given core. The default is <instanceDir>/data . It can take an absolute path or a relative path w.r.t instanceDir . Solr1.4
4)property
The <property> tag accepts two attributes:
name - The name of the property
value - The value of the property