0

I am trying to use KamSars approach to indexing subcontent (pagecomponents) in my Sitecore 9.2.0 solution. It works fine in my Solr index locally, but when I try to add the two new computed index fields in Azure, they are not showing up in the Azure portal OR they show up with NULL values.

Here is my configuration: (Azure.DefaultConfiguration)

<?xml version="1.0" encoding="utf-8" ?>
<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 ContentDelivery or ContentManagement" search:require="azure">
    <settings>
      <setting name="ContentSearch.Azure.SwitchOnRebuild" value="false"/>
    </settings>
    <contentSearch>
      <indexConfigurations>
        <searchCloudIndexConfiguration ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration">
          <fieldMap ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/fieldMap">
              <fieldNames hint="raw:AddFieldByFieldName">
                <field fieldName="renderedContent" cloudFieldName="renderedContent" searchable="YES" retrievable="YES" facetable="YES" filterable="YES" sortable="YES" 
                boost="1f" type="System.String" settingType="Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure" cloudAnalyzer="lowercase_keyword" />                
              </fieldNames>
            </fieldMap>
          <documentOptions type="Sitecore.ContentSearch.DocumentBuilderOptions, Sitecore.ContentSearch">
            <indexAllFields>false</indexAllFields>

            <!-- Excluded templates -->
            <exclude hint="list:AddExcludedTemplate">
              <BucketFolderTemplateId>{ADB6CA4F-03EF-4F47-B9AC-9CE2BA53FF97}</BucketFolderTemplateId>
            </exclude>

            <!-- Included templates -->
            <include hint="list:AddIncludedTemplate">
              <Frontpage>{CC8444F9-EF2D-43BC-9E08-84446CF253FB}</Frontpage>
              <StandardPage>{69E35420-AF97-40FC-AC84-E2F4AE256BEB}</StandardPage>
              <NewsArticlePage>{EFB6DB4E-4A31-413F-AD26-E808A52ED0EF}</NewsArticlePage>
            </include>

            <!-- GLOBALLY INCLUDE FIELDS IN INDEX
                 This setting allows you to specify which fields to include in the index when the indexAllFields setting is set to false.
            -->
            <include hint="list:AddIncludedField">
              <__Boost>{93D1B217-B8F4-462E-BABF-68298C9CE667}</__Boost>
              <__Created_By>{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}</__Created_By>
              <Date_Range>{7146F1A4-45FB-4CEC-9855-C95E9E595827}</Date_Range>
              <ID>{5A531AF0-C44C-4141-A0D3-09C5CDC3D654}</ID>
              <Image_Dimensions>{05EF282C-54DE-49B5-9EF3-0EB3008080C6}</Image_Dimensions>
              <Language>{BC06ED64-C4A1-4EE2-9835-541E1CC4CCC9}</Language>
              <Parent_ID>{1F4412CC-609C-4D3C-AF8C-D5C849202916}</Parent_ID>
              <Text>{A60ACD61-A6DB-4182-8329-C957982CEC74}</Text>
              <Title>{75577384-3C97-45DA-A847-81B00500E250}</Title>
              <Search_Types_Text>{E600C190-3F61-4776-B2F5-03AD7AEB351C}</Search_Types_Text>
              <Updated_Date>{87A830FB-4E2F-4F76-896B-F20CFA2374DD}</Updated_Date>
              <Workflow_State>{49D86313-493D-4054-ACC9-D68AD6B09332}</Workflow_State>
            </include>
            <!-- COMPUTED INDEX FIELDS
               This setting allows you to add fields to the index that contain values that are computed for the item that is being indexed.
               You can specify the storageType and indextype for each computed index field in the <fieldMap><fieldNames> section.
            -->
            <fields hint="raw:AddComputedIndexField">
              <field fieldName="site"                           >Sitecore.ContentSearch.ComputedFields.Site,Sitecore.ContentSearch</field>
              <!-- indexes subcontent contents into parent's _content field in the index (for better site search) -->
              <field fieldName="_content" type="WSA.Feature.Search.SubContentField,WSA.Feature.Search" />
              <field fieldName="renderedContent" type="WSA.Feature.Search.SubContentField,WSA.Feature.Search" />
            </fields>
          </documentOptions>
        </searchCloudIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

