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

drunken monkey’s picture

Status: Active » Needs review
Issue tags: -facet
StatusFileSize
new1.95 KB

Thanks 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!

jlapp’s picture

Version: 7.x-1.6 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
Issue tags: +facet

I 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.

jlapp’s picture

Issue tags: -facet
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for testing!
Committed.

Status: Fixed » Closed (fixed)

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