Boolean facet does not show the "FALSE" value

Created on 27 May 2025, 11 days ago

Problem/Motivation

When I add a facet based on a boolean field, I only see the "TRUE" value facet back in the interface.

Proposed resolution

The facet parser should be changed. It checks on an empty() statement. However the value we receive back from ES is 0. This is considered empty and therefore discarded.

2 solutions:
Different check:

'filter' => (!isset($value['key']) || $value['key'] === '') ? '!' : \sprintf('"%s"', $value['key']),

Or change the default value to 0.

'filter' => empty($value['key']) ? '0' : \sprintf('"%s"', $value['key']),

The patch in the attachement uses solution 1 since I do not know if the "!" is used for something specific.

🐛 Bug report
Status

Active

Version

8.0

Component

Code

Created by

🇳🇱Netherlands MarcKwee

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

Merge Requests

Comments & Activities

  • Issue created by @MarcKwee
  • 🇳🇱Netherlands MarcKwee

    Patch to solve issue above using method 1

  • First commit to issue fork.
  • 🇨🇦Canada mparker17 UTC-4

    @marckwee, thank you for the contribution!

    I committed your code to a merge request to make it easier for me to review.

    I took a very quick look at your patch: the changes seem clear to me, but I haven't yet had a chance to run the changed code... I may have more feedback when I do.

    I didn't see any automated tests in your patch... the Elasticsearch Connector module maintainers prefer to accept merge requests that have passing automated tests. Automated tests ultimately benefit you, because they ensure that future changes to this module (i.e.: by other people) will not break the functionality that your site depends on!

    I don't think that we have any automated tests for Facets yet ( I wrote a manual test but haven't had the time to turn it into code yet).

    Are you interested in learning how to write an automated test?

    If you describe how to run a test manually, then I may be able to suggest how to automate it (i.e.: if you're interested in learning to write a test), or write a test myself (if you aren't interested in learning to write a test).

Production build 0.71.5 2024