与之前版本不同,Solr5.5中默认不再使用schema.xml,取而代之的是Managed Schema,此种方式必须通过Schema API的方式进行管理,不太方便。现在改为传统的schema.xml的配置文件方式。
以下是简介:
“
The schemaFactory option in solrconfig.xml controls whether the Schema should be defined as a
"managed index schema": schema modification is only possible through the Schema API.
All of the example config sets use the managed schema by default.
By default,if no schemaFactory is specified,then the default behavior is to use the "ClassicIndexSchemaFactory":
<schemaFactory class="ClassicIndexSchemaFactory"/>
The ClassicIndexSchemaFactory requires the use of a schema.xml file,which can be edited manually and
is only loaded only when the collection is loaded. This setting disallows Schema API methods that modify the
schema.
”
首先通过默认方式启动solr 并创建core(这里命名为core1),这样会在solr-5.5.0/server/solr/core1/conf 目录下生成managed-schema,将此文件拷贝至同目录下名字为schema.xml。
然后编辑/solr-5.5.0/server/solr/core1/conf/solrconfig.xml,将以下代码注释掉:
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory>
同时新增<schemaFactory class="ClassicIndexSchemaFactory"/>
最后重启solr即可。
【Q&A】
1. Caused by: org.apache.solr.common.SolrException: Invalid Number: MA147LL/A
此问题是由于将schema.xml中的id设置为了int类型,<field name="id" type="int"
解决方式是把solr-5.5.0/server/solr/core1/conf中的elevate.xml的
<query text="ipod"> <doc id="MA147LL/A" /> <doc id="IW-02" exclude="true" /> </query> 注释掉