/
spelunker_v2.go
65 lines (44 loc) · 1.23 KB
/
spelunker_v2.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
package document
import (
"context"
)
// PrepareSpelunkerV2Document prepares a Who's On First document for indexing with the
// "v2" OpenSearch (v2.x) schema. For details please consult:
func PrepareSpelunkerV2Document(ctx context.Context, body []byte) ([]byte, error) {
prepped, err := ExtractProperties(ctx, body)
if err != nil {
return nil, err
}
return AppendSpelunkerV2Properties(ctx, prepped)
}
// AppendSpelunkerV2Properties appends properties specific to the v2" OpenSearch (v2.x) schema
// to a Who's On First document for. For details please consult:
func AppendSpelunkerV2Properties(ctx context.Context, body []byte) ([]byte, error) {
var err error
body, err = AppendNameStats(ctx, body)
if err != nil {
return nil, err
}
body, err = AppendConcordancesStats(ctx, body)
if err != nil {
return nil, err
}
body, err = AppendConcordancesMachineTags(ctx, body)
if err != nil {
return nil, err
}
body, err = AppendPlacetypeDetails(ctx, body)
if err != nil {
return nil, err
}
body, err = AppendExistentialDetails(ctx, body)
if err != nil {
return nil, err
}
body, err = AppendEDTFRanges(ctx, body)
if err != nil {
return nil, err
}
// to do: categories and machine tags...
return body, nil
}