Tuesday, May 29, 2018

Sitecore and Azure Search - Conflict between type of incomming field and field in schema

When attempting to rebuild the web/master indexes for a Sitecore 9 instance using Experience Commerce and Azure Search as the provider, the logs were filled with the following fatal errors:
FATAL Could not add field {B775BCA9-2605-4D60-B367-A0C354BE2504} : default value for indexable sitecore://master/{2F5990B9-E6F2-4D2E-9179-7851789EB66C}?lang=da&ver=1Exception: System.ApplicationExceptionMessage: Conflict between type of incomming field 'Edm.String' and field in schema 'Edm.Boolean'Source: Sitecore.ContentSearch.Azure at Sitecore.ContentSearch.Azure.Schema.CloudSearchIndexSchemaBuilder.AddFields(IndexedField[] fileds) at Sitecore.ContentSearch.Azure.Schema.CloudSearchIndexSchemaBuilder.AddField(String fieldName, Object fieldValue, CloudSearchFieldConfiguration configuration, CultureInfo culture)   at Sitecore.ContentSearch.Azure.CloudSearchDocumentBuilder.AddField(String cloudName, Object fieldValue, CloudSearchFieldConfiguration cloudConfiguration, Boolean append, Boolean fieldIsEmpty)   at Sitecore.ContentSearch.Azure.CloudSearchDocumentBuilder.AddField(String fieldName, Object fieldValue, CloudSearchFieldConfiguration cloudConfiguration, Boolean append) at Sitecore.ContentSearch.Azure.CloudSearchDocumentBuilder.AddField(IIndexableDataField field)   at Sitecore.ContentSearch.AbstractDocumentBuilder`1.CheckAndAddField(IIndexable indexable, IIndexableDataField field)
Strangely enough, this bug was supposedly fixed in version 8.2 of Sitecore Experience Platform. However it's likely the addition of new fields in later version that were not fixed up have caused it to come back.

The issue boils down to the fact that Azure search will store a type against a given field name. So in the case above, the field {B775BCA9-2605-4D60-B367-A0C354BE2504} is called default value and is of type single-line text (string). A quick search for other fields called default value, leads to 3 others, including one of type checkbox (boolean) and another of type integer.

That's where the issue comes in, the first occurrence of the field name will set the type in stone. So the only fix (if you wish to stop these errors) is to exclude the "duplicate fields" from the index.

Below is a patch file which has cleaned up many of these errors for me, I have not found any adverse affects (as these are often irrelevant system fields as opposed to rich text content).
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore role:require="Standalone or ContentManagement" search:require="Azure">
    <contentSearch>
      <configuration>
        <indexes>
          <index id="sitecore_master_index">
            <configuration>
              <documentOptions ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/documentOptions">
                <exclude hint="list:AddExcludedField">
                  <NameConflictA tag="{EA2A0983-36EA-4957-B613-6F23EA5CDAD4}">{EA2A0983-36EA-4957-B613-6F23EA5CDAD4}</NameConflictA>
      <NameConflictG tag="{3F67BE6A-F3F0-41C5-B379-C6AF29685666}">{3F67BE6A-F3F0-41C5-B379-C6AF29685666}</NameConflictG>      
      <NameConflict1 tag="{FF1383BB-F095-4958-9B6D-E555DB653C44}">{FF1383BB-F095-4958-9B6D-E555DB653C44}</NameConflict1>
      <NameConflict2 tag="{D660A7A4-3F42-4953-A13F-CFCA850BDFEA}">{D660A7A4-3F42-4953-A13F-CFCA850BDFEA}</NameConflict2>
      <NameConflict3 tag="{7DC7CD49-9B23-4D44-B21E-FA5443224A50}">{7DC7CD49-9B23-4D44-B21E-FA5443224A50}</NameConflict3>
      <NameConflict4 tag="{B775BCA9-2605-4D60-B367-A0C354BE2504}">{B775BCA9-2605-4D60-B367-A0C354BE2504}</NameConflict4>
      <NameConflict5 tag="{E43E4E5F-6B45-4E3B-8D85-85AB87D2CC12}">{E43E4E5F-6B45-4E3B-8D85-85AB87D2CC12}</NameConflict5>
      <NameConflict6 tag="{CEDA3E7F-7406-40D0-A154-7CF7E3E7E85B}">{CEDA3E7F-7406-40D0-A154-7CF7E3E7E85B}</NameConflict6>
      <NameConflict7 tag="{4F17697F-BD00-4D76-B4F5-1B53C0C8D884}">{4F17697F-BD00-4D76-B4F5-1B53C0C8D884}</NameConflict7>
      <NameConflict8 tag="{BEFC61BF-8CFD-4478-9F5C-8422E6E2F005}">{BEFC61BF-8CFD-4478-9F5C-8422E6E2F005}</NameConflict8>
      <NameConflict9 tag="{4F892959-FDE6-4020-8569-2CF934BA412C}">{4F892959-FDE6-4020-8569-2CF934BA412C}</NameConflict9>
      <NameConflict10 tag="{85E2D73B-F11A-4BD7-9826-86BB191925C5}">{85E2D73B-F11A-4BD7-9826-86BB191925C5}</NameConflict10>
      <NameConflict11 tag="{EA45EDF7-CD8B-433F-99A6-EBFE3C7CE3A5}">{EA45EDF7-CD8B-433F-99A6-EBFE3C7CE3A5}</NameConflict11>
      <NameConflict14 tag="{1B9D1028-C20C-407B-9DCD-AFFE86A6F793}">{1B9D1028-C20C-407B-9DCD-AFFE86A6F793}</NameConflict14>
      <NameConflict15 tag="{09147FB2-EBFB-4949-8C8E-26A424409D5E}">{09147FB2-EBFB-4949-8C8E-26A424409D5E}</NameConflict15>
      <NameConflict16 tag="{3DD612C4-3AA7-48A9-9F46-FD8DE9AE3ACA}">{3DD612C4-3AA7-48A9-9F46-FD8DE9AE3ACA}</NameConflict16>
      <NameConflict17 tag="{F917C951-1F75-4D62-B14A-BC6888D7EECA}">{F917C951-1F75-4D62-B14A-BC6888D7EECA}</NameConflict17>
      <NameConflict18 tag="{290DEFD0-7B9A-4541-A326-87C44BEE5309}">{290DEFD0-7B9A-4541-A326-87C44BEE5309}</NameConflict18>
      <NameConflict19 tag="{59B79BAF-4F30-4ECA-961D-4AFAB14D157C}">{59B79BAF-4F30-4ECA-961D-4AFAB14D157C}</NameConflict19>
      <NameConflict20 tag="{9EDD2FCC-04AE-4230-84B4-C46C963F2284}">{9EDD2FCC-04AE-4230-84B4-C46C963F2284}</NameConflict20>
                </exclude>
              </documentOptions>
            </configuration>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>
Ignore the mismatched field names, this was after some cleanup.

No comments:

Post a Comment