Sometimes there is a need to separate field options into several facets (one field - many facets). For example divide some taxonomy terms. The purpose for this can be a logic request (OR on facets, AND between facets).
This doesn't work, but I want to focus on another problem that is based on the above issue. When you're requesting some data from the facet, you shouldn't identify it by a field name, each facet have it's unique name for this purpose:
search_api/contrib/search_api_facetapi/plugins/facetapi/query_type_term.inc (row 123,124)
- if (isset($results['search_api_facets']) && isset($results['search_api_facets'][$this->facet['field']])) {
- $values = $results['search_api_facets'][$this->facet['field']];
+ if (isset($results['search_api_facets']) && isset($results['search_api_facets'][$facet['name']])) {
+ $values = $results['search_api_facets'][$facet['name']];
Comments
Comment #1
drunken monkeyThanks a lot for reporting this!
You're right, it seems we're already using the facet name to identify the facets in the query, but then falsely use the field when retrieving them.
The attached patch should fix this (also for date facets) – please test!
Comment #2
jlapp commentedI experienced this same issue with 7.x-1.7 and 7.x-1.x-dev.
I have an indexed field which has a facet, then in hook_facetapi_facet_info() I am creating a second facet for the same field with a different name and different configuration settings. Before applying this patch, the second facet would not appear because the code referenced above was using $this->facet['field'] instead of $this->facet['name']. Applying the patch in #1 corrected the issue for me.
Comment #3
jlapp commentedComment #4
drunken monkeyGood to hear, thanks a lot for testing!
Committed.