FacetResultParser returns incorrect values for date facets

Created on 26 September 2024, 3 months ago

I'm in the process of upgrading a site from elasticsearch_connector to search_api_opensearch. While testing, we spotted that an existing date facet on one of the views showed integers as the label instead of dates, and failed to filter properly when used. (It just went to a page of no results, with a warning message about the passed date value being incorrect.

Having turned off the "Date item processor" option in the facet so I got the raw values as the labels, I could see the value of the facet was time in milliseconds. Previously, this raw value was time in seconds.

elasticsearch_connector has code to handle the change from milliseconds to seconds in \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::parseDateFacets(). search_api_opensearch doesn't have any equivalent from what I could find.

I've copied the code from elasticsearch_connector to \Drupal\search_api_opensearch\SearchAPI\Query\FacetResultParser::parseFacetResult() and updated it to work. My date facets now display and filter as expected.

MR for this'll be incoming shortly.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom rupertj Bristol, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024