Name (Lookup) Value List field containing IDs without braces is not indexed


Description

With fields of types Name Value List and Name Lookup Value List, it is possible to reference items by ID. If the selected IDs are stored without curly brackets, then the field value cannot be indexed. The following message can be found in the Crawling logs:

FATAL Could not add field {6AC5BD92-75AE-4EF8-9D9E-BA61A96762B0} : fieldname for indexable sitecore://master/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}?lang=en&ver=1
Exception: System.ArgumentOutOfRangeException
Message: Index and length must refer to a location within the string.
Parameter name: length
Source: mscorlib
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Sitecore.Data.ShortID.Encode(String guid)
   at Sitecore.ContentSearch.FieldReaders.NameValueListFieldReader.GetFieldValue(IIndexableDataField indexableField)
   at Sitecore.ContentSearch.FieldReaders.FieldReaderMap.GetFieldValue(IIndexableDataField field)
   at Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder.AddField(IIndexableDataField field)
   at Sitecore.ContentSearch.AbstractDocumentBuilder`1.CheckAndAddField(IIndexable indexable, IIndexableDataField field)

Solution

To resolve the issue, upgrade your solution to Sitecore XP 10.3.0 or later.

Alternatively, to prevent the issue, consider one of the following options: