meilisearch / meilisearch-rust

Rust wrapper for the Meilisearch API.

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`formatted_result` handling

curquiza opened this issue · comments

Should be done once #201 is merged

Since v0.24.0, MeiliSearch does not return the exact document in the _formatted object.

Example
With this document

[
  { "id": 1, "title": "Alice In Wonderland", "author": "Lewis Carroll", "genre": "fantasy", "price": 25.99 },
]

and this search

{
    "q": "25",
    "attributesToHighlight": ["*"]
}

I get:

{
    "hits": [
        {
            "id": 1,
            "title": "Alice In Wonderland",
            "author": "Lewis Carroll",
            "genre": "fantasy",
            "price": 25.99,
            "_formatted": {
                "id": "1",
                "title": "Alice In Wonderland",
                "author": "Lewis Carroll",
                "genre": "fantasy",
                "price": "<em>25</em>.99"
            }
        }
    ],
    "nbHits": 1,
    "exhaustiveNbHits": false,
    "query": "",
    "limit": 20,
    "offset": 0,
    "processingTimeMs": 1
}

It means formatted_result (in src/search.rs) cannot be a Option<T> anymore.
I replaced it with Option<Map<String, Value>> in this PR #205

Maybe there is a better solution to handle this.

Fixed by #205