Solr Unknown Field error

When attempting to rebuild the sitecore_master_index on a project I faced an issued regarding an unknown field. This is related to the language  support provided in the use of Solr’s managed schemas which was introduced in Sitecore 9.  Unfortunately the support for languages is not extensive and Populate Solr Managed Schema does not necessarily generate all of the languages that you need.

Job started: Index_Update_IndexName=sitecore_master_index|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SolrNet.Exceptions.SolrConnectionException: <?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">7</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.common.SolrException</str></lst><str name="msg">ERROR: [doc=sitecore://master/{f621b08b-ac40-428e-af9a-a6d8be8640b0}?lang=zh-sg&amp;ver=1&amp;ndx=sitecore_master_index] unknown field 'description_t_zh'</str><int name="code">400</int></lst>
</response>
---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse()
at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request)

Rather than the old implementation of using the schema.xml, Sitecore 9 now uses Solr’s managed schema which means that it is more reliant on using the SOLR RESTful API. This can be used to make changed and this is how the Populate Solr Managed Schema tool works. The managed schema is still held in a file under server/solr for each core but it is recommended that you do not directly edit it.

This can be viewed by selecting a Solr core through Files > Managed Schema

 

Unfortunately there is not full coverage and a number of the languages using the Populate Solr Managed Schema tool . In our instance zh-sg (Chinese) was not supported and we needed to solve this by adding a dynamic field

<dynamicField name="*_t_zh" type="text_general" indexed="true" stored="true" />

 

This would then represent something like the following which is held in the managed schema

This can be achieved by selecting the core sitecore_master_index and the menu  to select Schema. Once loaded you can select Add Dynamic Field and fill out the following details as shown below. Once this has been saved you can attempt to rebuild the index again.

name: *_t_zh

field Type: text_general

stored: Checked

indexed: Checked

 

After contacting Sitecore about this issue they raised this as an issue and suggested extending the Populate processor Sitecore.ContentSearch.SolrProvider.Pipelines.PopulateSolrSchema.PopulateFields in future scenarios to introduce this as part of the managed schema process

 

Further Reading:

https://doc.sitecore.com/developers/90/platform-administration-and-architecture/en/solr-managed-schemas.html

https://lucene.apache.org/solr/guide/6_6/schema-factory-definition-in-solrconfig.html

Leave a Reply

Your email address will not be published. Required fields are marked *