Here is my configuration for the master-db:

<?xml version="1.0" encoding="utf-8" ?>
<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 type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="search_master_index" type="Sitecore.ContentSearch.Azure.CloudSearchProviderIndex, Sitecore.ContentSearch.Azure">
            <param desc="name">$(id)</param>
            <param desc="connectionStringName">cloud.search</param>
            <param desc="totalParallelServices">5</param>
            <!-- This initializes index property store. Id has to be set to the index id -->
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/searchCloudIndexConfiguration" >
              <scoringProfilesRepository ref="contentSearch/scoringProfilesRepository"/>
            </configuration>
            <schemaBuilder ref="contentSearch/searchServiceSchemaBuilder" />
            <searchService type="Sitecore.ContentSearch.Azure.Http.CompositeSearchService, Sitecore.ContentSearch.Azure"/>
            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these is controls the execution order -->
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
            </strategies>
            <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
              <policies hint="list:AddCommitPolicy">
                <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
                <policy type="Sitecore.ContentSearch.ModificationCountCommitPolicy, Sitecore.ContentSearch">
                  <Limit>1000</Limit>
                </policy>
              </policies>
            </commitPolicyExecutor>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>master</Database>
                <Root>/sitecore/content/Public Sites</Root>
              </crawler>
            </locations>
            <enableItemLanguageFallback>false</enableItemLanguageFallback>
            <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

EDIT FINDINGS If I add the following fieldmap:

<fieldMap ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/fieldMap">
  <fieldNames hint="raw:AddFieldByFieldName">
    <field fieldName="CustomContent" cloudFieldName="content_2" searchable="YES"  retrievable="NO" facetable="NO" filterable="NO" sortable="NO" boost="1f"
     type="System.String" settingType="Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure" />
    <field fieldName="renderedContent" cloudFieldName="renderedContent" searchable="YES" retrievable="YES" facetable="YES" filterable="YES" sortable="YES" 
    boost="1f" type="System.String" settingType="Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure" cloudAnalyzer="lowercase_keyword" />                
  </fieldNames>
</fieldMap>

and change my computedindexfield section to this:

<fields hint="raw:AddComputedIndexField">
  <field fieldName="CustomContent" type="WSA.Feature.Search.SubContentField,WSA.Feature.Search" />
  <field fieldName="renderedContent" type="WSA.Feature.Search.SubContentField,WSA.Feature.Search" />
</fields>

The field "renderedContent" shows up correct in Azure Search and so does the "CustomContent" field. However, I do not want to name my field "CustomContent", but instead it should be the builtin Azure-fieldname "content_1" for various reasons, but if I change the name to "content_1", it no longer shows up with the correct value in Azure Search.

My question is, is my configuration for the _content and _renderedContent fields incorrect, since they do not show up correctly in Azure search?

  • Try adding returnType="TYPE". But this shouldn't be a problem... – Dawid Rutkowski Sep 27 at 12:34
  • You are on to something. I will update the question with my findings. By adding the fieldmap section for "renderedContent", that field now correctly shows up in Azure search. Unfortunately, the same trick does not work for "_content" as that field already exists and seems to only contain its default value – Hos Sep 27 at 17:55
0

So as I wrote under findings it helped to add the fieldmap, update the computedindex section and finally added a cloudTypeMapper section. I never got the content into the built-in "_content" field, so if anyone can post an answer where that works I am willing to mark that as the solution.

Otherwise, this is the configuration that made the "renderedcontent" field work for me in Azure: (Azure.DefaultConfiguration)

