I've upgraded from sc90 to sc92 and faced the following problem with field types in solr:


sitecore field type: DropLink
solr doc: "accommodation_type_s":"6f75a5e4380448c7b95820e14b4bab12"
predicate.Or(i => i["accommodation_type_s"] == value)
=> solr query: accommodation_type_s:(6f75a5e4380448c7b95820e14b4bab12)


sitecore field type: DropLink
solr doc: "accommodation_type_sm":["6f75a5e4380448c7b95820e14b4bab12"]
predicate.Or(i => i["accommodation_type_sm"] == value)
=> solr query: ERROR Solr Error : ["undefined field accommodation_type"] - Query attempted: accommodation_type:(6f75a5e4380448c7b95820e14b4bab12)...

Looks like all single-link field types became list of guids instead of string guid in solr documents.

I can't use strongly typed objects to make query like i.AccommodationType.Contains(guid) or == guid because all queries are dynamically built and I don't know what field will be used to make it.

I've seen suggestions from other similar issues here that recommend:

by patching the returnType to string

But the main problem for me is why does the query i["accommodation_type_sm"] == value ignore the _sm postfix and raise an error in the search logs?


Finally found the reason (thanks Sitecore support).

I use a custom search index that does not include the /sitecore/templates sub-tree.

Solution if you are not able to use POCO objects with field types and field names definition you should include this section in your index config (normally sitecore_master/web_index as value) and use exact field name without any transformations (f.e. don't use "accommodation_type_sm" but use "Accommodation type" to build the predicate).

The last section from this doc actually describes this problem: https://doc.sitecore.com/developers/93/platform-administration-and-architecture/en/using-solr-field-name-resolution.html

| improve this answer | |

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.