Facets are shown for nodes which has not translation.

I mean:

Site with two languages: English and French. I have 5 nodes in English version and has not translations to French, and two facets: Node title and Taxonomy term.

On English version all is ok, but when we switch to French we have facets for English version without search results.

Facet titles are tranclated to French.

Expected result: no facets. As i have not nodes in French version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

divined created an issue. See original summary.

divined’s picture

Issue summary: View changes
borisson_’s picture

Version: 8.x-1.0-alpha6 » 8.x-1.x-dev

I've just confirmed this - not sure how we should resolve it though. Not even sure if this is facets or search api related. I guess we'll need to discuss this.

In any case, we also need tests for this - our current language-specific tests are very basic.

borisson_’s picture

Issue tags: +Needs tests

Adding tag

divined’s picture

Adding Count limit processor solve half of problems.
But we have another:

3 Node, 2 Terms

Node1 with Term1
Node2 with Term1 and Term2
Node3 with Term2
--

Select facets for all Node titles and Term titles. Then unselect Node1, Term2 and then Node2.

All facet filter will disapeared from the page, and you get an empty result page.

Because you have active filter returns zero count only. (Active filters: Node3 and Term1)

---

I solve this problem in this variant:
New count limit processor:

foreach ($results as $id => $result) {
      +if (in_array($result->getRawValue(), $facet->getActiveItems())) {
      +  continue;
      +}

      if (($min_count && $result->getCount() < $min_count) ||
        ($max_count && $result->getCount() > $max_count)) {
        unset($results[$id]);
      }
    }

Active results will skipped.

borisson_’s picture

Status: Active » Needs review
FileSize
3.02 KB

This is expected.

Facets use the same limitations as the query object passed, so when using views, add a filter to the view to limit to one language.
Otherwise, this is solved by adding a `hook_search_api_query_alter()` that limits the results to the current language.

I've added a test to make sure that this behavior works.

borisson_’s picture

Issue tags: -Needs tests
FileSize
3.2 KB

Needed a reroll

borisson_’s picture

FileSize
632 bytes
3.13 KB

  • borisson_ committed fe31120 on 8.x-1.x
    Issue #2827808 by borisson_: Facets on multilangual site
    
borisson_’s picture

Status: Needs review » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

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