34
votes

I want to use the schema.xml rather than the managed schema so I changed the following in the solrconfig.xml to the below

<schemaFactory class="ManagedIndexSchemaFactory">
    <bool name="mutable">true</bool>
    <str name="managedSchemaResourceName">managed-schema</str>
  </schemaFactory>

to

<schemaFactory class="ClassicIndexSchemaFactory"/> 

But I get The indexschema is not mutable error when I try to Index a flat file using the post command.

6

6 Answers

73
votes

Remove the AddSchemaFieldsUpdateProcessorFactory section from the updateRequestProcessorChain config in your solrconfig.xml

The schemaFactory option in solrconfig.xml. This controls whether the Schema should be defined as a "managed index schema": schema modification is only possible through the Schema API. By default, if no schemaFactory is specified, then the default behavior is to use the "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.

When ManagedIndexSchemaFactory is specified instead, Solr will load the schema from he resource named in managedSchemaResourceName, rather than from schema.xml.

AddSchemaFieldsUpdateProcessorFactory : This processor will dynamically add fields to the schema if an input document contains one or more fields that don't match any field or dynamic field in the schema.

read more on the same here https://lucene.apache.org/solr/4_6_0/solr-core/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.html

In short the above process factory is used for managed schema. When one does not want to use ManagedIndexSchemaFactory it should be removed from the updateRequestProcessorChain.

For more details of it you can check out the solr code or read the source code of the AddSchemaFieldsUpdateProcessorFactory.java Debug the method processAdd(AddUpdateCommand cm) , will help more on the same.

With the updated version of Solr 7.2 you need to the update.autoCreateFields to false in the updateRequestProcessorChain definition in solrconfig.xml.

<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:false}"
                             processor="uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date,add-schema-fields">
12
votes

At least in Solr 7.2 you should probably just switch update.autoCreateFields to false in the updateRequestProcessorChain definition in solrconfig.xml as the comment indicates.

<!-- The update.autoCreateFields property can be turned to false to disable schemaless mode -->
<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:false}"
                             processor="uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date,add-schema-fields">
    <processor class="solr.LogUpdateProcessorFactory"/>
    <processor class="solr.DistributedUpdateProcessorFactory"/>
    <processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>

That worked for and now I'm only getting pretty error messages like

Error from server at http://localhost:8983/solr: ERROR: [doc=urn:nbn:cz:tst01-000001] unknown field 'title'

as I'm tuning my static, unmanaged schema in schema.xml.

3
votes

Update autoCreateFields to false in solrconfig.xml.

${update.autoCreateFields:false}

2
votes

Another way to do this instead of editing your solrconfig.xml file is to add the update.autoCreateFields=false value to your core.properties file.

0
votes

For SOLR 7.7.2

Remove 'add-schema-field' from the updateRequestProcessorChain.

  <updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:true}"
                               processor="uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date">
    <processor class="solr.LogUpdateProcessorFactory"/>
    <processor class="solr.DistributedUpdateProcessorFactory"/>
    <processor class="solr.RunUpdateProcessorFactory"/>
  </updateRequestProcessorChain>
-1
votes

I realize this post is old but I ran into the same behavior today when importing a json file. The issue was the .json was not properly formed. It was missing the [] (square brackets) at the top and bottom of the file and the ',' (commas) between the objects. I validated the file using http://jslint.com/. The error was resolved once i made these changes.

NOTE: These were the issues which kept my file from being properly formed. I would suggest that you run your data through some type of validator to rule out whatever issue(s) your file MAY be having.

I hope this helps.