Unable to use filter parameters in API calls

Created on 27 October 2023, 11 months ago
Updated 10 November 2023, 11 months ago

Problem/Motivation

Unable to use filter parameters in API calls

Steps to reproduce

Create Endpoint against index.
Try to filter by Content type [or any field]
eg en/api/search/content_search?type=page

Expected results:
Only content types of type page should be retuned in the results.

Actual Result:
The result set isn't reduced - all content types are included.

Noteworthy
Faceting by the same field works fine.
eg /en/api/search/content_search?f[0]=type:page

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇪Ireland alanburke

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

Comments & Activities

  • Issue created by @alanburke
  • 🇮🇪Ireland alanburke

    Proper patch to follow. Dumping here for now
    diff --git a/web/modules/contrib/search_api_decoupled/src/Controller/SearchApiEndpointController.php b/web/modules/contrib/search_api_decoupled/src/Controller/SearchApiEndpointController.php
    index 6f91aacf..3d110e13 100644
    --- a/web/modules/contrib/search_api_decoupled/src/Controller/SearchApiEndpointController.php
    +++ b/web/modules/contrib/search_api_decoupled/src/Controller/SearchApiEndpointController.php
    @@ -229,7 +229,7 @@ protected function prepareQuery(Request $request, SearchApiEndpointInterface $se

    // Add conditions for all query parameters.
    foreach ($request->query->all() as $key => $value) {
    - if (!in_array($key, $index_fields)) {
    + if (!in_array($key, array_keys($index_fields))) {
    continue;
    }
    if (in_array($key, $query->getFulltextFields())) {

  • @alanburke opened merge request.
  • @alanburke opened merge request.
  • Status changed to Fixed 11 months ago
  • 🇩🇪Germany a.dmitriiev

    Thanks for the fix. Merged. And new version released.

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

Production build 0.71.5 2024