-
Notifications
You must be signed in to change notification settings - Fork 0
/
spelunker_v1.go
55 lines (38 loc) · 1.21 KB
/
spelunker_v1.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
package document
import (
"context"
)
// PrepareSpelunkerV1Document prepares a Who's On First document for indexing with the
// "v1" Elasticsearch (v2.x) schema. For details please consult:
// https://github.com/whosonfirst/es-whosonfirst-schema/tree/master/schema/2.4
func PrepareSpelunkerV1Document(ctx context.Context, body []byte) ([]byte, error) {
prepped, err := ExtractProperties(ctx, body)
if err != nil {
return nil, err
}
return AppendSpelunkerV1Properties(ctx, prepped)
}
// AppendSpelunkerV1Properties appends properties specific to the v1" Elasticsearch (v2.x) schema
// to a Who's On First document for. For details please consult:
// https://github.com/whosonfirst/es-whosonfirst-schema/tree/master/schema/2.4
func AppendSpelunkerV1Properties(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 = AppendPlacetypeDetails(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
}