1

I would like to add a facet to a search_api view filtering on the content "changed" field. I would like to use friendly naming like "This week", "This month" etc. There is an answer here stating that custom code is needed. However this answer is for Drupal 6 (about 8 years old) and refers to a date range field while "changed" is a timestamp.

Currently if I add Date processor capability to this facet I have a granularity option. If I select a month granularity I get a basic "time ago" feature but seem to get very odd results.

EG. Clicking on "3 months ago (3)" in the below list gives me 13 items. The url generated is &facets_query=&keyword[0]=last_updated:2021-05-22 (As of today July 22)

Last updated
3 months ago (3)
6 months ago (3)
7 months ago (2)
8 months ago (9)
10 months ago (1)
11 months ago (6)
1 year 0 months ago (7)

Questions:

  1. Is there an updated answer available for creating a friendly set of date ranges?
  2. Why could I be I getting these incorrect facet counts?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.