forked from defensestation/osquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery_nested_test.go
More file actions
61 lines (59 loc) · 1.36 KB
/
query_nested_test.go
File metadata and controls
61 lines (59 loc) · 1.36 KB
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
58
59
60
61
package osquery
import "testing"
// Test cases for NestedQuery
func TestNestedQuery(t *testing.T) {
runMapTests(t, []mapTest{
{
"nested query without optional fields",
Nested("comments", Term("user", "kimchy")),
map[string]interface{}{
"nested": map[string]interface{}{
"path": "comments",
"query": map[string]interface{}{
"term": map[string]interface{}{
"user": map[string]interface{}{
"value": "kimchy",
},
},
},
},
},
},
{
"nested query with score_mode",
Nested("comments", Term("user", "kimchy")).ScoreMode(ScoreModeMax),
map[string]interface{}{
"nested": map[string]interface{}{
"path": "comments",
"query": map[string]interface{}{
"term": map[string]interface{}{
"user": map[string]interface{}{
"value": "kimchy",
},
},
},
"score_mode": "max",
},
},
},
{
"nested query with inner_hits",
Nested("comments", Term("user", "kimchy")).InnerHits(map[string]interface{}{"size": 3}),
map[string]interface{}{
"nested": map[string]interface{}{
"path": "comments",
"query": map[string]interface{}{
"term": map[string]interface{}{
"user": map[string]interface{}{
"value": "kimchy",
},
},
},
"inner_hits": map[string]interface{}{
"size": 3,
},
},
},
},
})
}