0

I'm upgrading our application from Sitecore 8.2 to 9.3 and we are working on Solr 8.1 where there are lots of multilist fields available as below: "document_languages_sm":["af58419145c9420187405409f4cf8bdd", "96f021639342449088cf73b79727a58e", "0ac792397513488bb1bb3dadc248270e"], "video_languages_sm":["af58419145c9420187405409f4cf8bdd"] and so on

And we are defining these multilist in Sitecore 9.3 code as below:

 [IndexField(Constants.IndexFields.DocumentLanguages)]
    public List<string> DocumentLanguages { get; set; }

    [IndexField(Constants.IndexFields.VideoLanguage)]
    public List<string> VideoLanguages { get; set; }

And this is how we have mapped the Solr fields in our local

 public const string DocumentLanguages = "document_languages_sm";
 public const string VideoLanguages = "video_languages_sm";

But we are getting 0 results for the below code though the results are available in Solr:

  queryable = FilterOnLocation(queryable, rootItems, excludedRootItems, query.Language).Cast<IndexedItem>();
            resultItem = queryable.GetResults();

We are getting results for other datatypes like "string" but not for List<string>. Could anyone suggest us on this issue?

0

Change your property types from List<string> to IEnumerable<ID> and add [TypeConverter(typeof(IndexFieldEnumerableConverter))] attribute.

It is possible that Sitecore cannot convert from field which comes back from Solr to List<string> as it's not defined in config.

So it would be:

[IndexField(Constants.IndexFields.DocumentLanguages)]
[TypeConverter(typeof(IndexFieldEnumerableConverter))]
public IEnumerable<ID> DocumentLanguages { get; set; }

[IndexField(Constants.IndexFields.VideoLanguage)]
[TypeConverter(typeof(IndexFieldEnumerableConverter))]
public IEnumerable<ID> VideoLanguages { get; set; }
1
  • I tried the above solution...but it did not work for me
    – Geetha
    Jul 9 at 9:57
0

Try to use at mapping the field names without _sm suffix, and try to the type to IEnumerable.

I had same issue before, and if the aboves doesn't work add by field names in index configuration like the following:

<fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">
    <fieldNames hint="raw:AddFieldByFieldName">
         <field fieldName="document_languages" returnType="stringCollection" />
         <field fieldName="video_languages" returnType="stringCollection" />

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.