-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatch_phrase_test.rs
57 lines (48 loc) · 1.28 KB
/
match_phrase_test.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use serde_json::json;
use os_query_builder_rs::full_text::match_phrase::MatchPhrase;
use os_query_builder_rs::model::Query;
#[test]
fn match_phrase_test() {
let match_phrase = MatchPhrase::new()
.field("brand")
.value("DPH")
.analyzer("english")
.slop(2u64)
.zero_terms_query("all");
let json = json!(match_phrase);
let json_str = json!({
"brand":{
"query": "DPH",
"analyzer": "english",
"slop": 2,
"zero_terms_query": "all"
}
});
assert_eq!(json_str, json);
}
#[test]
fn query_match_phrase_test() {
let match_phrase_test_test = MatchPhrase::new().field("brand")
.value("DPH")
.analyzer("english")
.slop(2u64)
.zero_terms_query("all");
let query = Query::new()
.source(vec!["brand"])
.query(match_phrase_test_test);
let json = json!(query);
let json_str = json!({
"query":{
"match_phrase":{
"brand":{
"query": "DPH",
"analyzer": "english",
"slop": 2,
"zero_terms_query": "all"
}
}
},
"_source":["brand"]
});
assert_eq!(json_str, json);
}