0

We are using Sitecore 10.2 with Compatible SOLR 8.8.2. In our case we need to add two custom field in SOLR Indexing. By default SOLR using ManagedIndexSchemaFactory. If we add any new custom field in the Schema file its automatically disappear after Populate Schema file. After some analysis, I figure out we need to changed the schema factory from ManagedIndexSchemaFactory to ClassicIndexSchemaFactory. So I have followed the below things

  1. Create CORE file
  2. Renaming the "Managed-Schema" to schema.xml
  3. Changed the IndexFactory
  4. Updated the update.autoCreateFields to false
  5. Removed the whole processer "AddSchemaFieldsUpdateProcessorFactory"

https://stackoverflow.com/questions/31719955/solr-error-this-indexschema-is-not-mutable https://solr.apache.org/guide/8_2/schema-factory-definition-in-solrconfig.html

After done all the changes, restart the SOLR, Sitecore site and Go to control panel, click Indexing Manager and select the index. build started successfully but in the last minute I got the error "The IndexSchema is not mutable"

2 Answers 2

1

I'd suggest you keep the managed schema and change the DefaultPopulateHelperFactory class of the PopulateFields processor in the contentSearch.PopulateSolrSchema pipeline instead. Thereby you can keep the managed schema across all your Solr instances and the Populate Schema function will put your Solr schema into the expected state. The default DefaultPopulateHelperFactory is just a simple class implementing IPopulateHelperFactory, so you can roll your own with the changes you need.

If you want to be a bit more ambitious and drive your entire Solr managed schema from the Sitecore config files, you can do so as well. I wrote a post around that a few years ago with sample code: https://mikael.com/2020/10/dealing-with-solr-managed-schema-through-sitecore-config-files/

0

As per the Sitecore documents to add a custom field to the Solr schema, you can create a custom helper class to add custom fields to a Solr schema.

  1. Create a class that inherits SchemaPopulateHelper, and use this class to define the fields and the field types you want to add to the Solr schema
  2. Create a PopulateHelper factory class that inherits from IPopulateHelperFactory, implements the GetPopulateHelper method, and returns your custom class.
  3. Create a configuration patch file that overrides the Sitecore class factory with the one you created.

Try creating this way and it should work.

Refer to this document.

https://doc.sitecore.com/xp/en/developers/102/platform-administration-and-architecture/add-custom-fields-to-a-solr-schema.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.