quickwit
quickwit copied to clipboard
Fix REST search response for requests without snippets
Nesting each hit in a document object is not required for requests without snippets.
@guilload, Please It's not very clear to me what you mean, document as?
- in quickwit https://github.com/quickwit-oss/quickwit/blob/main/quickwit/quickwit-search/src/fetch_docs.rs#L155
- or the rest service response https://github.com/quickwit-oss/quickwit/blob/main/quickwit/quickwit-search/src/search_response_rest.rs#L31
So here is an example of a hit:
{
"document": {
"created_at": "2022-09-28T14:20:49Z",
"id": 24276723600
}
}
I see one problem coming: the json structure depending on snippet or not. From a user perspective, it's nice to have a stable search results whether there is a snippet or not.
Ok I think i now understand @guilload 's concern and it's for stable representation of the response I changed the shape, this way decorative info specific to "document" like score can always come next to it. we could get rid of document and have snippet but a document field can be named snippet.
Elsewhere, what we have here as "document" ElasticSearch call it "_source"
As discussed with Evance, let's go with:
- removing the
documentfield - populating snippets in a top-level field called
snippetsthe same way we do for aggregations
#[serde(skip_serializing_if = "Option::is_none")]
pub snippets: Option<Vec<serde_json::Value>>,
My guess is that the snippet array and the hits array should match in terms of indices. That is hit[0] -> snippets[0]
@guilload IMHO this is not API consumer friendly thought.