meilisearch/MeiliSearch

`searchableAttributes` change order of fields in response hits

Ouverte

#1 495 ouverte le 7 juil. 2021

 (24 commentaires) (0 réaction) (0 personne assignée)Rust (2 542 forks)batch import
bugcontribution acceptedhelp wanted

Métriques du dépôt

Stars
 (57 572 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

Describe the bug

When adding fields in searchableAttributes the order of fields in the returned document are impacted:

{
  "searchableAttributes": [
    "title",
    "description"
  ],
  "filterableAttributes": [
    "genres"
  ]
}

id field of document goes from first position to second position. Given this document:

{
  "id": 28,
  "title": "Apocalypse Now",
  "overview": "At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, \"does not exist, nor will it ever exist.\" His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.",
  "genres": [
    "Drama",
    "War"
  ],
  "poster": "https://image.tmdb.org/t/p/w500/gQB8Y5RCMkv2zwzFHbUJX3kAhvA.jpg",
  "release_date": 303523200
}

after a search this is how it is returned in the response body:

        {
            "title": "Apocalypse Now",
            "id": 28,
            "overview": "At the height of the Vietnam war, Captain Benjamin Willard is sent on a dangerous mission that, officially, \"does not exist, nor will it ever exist.\" His goal is to locate - and eliminate - a mysterious Green Beret Colonel named Walter Kurtz, who has been leading his personal army on illegal guerrilla missions into enemy territory.",
            "genres": [
                "Drama",
                "War"
            ],
            "poster": "https://image.tmdb.org/t/p/w500/gQB8Y5RCMkv2zwzFHbUJX3kAhvA.jpg",
            "release_date": 303523200
        },

Expected behavior Same order

MeiliSearch Version: 0.21.0

Guide contributeur