From 968c29f11734bbb3eb7dc8163c879d6eba8e3e5e Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 17 Dec 2020 21:03:21 -0800 Subject: parse: more flexible sort order specification --- src/parse.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 10216f7..8f0ddea 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -115,7 +115,7 @@ pub struct SearchBody { // https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-search-results.html #[serde(skip_serializing_if = "Option::is_none")] - pub sort: Option>, + pub sort: Option, #[serde(skip_serializing_if = "Option::is_none")] pub slice: Option, @@ -279,6 +279,14 @@ pub enum SortElement { Object(HashMap), } +#[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum SortSingleOrVec { + Single(String), + Vec(Vec), +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] #[serde(untagged)] @@ -638,7 +646,7 @@ pub struct InnerHits { #[serde(skip_serializing_if = "Option::is_none")] size: Option, #[serde(skip_serializing_if = "Option::is_none")] - sort: Option>, + sort: Option, #[serde(skip_serializing_if = "Option::is_none")] name: Option, #[serde(skip_serializing_if = "Option::is_none")] -- cgit v1.2.3