EPiCommerce and Multiline Dictionary Meta Field Bug
I am in the early stages of a large EPiCommerce build and myself and one of my colleagues have been experiencing issues with Dictionary meta fields that allow multiple selections to be picked.
Basically the issue is that the values chosen in these fields do not appear in the faceted navigation. Some time last week we raised a support ticket with EPiServer to investigate the issue.
Today, on the way home from work I thought I would investigate this issue further and see if it is possible to find a work around to the problem. It just so happens there is
After using LUKE – Lucene Index Toolbox to analyse the indexes that were being created I could see that the values being stored for my multiline enabled dictionary were always System.String.
When the CatalogEntry was being indexed the indexer was not sure what to do with the particular field type and just performed a ToString() on the string array of selected values and stored that in the index, that’s s**t
I last used Mediachase around 3-4 years ago and it seems the documentation and online forum support doesn’t seem much better than it was back then.
So I did some digging around through the various Mediachase configs and found this little beauty Mediachase.Search.config:
This config allows you to configure a search provider, you will see mine is configured to use the LuceneSearchProvider. You will also notice that you are able to configure an indexer .
I then decompiled the CatalogIndexBuilder and had a scan around the various methods and decided to implement my own Indexer which inherits the Medicachase.Search.Extensions.Indexers.CatalogIndexBuilder.
There is an AddMetaField method you can override and this contains all of the logic for populating the meta fields within the lucene document.
I then figured out where the problem code was. Basically there was an if statement like the following:
1: if (metaField.DataType == MetaDataType.DictionaryMultiValue)
Which needed to change to:
1: if (metaField.DataType == MetaDataType.DictionaryMultiValue || metaField.DataType == MetaDataType.EnumMultiValue)
When one of your meta fields is a dictionary which allows multiple selections it’s MetaDataType is an EnumMutiValue. This MetaDataType was not handled correctly within the out of the box Medichase CatalogIndexBuilder.
I then created a new class named LeesCatalogIndexBuilder within a new project named LeesSearchExtensions. I got hold of the decompiled code for the AddMetaField method and fixed the issue above and placed it within my new Indexbuilder class.
I am sure you would agree with me that this kind of bug should have been picked up by the Medichase testing process, but we all know bugs like this slip through. I don’t know whether other people have experienced this but multiple searches on google didn’t return any hits for the issue.
In summary, luckily it turned out there was a simple solution to the problem so myself and my colleagues can carry on with the out of the box faceted search functionality without having to reinvent the wheel .