diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-10-18 13:10:45 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-10-18 13:14:20 -0700 |
commit | bd2809dbde925eb3c12640a7fa4cbe38a62151d0 (patch) | |
tree | 15017791073cf30d5bdfe93a6e0483b58fd181c4 /src/parse.rs | |
parent | e21ba4bb4da9f88680b6168498b73115e865ad25 (diff) | |
download | es-public-proxy-bd2809dbde925eb3c12640a7fa4cbe38a62151d0.tar.gz es-public-proxy-bd2809dbde925eb3c12640a7fa4cbe38a62151d0.zip |
schema: term queries can be numeric or boolean
Diffstat (limited to 'src/parse.rs')
-rw-r--r-- | src/parse.rs | 23 |
1 files 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<IdsQuery>, #[serde(skip_serializing_if = "Option::is_none")] - wildcard: Option<HashMap<String, TermQueryOrString>>, // also works for wildcard + wildcard: Option<HashMap<String, TermQueryOrValue>>, // also works for wildcard #[serde(skip_serializing_if = "Option::is_none")] - prefix: Option<HashMap<String, TermQueryOrString>>, // also works for prefix query + prefix: Option<HashMap<String, TermQueryOrValue>>, // also works for prefix query #[serde(skip_serializing_if = "Option::is_none")] range: Option<HashMap<String, RangeQuery>>, #[serde(skip_serializing_if = "Option::is_none")] - term: Option<HashMap<String, TermQueryOrString>>, + term: Option<HashMap<String, TermQueryOrValue>>, #[serde(skip_serializing_if = "Option::is_none")] // TODO: boost in terms query terms: Option<HashMap<String, Vec<String>>>, @@ -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<String>, #[serde(skip_serializing_if = "Option::is_none")] @@ -428,6 +431,16 @@ pub enum StringOrNum { #[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)] pub enum Num { Int(u64), Float(f64), |