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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rené bakx created an issue. See original summary.

rene bakx’s picture

Issue summary: View changes
Status: Active » Needs review

bcizej made their first commit to this issue’s fork.

bcizej’s picture

@rene thanks for reporting and contribution.

Branch has been rebased, added tests and refactored code to use a separate parser class for booleans.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Hello, I've tested this MR with both D10 and D11 and in both cases I can confirm that this is working correctly in both cases. I've taken a look into the MR and code looks good so I'm marking this issue with RTBC.

  • bcizej committed 45715d22 on 2.x authored by rené bakx
    Issue #3473369 by rené bakx, bcizej, jernejmramor: Boolean fields don't...
bcizej’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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