Solr error creating core: fieldType [x] not found

2019-03-28 08:30发布

问题:

I am trying to get a Solr core running with my own schema.xml, but Solr (version 5.2.1) keeps complaining about missing fieldType elements that aren't even in my fields definitions.

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

Whenever I add a 'missing' fieldtype another error pops up complaining about another fieldType missing, like longs, etc., until I've added them all and the schema is accepted without error.

Now how come I must provide these fieldtype elements when there is no use for them?

In config.xml I have:

<schemaFactory class="ClassicIndexSchemaFactory"/>

Here's my 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>

There is not a single multiValued field in there. Nonetheless I tried explicitly setting multiValued='false' for each field individually, but to no avail. Even when I strip the entire schema down to just a handful of String fields it still generates that error.

I'm pretty confident my schema.xml is OK but perhaps some setting somewhere should tell Solr to take it easy.

回答1:

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

over here you need to correct "booleans" to "boolean".

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

Then it will work..

Please check the links

https://lucene.apache.org/solr/4_6_0/solr-core/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.html

http://events.linuxfoundation.org/sites/events/files/slides/whats-new-in-apache-solr.pdf



回答2:

Not sure whether it is the preferred way to go, but commenting out the solr.AddSchemaFieldsUpdateProcessorFactory section in config.xml seems to solve the issue.

<!--
<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>
-->