Skip to content

Commit

Permalink
add more example for left association
Browse files Browse the repository at this point in the history
  • Loading branch information
cch123 committed Feb 4, 2019
1 parent ecf1713 commit ce8ecef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![recursion_limit = "1024"]

extern crate pest;
#[macro_use]
extern crate pest_derive;
Expand Down Expand Up @@ -240,6 +242,7 @@ fn walk_tree(expr: Expression, is_root: bool) -> serde_json::Value {
}
}


#[cfg(test)]
mod tests {
use serde_json::json;
Expand Down Expand Up @@ -294,6 +297,11 @@ mod tests {
output: json!({"from":0,"query":{"bool":{"must":[{"bool":{"must":[{"match":{"a":{"query":"1","type":"phrase"}}},{"match":{"b":{"query":"2","type":"phrase"}}}]}},{"match":{"c":{"query":"3","type":"phrase"}}}]}},"size":1000}),
comment: "left association test",
},
TestCase {
input: ("a = 1 and b = 2 and c = 3 and d = 4", 0, 1000, vec![], vec![]),
output: json!({"from":0,"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"must":[{"match":{"a":{"query":"1","type":"phrase"}}},{"match":{"b":{"query":"2","type":"phrase"}}}]}},{"match":{"c":{"query":"3","type":"phrase"}}}]}},{"match":{"d":{"query":"4","type":"phrase"}}}]}},"size":1000}),
comment: "left association test",
},
];
test_cases.iter().for_each(|case| {
let output = super::convert(
Expand Down

0 comments on commit ce8ecef

Please sign in to comment.