Boolean fields don't work when used as views filters

Created on 10 September 2024, 3 months ago

Problem/Motivation

When using a view to display the output of an search_api_index, for example to create an overview page with several filters on it. Boolean fields are queried using 1 or 0 instead of 'true' or 'false'.

Meilisearch stores booleans as lowercase string (see https://www.meilisearch.com/docs/learn/engine/datatypes#boolean)

Steps to reproduce

Create a index and store a boolean field on that index, as type 'boolean'
Create a view for that index, and filter on that boolean field.

The filter won't work, and in worse case scenario your view will remain empty.

Proposed resolution

A small change in Drupal\search_api_meilisearch\Parser\ScalarValueParser.php that changes the value into 'true' or 'false' will fix this issue.

I did try to move the value fix to MeilisearchUtils::formatConditionValue function, however that would imply that the current field or field_type would be added to that method and that makes no sense for any other value except a boolean.

Remaining tasks

Check MR !53 as proposed solution.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇳🇱Netherlands rené bakx Netherlands

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024