Date field gets added to cloud platform as a String type
I have a computed field used in a facet. It is used by both Sitecore and external sources and should be a Coveo "Date" type. I am trying to get the field to show up in the cloud platform panel as a Date type, but every time I rebuild my Sitecore index it shows up as "String". In my custom config I have:
<fieldType fieldName="aopaResultDate" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" isExternal="true" isSortable="true" type="System.DateTime" returnType="System.Date" />
I have also tried setting returnType to System.DateTime but no difference.
<field fieldName="AOPAResultDate" sourceField="AOPA.Library.Search.CoveoFields.ResultDate, AOPA.Library" returnType="datetime">AOPA.Library.Search.CoveoFields.ResultDate, AOPA.Library</field>
Why does this happen?
The type of a computed index field is determined by a mix of the fieldmap entry (if any) and the computed index field class. In your case, the `AOPA.Library.Search.CoveoFields.ResultDate` class. It must have a ReturnType property with a `get` that returns "datetime" as explained in this article: https://developers.coveo.com/x/agDvAQ
The `ComputeFieldValue` method should return a string formatted with the Coveo index date format "yyyy/MM/dd@HH:mm:ssZ".
The article also mentions that the fieldMap entry should have `type="System.DateTime" returnType="System.DateTime"`. You seem to have `returnType="System.Date"` in yours.
In your computed index field, I am not sure about your `sourceField` attribute value. This seems to be the filly qualified name of a constant or a class property. Are you using reflection in your computed field code to its value? If you are not, this attribute value should be the actual name of a Sitecore field item in one of your templates.