When I add the recurring date to a view as a field it cannot be formatted as a date. Internally the default search_api widget is used, which outputs the data as a timestamp.

I managed to mitigate this by using the following code:

function <em>hook</em>_views_data_alter(array &$data) {
  $data['search_api_index_{$index_id}']['{$index_field_name}']['field']['id'] = 'search_api_date';
}

While this work-around is simple to implement it would be nice for the module to correctly set the field widget automatically as the code will need to be added for each index and field. The work-around only works for the "(indexed field)" variant of the data.

Weirdly the end_date gets the correct field widget, it's just then start value that cannot be formatted.

Field set-up:
Field settings

Output without work-around:

Output with work-around:

Comments

john cook created an issue. See original summary.

joachim’s picture

Title: Data is not formattable when used as a filed. » Data is not formattable when used as a field.
Version: 1.0.0-beta2 » 1.0.x-dev
Status: Active » Postponed (maintainer needs more info)

Do you mean the recurring date field, or the date occurrence computed field?

If it's the recurring date field, then it's a problem with Date Recur module. If it's the computed field, then the problem is probably in Search API, as the computed occurrence field is of type daterange.

This module doesn't actually declare any fields to the search index - our datasource plugin inherits from the one for entities in SearchAPI, and doesn't override getPropertyDefinitions().

nickdjm’s picture

Just wanted to chime in here and confirm that this looks like a SearchAPI issue.

https://www.drupal.org/project/search_api/issues/3353719

I've tried removing the check to see if the field is computed and it allows you to use the proper formatters.