<?xml version="1.0" encoding="utf-8" ?>
<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 ContentDelivery or ContentManagement" search:require="azure">
    <contentSearch>
      <indexConfigurations>
        <searchCloudIndexConfiguration ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration">
          <fieldMap ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/fieldMap">
            <!-- This setting allows you to map a field name in Sitecore to the index and store it in the appropriate way.
               fieldName:   The name of the field in the index.
               retrievable: means that field value shows up in search results list
               searchable:  means that a field is included in full text search.
               filterable:  whether a field can be used in a filter navigation structure
               facetable:   whether a field can be used in a facet navigation structure
               sortable:    whether a field can be used in a sort navigation structure
               boost:       The boost factor globally indicates the relative importance of this field at index and query time.
               type:        The type to cast the value back to in the API.
               settingType: The class implementation to store the information specified in all other fields.
            -->
            <fieldNames hint="raw:AddFieldByFieldName">
              <field fieldName="renderedcontent" cloudFieldName="renderedcontent" searchable="YES" retrievable="YES" facetable="YES" filterable="YES" sortable="YES"
              boost="1f" type="System.String" settingType="Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure" />
            </fieldNames>
          </fieldMap>
          <documentOptions type="Sitecore.ContentSearch.DocumentBuilderOptions, Sitecore.ContentSearch">
            <indexAllFields>false</indexAllFields>

            <!-- Excluded templates -->
            <exclude hint="list:AddExcludedTemplate">
              <BucketFolderTemplateId>{ADB6CA4F-03EF-4F47-B9AC-9CE2BA53FF97}</BucketFolderTemplateId>
            </exclude>

            <!-- Included templates -->
            <include hint="list:AddIncludedTemplate">
              <Frontpage>{CC8444F9-EF2D-43BC-9E08-84446CF253FB}</Frontpage>
              <StandardPage>{69E35420-AF97-40FC-AC84-E2F4AE256BEB}</StandardPage>
              <NewsArticlePage>{EFB6DB4E-4A31-413F-AD26-E808A52ED0EF}</NewsArticlePage>
            </include>

            <!-- GLOBALLY INCLUDE FIELDS IN INDEX
                 This setting allows you to specify which fields to include in the index when the indexAllFields setting is set to false.
            -->
            <include hint="list:AddIncludedField">
              <__Boost>{93D1B217-B8F4-462E-BABF-68298C9CE667}</__Boost>
              <__Created_By>{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}</__Created_By>
              <Date_Range>{7146F1A4-45FB-4CEC-9855-C95E9E595827}</Date_Range>
              <ID>{5A531AF0-C44C-4141-A0D3-09C5CDC3D654}</ID>
              <Image_Dimensions>{05EF282C-54DE-49B5-9EF3-0EB3008080C6}</Image_Dimensions>
              <Language>{BC06ED64-C4A1-4EE2-9835-541E1CC4CCC9}</Language>
              <Parent_ID>{1F4412CC-609C-4D3C-AF8C-D5C849202916}</Parent_ID>
              <Text>{A60ACD61-A6DB-4182-8329-C957982CEC74}</Text>
              <Title>{75577384-3C97-45DA-A847-81B00500E250}</Title>
              <Search_Types_Text>{E600C190-3F61-4776-B2F5-03AD7AEB351C}</Search_Types_Text>
              <Updated_Date>{87A830FB-4E2F-4F76-896B-F20CFA2374DD}</Updated_Date>
              <Workflow_State>{49D86313-493D-4054-ACC9-D68AD6B09332}</Workflow_State>
            </include>
            <!-- COMPUTED INDEX FIELDS
               This setting allows you to add fields to the index that contain values that are computed for the item that is being indexed.
               You can specify the storageType and indextype for each computed index field in the <fieldMap><fieldNames> section.
            -->
            <fields hint="raw:AddComputedIndexField">
              <field fieldName="site"                           >Sitecore.ContentSearch.ComputedFields.Site,Sitecore.ContentSearch</field>
              <!-- indexes subcontent contents into parent's _content field in the index (for better site search) -->
              <field fieldName="renderedcontent" type="CUSTOMER.Feature.Search.SubContentField,CUSTOMER.Feature.Search" />
            </fields>
          </documentOptions>
          <cloudTypeMapper ref="contentSearch/indexConfigurations/defaultCloudIndexConfiguration/cloudTypeMapper">
            <maps hint="raw:AddMap">
              <map type="CUSTOMER.Feature.Search.SubContentField,CUSTOMER.Feature.Search"  cloudType="Edm.String" />
            </maps>
          </cloudTypeMapper>
        </searchCloudIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

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.