1

Recently we have upgraded our project to Sitecore 10 & SOLR 8.4 , after the upgrade we set up the solr & rebuilt indexes for all indexes. But we are seeing a lot of index fields are stored/updated in SOLR as string collection with _sm([""]) , and it should be string with _s(""). These are not the computed fields. Can anyone let me know how to update the fields to string index fields.

2 Answers 2

7

We faced this issue while upgrading as well, so we noticed that some configurations need to be changed like in above @Marek answer you can see droplink|droptree returnType is stringCollection instead it should be string, if you change it index again then you will notice now droplink field will come as _s in solr indexing. So changed these as below -

<defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
<fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
    <!--  FIELD TYPE MAPPING
             This allows you to map a field type in Sitecore to a type in the index.
             USAGE: When you add new field types to Sitecore, add the mappings here so they work through the Linq Layer 
           -->
    <fieldTypes hint="raw:AddFieldByFieldTypeName">
        <fieldType fieldTypeName="checkbox" returnType="bool"/>
        <fieldType fieldTypeName="date|datetime" returnType="datetime"/>
        <fieldType fieldTypeName="html|rich text|single-line text|multi-line text|text|memo|image|reference" returnType="text"/>
        <fieldType fieldTypeName="word document" returnType="text"/>
        <fieldType fieldTypeName="integer" returnType="long"/>
        <fieldType fieldTypeName="number" returnType="float"/>
        <fieldType fieldTypeName="icon|droplist|grouped droplist" returnType="string"/>
        <fieldType fieldTypeName="checklist|multilist|treelist|tree list|treelistex|tree list|multilist with search|treelist with search" returnType="stringCollection"/>
        <fieldType fieldTypeName="name lookup value list|name value list" returnType="stringCollection"/>
        <fieldType fieldTypeName="grouped droplink|tree" returnType="stringCollection"/>
        <fieldType fieldTypeName="droplink|droptree" returnType="string"/>
    </fieldTypes>
</fieldMap>

Or instead of string you can use shortId as well, because droplink and droptree both store type is Guid ID

<fieldType fieldTypeName="droplink|droptree" returnType="shortid" />

And you can find typeMatch for shortID that also adds _s

<typeMatch typeName="shortid" type="Sitecore.Data.ShortID, Sitecore.Kernel" fieldNameFormat="{0}_s" settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />

Update 1 : You can add patch like below -

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" 
xmlns:set="http://www.sitecore.net/xmlconfig/set/">
   <sitecore>
    <contentSearch>
      <indexConfigurations>
        <defaultSolrIndexConfiguration>
          <fieldMap>
            <fieldTypes hint="raw:AddFieldByFieldTypeName">
              <fieldType fieldTypeName="droplink|droptree">
                <patch:attribute name="returnType">string</patch:attribute>
              </fieldType>
            </fieldTypes>
          </fieldMap>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch> 
   </sitecore>
</configuration>
3
  • Hi @gaurav , Thanks Your solution worked for me. But I have one small question , since this is part of default sitecore configuration, can you let me know how can i add this as a patch file so that next time indexing happens without any issues.
    – Harish
    Commented Jul 22, 2021 at 14:51
  • See updated commented Commented Jul 22, 2021 at 15:02
  • Thank you so much Gaurav..
    – Harish
    Commented Jul 22, 2021 at 15:55
1

You should check your SolrIndexConfiguration in /sitecore/admin/showconfig.aspx.

There should be entries for every type of the field and their corresponding type in Solr:

<defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
    <fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
        <!--  FIELD TYPE MAPPING
                 This allows you to map a field type in Sitecore to a type in the index.
                 USAGE: When you add new field types to Sitecore, add the mappings here so they work through the Linq Layer 
               -->
        <fieldTypes hint="raw:AddFieldByFieldTypeName">
            <fieldType fieldTypeName="checkbox" returnType="bool"/>
            <fieldType fieldTypeName="date|datetime" returnType="datetime"/>
            <fieldType fieldTypeName="html|rich text|single-line text|multi-line text|text|memo|image|reference" returnType="text"/>
            <fieldType fieldTypeName="word document" returnType="text"/>
            <fieldType fieldTypeName="integer" returnType="long"/>
            <fieldType fieldTypeName="number" returnType="float"/>
            <fieldType fieldTypeName="icon|droplist|grouped droplist" returnType="string"/>
            <fieldType fieldTypeName="checklist|multilist|treelist|tree list|treelistex|tree list|multilist with search|treelist with search" returnType="stringCollection"/>
            <fieldType fieldTypeName="name lookup value list|name value list" returnType="stringCollection"/>
            <fieldType fieldTypeName="droplink|droptree|grouped droplink|tree" returnType="stringCollection"/>
        </fieldTypes>
    </fieldMap>
</defaultSolrIndexConfiguration>

Most probably your upgrade went wrong and your configs are broken.

Make sure that the index configuration used by your indexes have same <fieldTypes> as in clean Sitecore installation of the same version that you use.

1
  • Thank you @Marek , let me check the configuration from my end & confirm it.
    – Harish
    Commented Jul 22, 2021 at 9:22

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.