We have upgraded from Sitecore 8 to Sitecore 10.1 and also updated Solr 6.6.2 to Solr 8.4

Some of the search from Solr was returning null. Upon investigation, I found out that the field type in Solr is string (_s). While in the Search log, the type passed in a query is text (_t).

As an example, the field in Solr is sustainabilitycasestudytag_s while in the search log, the query is sustainabilitycasestudytag_t_en:("Climate Change").

I had to fix this by adding the field in Solr

<field fieldName="sustainabilitycasestudytag" returnType="stringCollection" />      

After index rebuilding, the results from Solr are coming correctly.

I have found this issue with 3 or more fields and in order to fix this, I have added the returnType="stringCollection" in the config.

There may be other pages with the similar issue, is there any permanent way to fix this?. The fields in Solr are string(_s) while in the Search log, it is passed as text (_t)

Here is the code

public virtual string Tag { get; set; }

private Expression<Func<SustainabilityCaseStudySearchItem, bool>> ApplySustainabilityCaseStudyTagFilter(Expression<Func<SustainabilityCaseStudySearchItem, bool>> filterPredicate)
            var tagFilter = "Climate Change";
            if (!string.IsNullOrEmpty(tagFilter))
                return filterPredicate.And(x => x.Tag.Equals(tagFilter));

            return filterPredicate;
  • What field type is sustainabilitycasestudytag in Sitecore? Is it a computed field? How are you querying this field in the Content Search API? Can you share the code? Commented May 27, 2022 at 5:12
  • its not a computed field. I have updated the question with the code @ChetCheeto Commented May 27, 2022 at 5:30
  • And also use string instead stringCollection if the field holds one string value. I also faced this issue and ended up adding the field in config like you did. Commented May 27, 2022 at 8:12
  • And what type of field is sustainabilitycasestudytag? Sitecore will generally treat a RichText field as Text datatype in Solr, but a Single-line text field is treated as a string datatype. Commented May 28, 2022 at 0:39
  • @ChetCheeto its a dropdownlist field Commented May 28, 2022 at 4:08


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.