Problem/Motivation
For the attributes mentioned in the title, there is a check if the search API config is different than Meilisearch settings. The generated attributes by the backend code are not necessarily in the same order as Meilisearch returns them. This potentially causes all settings to always update.
Steps to reproduce
- Install and configure the module.
- Prepare an index with some fields.
- Open the module code, with some kind of debugger.
- Place breakpoints after the comparisons.
- Go to the Search API field settings, without changing anything, just click "Save Changes".
- Your code execution has a big change to stop at one or all of the breakpoints.
Proposed resolution
Since the order of these values is not important, using sort before or in the if statement should do the job.
Remaining tasks
Fix the code
Issue fork search_api_meilisearch-3386972
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
Comment #3
admirlju commentedComment #4
deaom commentedI do agree for the order not being important for the searchable and filterable attributes, but for sortable it's important that they keep the order in which they are set in the search API fields, as if I'm not mistaken, the first one added (on top) is the one with more "importance" when sorting, but I could be wrong, so leaving this to needs review.
Comment #5
admirlju commentedLooking at the meilisearch documentation. The order of sorting attributes is not important when setting them up, this setting only sets what values can be used for sorting. The sorting order is done at search time, so values in the
"sort"parameter must be correctly ordered.Comment #6
deaom commentedThank you for looking into it. Did test the code and it's working as expected and I see no issue with this being sorted before comparison is made, marking it as RTBC.
Comment #8
bcizej commentedThanks, merged but needs to be applied to 2.x as well.
Comment #11
bcizej commentedMerged to 2.x as well.