Problem/Motivation

In #2450227: Ignore parent terms in facets when operator is OR SearchApiFacetapiTerm::execute() parent items were ignored if a child is active when a facet uses the OR operator in an hierarchical structure, since by default entities are tagged with both parent and child terms in hierarchical taxonomies, thus making filtering on the parent include too many results. However, the existing code does not correctly strip parents when using a hierarchical structure with non-numeric machine names, since it checks for the "missing value" filter ! by looking for any non-numeric value.

Steps to reproduce

  • Index items with a hierarchical facet with non-numeric machine names
  • Search by selecting a parent and then a child; the result set will be the same as if you had not selected the child

Proposed resolution

Check explicitly for the string '!' to exclude the missing value filter, and not any non-numeric value.

Remaining tasks

Write tests?

Comments

mvc created an issue. See original summary.

mvc’s picture

drunken monkey’s picture

Status: Active » Fixed

Thanks a lot for reporting this problem! Very strange that I used is_numeric() instead of just checking for '!' – the latter seems not only more accurate but also faster.

Apparently, we initially (in #2450227: Ignore parent terms in facets when operator is OR) made the mistake of assuming that the SearchApiFacetapiTerm class was only used for taxonomy terms, while “term” there refers to just any single value. We fixed that in #2703675: Undefined index: [value in taxonomy_term_load error, but apparently overlooked this remaining assumption that all filters would either be integers (taxonomy term IDs) or the missing filter. (Still unclear, though, why I thought this was a good idea either way.)

Anyways, so much for the history. Your fix looks great, though, in any case, so I’ll just commit it. (Test coverage is very poor in our D7 code anyways, unfortunately, so no need to bother with that.)
Thanks again!

  • drunken monkey committed 3985230 on 7.x-1.x authored by mvc
    Issue #3178035 by mvc, drunken monkey: Fixed OR facets for non-numeric...

Status: Fixed » Closed (fixed)

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