1. 索引目录结构
基本目录结构
-------------------------
Solr主目录通常包含下面的子目录…
conf/
这个目录是必需的并且必须包含solrconfig.xml和schema.xml. 任何其他可选的配置文件也应该放在这里。
data/
这个目录是存放索引的默认位置,并且被replication脚本用来处理snapshots. 你可以在conf/solrconfig.xml中覆盖这个目录。如果目录不存在,Solr会自动创建。
lib/
这个目录是可选的。如果存在,Solr将载目录中的Jars,并且用来解决你在solrconfig.xml或schema.xml中配置的任何插件(如,Analyzers, RequestHandlers, 等…)。替代的,你可以在conf/solrconfig.xml中使用<lib>语法来指定你的插件。
2. 新建索引集合
---- Add Core报错1:
ErrorCREATEing SolrCore 'resume': Unable to create core: resume Caused by: _version_field must exist in schema, using indexed="true" ordocValues="true", stored="true" andmultiValued="false" (_version_ does not exist)Error CREATEing SolrCore 'position': Unable tocreate core: position Caused by: Invalid Number: MA147LL/A
---------
Note that if youhave enabled the QueryElevationComponent insolrconfig.xml it requires the schema to have auniqueKey of typeStrField. It cannot be, forexample, an int field.
Otherwise, you willget exception like:
java.lang.NumberFormatException:For input string: "MA147LL/A"
-----
在solrconfig.xml中启用QueryElevationComponent (结果置顶功能)需要有一个StrField类型的唯一键,启用这个功能需要配置elevate.xml,查看elevate.xml
<elevate>
<query text="foo bar">
<doc id="1" />
<doc id="2" />
<doc id="3" />
</query>
<query text="ipod">
<doc id="MA147LL/A"/> <!-- put the actual ipod at thetop -->
<doc id="IW-02"exclude="true" /> <!-- exclude this cable -->
</query>
这是从core0拷贝过来的默认配置,id为String,而在自己的集合配置中ID字段是整型的。
不需要使用这个功能,将下面的配置注释掉,重新添加集合即可。
------ conf/solrconfig.xml-----
<!-- Query Elevation Component
http://wiki.apache.org/solr/QueryElevationComponent
a search component that enables you toconfigure the top
results for a given query regardless ofthe normal lucene
scoring.
-->
<!--
<searchComponent name="elevator"class="solr.QueryElevationComponent" >
-->
<!-- pick a fieldType to analyze queries -->
<!--
<strname="queryFieldType">string</str>
<strname="config-file">elevate.xml</str>
</searchComponent>
-->