meilisearch/MeiliSearch

`searchableAttributes` change order of fields in response hits

Open

#1,495 opened on Jul 7, 2021

View on GitHub
 (24 comments) (0 reactions) (0 assignees)Rust (20,887 stars) (733 forks)batch import
bugcontribution acceptedhelp wanted

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

Contributor guide