From bd2809dbde925eb3c12640a7fa4cbe38a62151d0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 18 Oct 2020 13:10:45 -0700 Subject: schema: term queries can be numeric or boolean --- src/parse.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 338ec64..c2cb356 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -205,13 +205,13 @@ pub struct ApiQuery { #[serde(skip_serializing_if = "Option::is_none")] ids: Option, #[serde(skip_serializing_if = "Option::is_none")] - wildcard: Option>, // also works for wildcard + wildcard: Option>, // also works for wildcard #[serde(skip_serializing_if = "Option::is_none")] - prefix: Option>, // also works for prefix query + prefix: Option>, // also works for prefix query #[serde(skip_serializing_if = "Option::is_none")] range: Option>, #[serde(skip_serializing_if = "Option::is_none")] - term: Option>, + term: Option>, #[serde(skip_serializing_if = "Option::is_none")] // TODO: boost in terms query terms: Option>>, @@ -401,15 +401,18 @@ pub struct IdsQuery { #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] #[serde(untagged)] -pub enum TermQueryOrString { +pub enum TermQueryOrValue { String(String), + Int(u64), + Float(f64), + Boolean(bool), Object(TermQuery), } #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct TermQuery { - value: String, + value: StringOrNumOrBool, #[serde(skip_serializing_if = "Option::is_none")] rewrite: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -425,6 +428,16 @@ pub enum StringOrNum { Float(f64), } +#[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum StringOrNumOrBool { + String(String), + Int(u64), + Float(f64), + Boolean(bool), +} + #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] #[serde(untagged)] -- cgit v1.2.3