summaryrefslogtreecommitdiffstats
path: root/src/parse.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-12-17 21:03:21 -0800
committerBryan Newbold <bnewbold@archive.org>2020-12-17 21:03:21 -0800
commit968c29f11734bbb3eb7dc8163c879d6eba8e3e5e (patch)
tree121c24f24fbe90b2e1fb335faaf592b5d0cf78e9 /src/parse.rs
parent51417bfeffc8dbbb417bfb352776a48204d06fbc (diff)
downloades-public-proxy-968c29f11734bbb3eb7dc8163c879d6eba8e3e5e.tar.gz
es-public-proxy-968c29f11734bbb3eb7dc8163c879d6eba8e3e5e.zip
parse: more flexible sort order specification
Diffstat (limited to 'src/parse.rs')
-rw-r--r--src/parse.rs12
1 files 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<Vec<SortElement>>,
+ pub sort: Option<SortSingleOrVec>,
#[serde(skip_serializing_if = "Option::is_none")]
pub slice: Option<ApiSlice>,
@@ -282,6 +282,14 @@ pub enum SortElement {
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
#[serde(untagged)]
+pub enum SortSingleOrVec {
+ Single(String),
+ Vec(Vec<SortElement>),
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(deny_unknown_fields)]
+#[serde(untagged)]
pub enum DocValOrString {
String(String),
Object {
@@ -638,7 +646,7 @@ pub struct InnerHits {
#[serde(skip_serializing_if = "Option::is_none")]
size: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
- sort: Option<Vec<SortElement>>,
+ sort: Option<SortSingleOrVec>,
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]