Facet process to merge node types

Created on 4 May 2020, about 4 years ago
Updated 16 October 2023, 9 months ago

I would like to propose a new processor to merge facets together. While I was working in a case where I had to do it, I walked throught different places however I didn't see a generic solution provided out-of-the-box from Facets module per se.

Then I came with my solution and I would like to share here. The code I wrote I have some details here: https://www.keboca.com/drupal-8-merge-facets-together

Plus it is possible it would help as well on the following closed tickets:
How can I merge combine facets in drupal 8 Search API and Facets β†’
Trying to merge multiple content types into a single facet via a facet processor plugin β†’
How can I merge or combine facets?

I'm leaving here a path which allows to create facet groups based on current content types.

✨ Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡·Costa Rica keboca

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jiong_ye

    Ran into this issue https://www.drupal.org/project/facets/issues/3368327 πŸ› Facets Pretty Paths module and Merge node types processor error Active
    Updated the patch slightly.

  • πŸ‡ΊπŸ‡ΈUnited States jiong_ye

    renamed the patch

  • πŸ‡ΊπŸ‡ΈUnited States mgaskey

    Re-rolled the patch in #14 to improve the language used in comments and the UI. The functionality works great in the original patch.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.1 & MySQL 5.5
    last update 10 months ago
    Composer require failure
  • πŸ‡ͺπŸ‡ΈSpain pcambra Spain, πŸ‡ͺπŸ‡Ί
  • πŸ‡ͺπŸ‡ΈSpain pcambra Spain, πŸ‡ͺπŸ‡Ί
  • πŸ‡ΊπŸ‡ΈUnited States thomps9012

    For context we're using version 2.0.6 of facets, solr / solr cloud, and json:api search index.

    Here's what we're seeing for the url of our merged node facet (in the metadata section of our json:api response):

    https://base_url.com/jsonapi/index/solr_node_index?filter[facet_group]=facet_item&filter[0]=facet_group:facet_item&filter[1]=facet_group:facet_item
    

    Which is not a clickable link.

    Our patch corrects the generated url to the below:

    https://base_url.com/jsonapi/index/solr_node_index?filter[facet_merged_name][condition][path]=facet_group&filter[facet_merged_name][condition][value][0]=facet_item_1&filter[facet_merged_name][condition][value][1]=facet_item_2&filter[facet_merged_name][condition][value][2]=facet_item_3
    

    Which is a clickable link

    Hopefully this patch helps resolve this issue for some others, if not

  • πŸ‡ΊπŸ‡ΈUnited States thomps9012

    FYI the interdiff is in the previous comment and file 3133309-18.patch attached to this comment is the actual patch

  • πŸ‡ΊπŸ‡ΈUnited States thomps9012

    Resolution to patch 19 which was attempting to pass the translate object as a query parameter

  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    We already have a combine facets processor in 3.0.x. doesn't it solve the requirements here?

  • πŸ‡ͺπŸ‡ΈSpain pcambra Spain, πŸ‡ͺπŸ‡Ί

    @mkalkbrenner the use case here is a common requirement by clients to group content types (and other fields) together in the same value for filtering, for example to produce a checkbox widget like so:

    [ ] Latest
    [ ] Articles
    [ ] Documents

    Where Latest are from content types blog and news, Articles are from content type article and page, and Documents are from document and file content type (just a quick example).

    This can be done either at index time with a computed field or something, or at search time, with the work on this patch, I don't think it's the same as combining facets.

Production build 0.69.0 2024