Search API Integration not working as expected

Created on 17 January 2025, 4 months ago

Problem/Motivation

Architecture:
Entity: Group
Custom Field Name: field_requested_user
Sub Fields:
- Entity Reference (user): requested_user
- Boolean: request_closed

I have a group entity, with two values for field_requested_user. Values:
Group ID: 445
1) requested_user: 1300
request_closed: 1
2) requested_user: 1301
request_closed: 0

In table {group__field_requested_user}, I can see that this has saved correctly:

entity_id| field_requested_user_requested_user | field_requested_user_request_closed
445 | 1300 | 1
445 | 1301| 0

I have indexed both the requested_user and request_closed fields in Search API. I have created a View of group nodes, with a contextual filter on requested_user, and a filter set show items with a value of request_closed equal to 0. Here is the query views is using:

Conditions:
[
request_closed <> 1
AND
requested_user_uid = 1301
]
Sorting: created DESC
Options: array (
'search_api_view' => 'object (Drupal\\views\\ViewExecutable)',
)

Expected result: Show the row for user 1301, since request_closed is equal to 0.
Actual result: No row shown.

I believe this is because search API is finding two rows for request_closed, and is unable to differentiate which row:.

In table {search_api_db_requested_user_uid} I see a row for each user:

item_id | value
entity:group/445:en | 1301
entity:group/445:en | 1300

And I can see in table {search_api_db_job_request_closed} the following two rows:

item_id | value
entity:group/445:en | 1
entity:group/445:en | 0

There is no differentiation between these two rows for any kind of delta, to correctly relate the value between the two different requested_user rows.

I am unsure if this is a Search API issue, or a bug in how this module is integrating with Search API.

Steps to reproduce

1) Create a custom field with a user reference, and a boolean
2) Integrate with Search API, and index both fields
3) Create two values on the entity for the custom field, each value for a different user. Set the boolean to TRUE for one and FALSE for the other
4) Create a search API view that has a contextual filter based on the user, with a filter on the boolean value. The filter can be on either TRUE or FALSE.
5) In the views preview, test both user IDs as the contextual filter value, and see that both IDs show the same result, even though one is filtered to TRUE and one is filtered to FALSE.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.1

Component

User interface

Created by

πŸ‡¨πŸ‡¦Canada jaypan Victoria, BC

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

Comments & Activities

Production build 0.71.5 2024