forked from aquasecurity/esquery
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquery_match_test.go
68 lines (66 loc) · 1.39 KB
/
query_match_test.go
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
62
63
64
65
66
67
68
package esquery
import (
"testing"
)
func TestMatch(t *testing.T) {
runMapTests(t, []mapTest{
{
"simple match",
Match("title", "sample text"),
map[string]interface{}{
"match": map[string]interface{}{
"title": map[string]interface{}{
"query": "sample text",
},
},
},
},
{
"match with more params",
Match("issue_number").Query(16).Transpositions(false).MaxExpansions(32).Operator(OperatorAnd),
map[string]interface{}{
"match": map[string]interface{}{
"issue_number": map[string]interface{}{
"query": 16,
"max_expansions": 32,
"transpositions": false,
"operator": "AND",
},
},
},
},
{
"match_bool_prefix",
MatchBoolPrefix("title", "sample text"),
map[string]interface{}{
"match_bool_prefix": map[string]interface{}{
"title": map[string]interface{}{
"query": "sample text",
},
},
},
},
{
"match_phrase",
MatchPhrase("title", "sample text"),
map[string]interface{}{
"match_phrase": map[string]interface{}{
"title": map[string]interface{}{
"query": "sample text",
},
},
},
},
{
"match_phrase_prefix",
MatchPhrasePrefix("title", "sample text"),
map[string]interface{}{
"match_phrase_prefix": map[string]interface{}{
"title": map[string]interface{}{
"query": "sample text",
},
},
},
},
})
}