Search API provides a granularity option for date facet.
But it does not show up when the date field is multiple.

Comments

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1.63 KB

Oh, you're right, thanks for reporting! We currently seem to handle multi-valued fields completely wrong in the facet definition code.

The attached patch should fix this, please test!

anrikun’s picture

Status: Needs review » Needs work

Thank you!
The option shows up but something else is going wrong :-(

First, I get these items as expected:

Filter by date:
2012 (3)
2013 (1)

But when I click on 2012, I get these:

Filter by date:
(-) 2012
    December 2012 (2)
    Mars 2012 (1)
    September 2013 (1)

2013 has gone away and September 2013 is displayed inside 2012!

drunken monkey’s picture

Status: Needs work » Postponed

Well, that's a different problem, and harder to solve: one part of it is that range filters on multi-valued fields are fundamentally broken in the Search API – see #1783746: Add support for "between" operator. So when you use a date facet on a multi-valued field, it currently cannot possibly work correctly, as long as the field really has multiple values sometimes.
Once that is fixed, we'd probably also have to fix the code in the date facet handler to a) use the new operator and b) sort out field values that are out of range for the currently active filter.

Not sure if we should commit the patch until then. Making the date facet handler available for multi-valued date fields is probably not a good idea as long as it won't work anyways. On the other hand, it works fine for fields that are technically multi-valued but always only have a single value – which is the case sometimes.
Still, probably not. Unless you disagree there, please follow the issue I linked and bump this one as soon as the other is committed, so we won't forget.

Status: Postponed » Needs review
drunken monkey’s picture

Issue summary: View changes
Status: Needs review » Postponed

Unless I'm missing something I think this should still be postponed?

legolasbo’s picture

Status: Postponed » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.

klausi’s picture

Status: Closed (outdated) » Needs review

This patch is still relevant for us to make date facets work.

anrikun’s picture

Yes, let's bump this for @drunken monkey as #1783746: Add support for "between" operator is now fixed (see #3)

drunken monkey’s picture

StatusFileSize
new3.88 KB
new4.88 KB

Ah, yes, thanks a lot for bumping!
Can you verify the attached works for you?

drunken monkey’s picture

Anyone able/willing to test?
About to create a new release, so would be great to still get that in.

  • drunken monkey committed 8717f83 on 7.x-1.x
    Issue #2104623 by drunken monkey: Fixed facet filters for multi-valued...
drunken monkey’s picture

Status: Needs review » Fixed

Well, I’m pretty confident that this at least doesn’t break anything, and also the next release is still a while off, so I’m just committing this now.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.