Solr 创建核心时出错:在模式中找不到 fieldType [x]

Solr error creating core: fieldType [x] not found in the schema

我正在尝试获得我自己的 Solr 核心 运行 schema.xml,但 Solr(版本 5.2.1)一直抱怨缺少 fieldType 甚至不在其中的元素我的 fields 定义。

org.apache.solr.common.SolrException: fieldType 'booleans' not found in the schema

每当我添加 'missing' fieldtype 时,都会弹出另一个错误,抱怨缺少另一个 fieldType,例如 longs,等等,直到我将它们全部添加架构被无误地接受。

为什么我必须提供这些 fieldtype 元素,而这些元素没有用?

config.xml 我有:

<schemaFactory class="ClassicIndexSchemaFactory"/>

这是我的 schema.xml:

<schema name="collections" version="1.5">

<fields>
    <field name="id_object" type="string" indexed="true" stored="true" />
    <field name="id_organization" type="string" indexed="true" stored="true"  />
    <field name="title" type="string" indexed="true" stored="true"  />
    <field name="artist" type="string" indexed="true" stored="true"  />
    <field name="searchname" type="string" indexed="true" stored="true"  />
    <field name="technique_group" type="string" indexed="true" stored="true"  />
    <field name="technique" type="string" indexed="true" stored="true"  />
    <field name="color_type" type="string" indexed="true" stored="true"  />
    <field name="color" type="string" indexed="true" stored="true"  />
    <field name="subject" type="string" indexed="true" stored="true"  />
    <field name="height" type="tint" indexed="true" stored="true"  />
    <field name="width" type="tint" indexed="true" stored="true"  />
    <field name="depth" type="tint" indexed="true" stored="true"  />
    <field name="price_sale" type="tfloat" indexed="true" stored="true"  />
    <field name="price_rental" type="tfloat" indexed="true" stored="true"  />
    <field name="price_rental_with_savings" type="tfloat" indexed="true" stored="true"  />
    <field name="savings_portion" type="tfloat" indexed="true" stored="true"  />
    <field name="year" type="tint" indexed="true" stored="true"  />
    <field name="is_for_rent" type="boolean" indexed="true" stored="true"  />
    <field name="is_for_sale" type="boolean" indexed="true" stored="true"  />
    <field name="status" type="string" indexed="true" stored="true"  />
    <field name="shipment" type="tfloat" indexed="true" stored="true"  />
    <field name="timestamp" type="tdate" indexed="true" stored="true" default="NOW" />

    <!-- catch all field, must be multiValued if any of its source fields is -->
    <field name="quick_search" type="text" indexed="true" stored="false" />

    <!-- mandatory -->
    <field name="_version_" type="tlong" indexed="true" stored="true" />

</fields>

<uniqueKey>id_object</uniqueKey>

<copyField source="id_object" dest="quick_search" />
<copyField source="title" dest="quick_search" />
<copyField source="artist" dest="quick_search" />
<copyField source="searchname" dest="quick_search" />
<copyField source="technique_group" dest="quick_search" />
<copyField source="technique" dest="quick_search" />
<copyField source="color_type" dest="quick_search" />
<copyField source="color" dest="quick_search" />
<copyField source="subject" dest="quick_search" />

<types>
    <fieldtype name="string" class="solr.StrField" />
    <fieldtype name="boolean" class="solr.BoolField" />
    <fieldtype name="tint" class="solr.TrieIntField" />
    <fieldtype name="tlong" class="solr.TrieLongField" />
    <fieldtype name="tfloat" class="solr.TrieFloatField" />
    <fieldtype name="tdate" class="solr.TrieDateField" />
    <fieldtype name="text" class="solr.TextField"/>
</types>

</schema>

那里没有一个 multiValued 字段。尽管如此,我尝试单独为每个字段显式设置 multiValued='false',但无济于事。即使我将整个模式剥离为少数 String 字段,它仍然会生成该错误。

我非常有信心我的 schema.xml 没问题,但也许某处的某些设置应该告诉 Solr 放轻松。

不确定这是否是首选方式,但注释掉 config.xml 中的 solr.AddSchemaFieldsUpdateProcessorFactory 部分似乎可以解决问题。

<!--
<processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
  <str name="defaultFieldType">strings</str>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Boolean</str>
    <str name="fieldType">booleans</str>
  </lst>
  <lst name="typeMapping">
    <str name="valueClass">java.util.Date</str>
    <str name="fieldType">tdates</str>
  </lst>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Long</str>
    <str name="valueClass">java.lang.Integer</str>
    <str name="fieldType">tlongs</str>
  </lst>
  <lst name="typeMapping">
    <str name="valueClass">java.lang.Number</str>
    <str name="fieldType">tdoubles</str>
  </lst>
</processor>
-->
<lst name="typeMapping">
    <str name="valueClass">java.lang.Boolean</str>
    <str name="fieldType">booleans</str>
</lst>

在此处您需要将“布尔值”更正为“布尔值”。

<lst name="typeMapping">
    <str name="valueClass">java.lang.Boolean</str>
    <str name="fieldType">boolean</str>
</lst>

然后就可以了..

或者

替代解决方案是注释掉 solrconfig.xml 中的 <updateRequestProcessorChain name="add-unknown-fields-to-the-schema"> 部分。