In my project I need to show more than a simple counter for each facet value.
Let's say I have a boolean property (active) for my search results, what I have to show is the number of active items / number of total items in each facet.
So, now I have:
Color
white 20
blue 10
black 6
instead I need something like this:
Color
white 0/20
blue 4/10
black 6/6
Where 0, 4 and 6 are the numbers I would get if I added another filter to my search (active=1).
As I'm new to facet_api+search_api (using db backend, right now) can you suggest the best way to deal with this requirement? I checked the source code but I'm a bit lost, so I preferred to ask for some pointers before digging more into it.
Comments
Comment #1
bago commentedTo explain it in a more generalized way my need is to display a matrix of 2 facets.
In my case color and active are two facets, currently I get
color
- white 20
- blue 10
- black 6
active
- true 10
- false 26
Instead I'd need to show a "matrix facet" color/active with the combined results:
color/active
- white/false 20
- blue/true 4
- blue/false 6
- black/true 6
or as a matrix
This "matrix" contains much more data than what I need, but maybe it is more generic to be general purpose (and I could easily adapt to my use case anyway)...
Is facet api generic enough to let me do this stuff by only "extending" it? Or do you think I will have to patch the main code?
Comment #2
cpliakas commentedFact API is generic enough to modify he display, but understand that Facet API doesn't do the facet calculations. Therefore the Search API module would have to provide this data somehow. I'm not sure if there is an easy way to display both the number of facets in the resultset AND the total number of facets without executing 2 queries, especially if you are using Solr. Either way, I would start with a request to Search API as it has to provide the facet data you are looking for first.
Thanks,
Chris
Comment #3
cpliakas commentedMarking as fixed, because once the Search API module is resolved, the technique in Facet API to display this data is very similar to the resolution of the issue #1524896: Keep count for active facets when using checkbox and/or OR facets.