The order of facets in the endpoint response is not consistent, does not respect configured weights

Created on 13 March 2024, 10 months ago
Updated 8 April 2024, 9 months ago

Problem/Motivation

The order in which facets appear in the api endpoint response does not always conform to the configuration of facets for the API source under /admin/config/search/facets. The behavior seems unpredictable and inconsistent.

Steps to reproduce

Using the Search API module, I have configured an index. I am using version 1.31 of the search_api module. I then configured an endpoint for the index using Search API Decoupled. I am using version 1.0 alpha 24 of the module. I then configured three facets for the source representing the decoupled endpoint. On the facets admin page, I specified an order in which the facets should appear using the drag/drop interface. I am using version 2.0.6 of the facets module.

When submitting queries to the search api endpoint, the endpoint usually returns facets in the correct order. That is, in the array of facets in the returned JSON, the three facets appear in the order I specified in the configuration. However, this is not always the case. Occasionally when I submit a query, the JSON returned will have the facets in a different order.

I am using Vuejs to construct my search frontend and looping over the facets array to present the facets. This change in the order of the facets array means that the UI occasionally changes for no reason. This results in a poor user experience.

There does not appear to be any pattern governing when this happens. It doesn't seem to matter which facets are active or the order in which facets appear in the query URL.

Proposed resolution

Ideally, the JSON returned should always reflect the order specified in configuration. Not sure why it doesn't. I'd prefer to have this fixed in the module instead of needing to manually order the facets on the front-end as that will require extra code that should be unnecessary.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aaronpinero

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