quickwit icon indicating copy to clipboard operation
quickwit copied to clipboard

Fix REST search response for requests without snippets

Open guilload opened this issue 1 year ago • 3 comments

Nesting each hit in a document object is not required for requests without snippets.

guilload avatar Sep 30 '22 21:09 guilload

@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

evanxg852000 avatar Oct 03 '22 12:10 evanxg852000

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.

fmassot avatar Oct 03 '22 14:10 fmassot

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"

evanxg852000 avatar Oct 03 '22 18:10 evanxg852000

As discussed with Evance, let's go with:

  • removing the document field
  • populating snippets in a top-level field called snippets the same way we do for aggregations
#[serde(skip_serializing_if = "Option::is_none")]
pub snippets: Option<Vec<serde_json::Value>>,

guilload avatar Nov 01 '22 17:11 guilload

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.

evanxg852000 avatar Nov 02 '22 13:11 evanxg852000