1

Sitecore 9.0 update 2

Solr 6.6.2 and 6.6.3 (same result on both, both supported: https://kb.sitecore.net/articles/227897)

I'm facing an issue when I "Populate Managed Schema" from control panel. My managed-schema gets updated 99.9% correctly. The 0.1% that is incorrect is that the uniqueKey element value generates as id:

<uniqueKey>id</uniqueKey>

A correct managed-schema generates as:

<uniqueKey>_uniqueid</uniqueKey>

The rest of the file generates properly. While I can manually change the uniqueKey element value, I would prefer to get to the bottom of my issue (as I'm attempting to automate things, with this being a key step).

When I run "Populate Managed Schema", the modal indicates [Success]. However, when I rebuild a particular index I am greeted with this error:

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">2</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">Document is missing mandatory uniqueKey field: id</str><int name="code">400</int></lst>
</response>

Prior to this exception being thrown, the index rebuild progress modal progresses as expected, e.g. "Added 1,000 items to index".

As stated above, I've tested this on Solr 6.6.2 and 6.6.3 with the same result each time. It appears the issue is on the Sitecore side of things. No issues were reported during the installation of Sitecore and the rest of the pieces (Content Editor, Exp Editor, etc.) work properly.

Edit/Update

Comparison of my automated web root with a working 9.0.2 copy shows no discernable differences.

  • It randomly began working. Some combination of restarting Solr or something else. Will reproduce and post results. – jrap Nov 27 '18 at 21:55
3

This issue is a result of not reading the fine-print with regards to configuring Solr for Sitecore

From Sitecore:

Both of these links walk through the prerequisites needed prior to executing "Populate Managed Schema". They also both make the assumption that your Solr instance is currently NOT running. Notice this step on both links...

  1. Start Solr.

Solr must be started after the prerequisite schema changes are made. However, if Solr is currently running, it must be restarted (i.e. restart the Solr service). This will properly reload the core configurations into memory. From there the "Populate Managed Schema" action will execute correctly.

General Steps to Resolve

  1. On the Solr server, navigate to the folder that contains your cores, e.g. C:\Solr\solr-6.6.2\server\solr
  2. In the configsets folder, copy the basic_configs config set either to A) a new config set and then reference it from each core, or B) copy the conf folder to each core individually
  3. Make the two required schema changes:
    1. Set the value in <uniqueKey>id</uniqueKey> to _uniqueid.
    2. In the fields section, add field configuration for _uniqueid: <field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>
  4. RESTART SOLR/SOLR SERVICE
  5. Execute Populate Manged Schemas from Sitecore Control Panel

Note: These steps are not relevant for any xdb indexes. These indexes use the out-of-the-box configsets

  • Thanks @jrap this worked for me.Field with name _uniqueid is already populated for me in field configuration.So i need not add the step 2 in 3. – Rama Krshna Ila Feb 8 '19 at 17:22
0

Are you using the default implementation of ISchemaPopulateHelper (Sitecore.ContentSearch.SolrProvider.Pipelines.PopulateSolrSchema.SchemaPopulateHelper)?

Over the last year I've found a few issues in the default implementation. Take a look at that class and compare it with your Solr managed schema. In GetAllFields() a list of add/remove/replace fields are generated. Oddly, this is an XML representation that is later converted into JSON, that in turn is sent to the Solr REST API.

Are you perhaps having an id field in your schema, so that adding the _uniqueid field (from GetAddFields()) fails? See if GetRemoveFields contains removal of your existing id field.

Regardless, it could be worth doing your own implementation of ISchemaPopulateHelper in order to fix some language stemming issues etc. More details here: https://mikael.com/2018/01/working-with-content-search-and-solr-in-sitecore-9/

  • This was a completely vanilla install. No customizations. – jrap Nov 28 '18 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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