Skip to content

instant-meilisearch geosearch overwrites objectID #1308

@queer

Description

@queer

Description
I have an index I am using geosearch on, using instant-meilisearch + react-instantsearch. Something I noticed is that when I try to use hit.objectID for anything, it's never the actual value that's stored in my Meilisearch index or the value returned in the network requests, but instead always a seemingly-random number. Today I traced it down to adaptGeoResponse explicitly overwriting the objectID field:

const objectID = `${i + Math.random() * 1000000}`
if (hits[i]._geo) {
hits[i]._geoloc = hits[i]._geo
hits[i].objectID = objectID
}
if (hits[i]._formatted?._geo) {
hits[i]._formatted._geoloc = hits[i]._formatted._geo
hits[i]._formatted.objectID = objectID
}

It seems that this behaviour has been a part of the geo-response-adapter since the beginning: ac69707#diff-b1f517006a5289a6c011e39668cc44e828b73d2056a2ff00cf04e01bc4bfcafcR13

Expected behavior
instant-meilisearch doesn't change the data I get back from Meilisearch.

Current behavior
instant-meilisearch changes my objectIDs to unwanted, useless values. I have to use a workaround of getting the value from hit._highlightResult.objectID.value.

Screenshots or Logs
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions