forked from aquasecurity/esquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highlight_test.go
93 lines (91 loc) · 2.37 KB
/
highlight_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package query
import (
"testing"
)
func TestHighlight(t *testing.T) {
runMapTests(t, []mapTest{
{
"simple highlight",
Highlight().Field("content"),
map[string]interface{}{
"fields": map[string]interface{}{
"content": map[string]interface{}{},
},
},
},
{
"highlight all params",
Highlight().
PreTags("<pre>", "<code>").
PostTags("</code>", "</pre>").
Field("content",
Highlight().
BoundaryChars(".;,")).
FragmentSize(150).
NumberOfFragments(4).
Type(HighlighterPlain).
BoundaryChars("()[]").
BoundaryMaxScan(32).
BoundaryScanner(BoundaryScannerChars).
BoundaryScannerLocale("en-US").
Encoder(EncoderHtml).
ForceSource(true).
Fragmenter(FragmenterSimple).
FragmentOffset(6).
HighlightQuery(
Bool().
Must(
Match("author").
Query("some guy").
Analyzer("analyzer?").
Fuzziness("fuzz"))).
MatchedFields("title", "body").
NoMatchSize(64).
Order(OrderScore).
PhraseLimit(512).
RequireFieldMatch(false).
TagsSchema(TagsSchemaStyled),
map[string]interface{}{
"pre_tags": []string{"<pre>", "<code>"},
"post_tags": []string{"</code>", "</pre>"},
"fragment_size": 150,
"number_of_fragments": 4,
"type": "plain",
"boundary_chars": "()[]",
"boundary_scanner": "chars",
"boundary_max_scan": 32,
"boundary_scanner_locale": "en-US",
"encoder": "html",
"force_source": true,
"fragment_offset": 6,
"fragmenter": "simple",
"matched_fields": []string{"title", "body"},
"no_match_size": 64,
"order": "score",
"phrase_limit": 512,
"require_field_match": false,
"tags_schema": "styled",
"fields": map[string]interface{}{
"content": map[string]interface{}{
"boundary_chars": ".;,",
},
},
"query": map[string]interface{}{
"bool": map[string]interface{}{
"must": []map[string]interface{}{
{
"match": map[string]interface{}{
"author": map[string]interface{}{
"analyzer": "analyzer?",
"fuzziness": "fuzz",
"query": "some guy",
},
},
},
},
},
},
},
},
})
}