/
descendants.go
38 lines (27 loc) · 1.1 KB
/
descendants.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
package opensearch
import (
"context"
"strings"
"github.com/aaronland/go-pagination"
opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi"
"github.com/whosonfirst/go-whosonfirst-spelunker"
wof_spr "github.com/whosonfirst/go-whosonfirst-spr/v2"
)
func (s *OpenSearchSpelunker) GetDescendants(ctx context.Context, pg_opts pagination.Options, id int64, filters []spelunker.Filter) (wof_spr.StandardPlacesResults, pagination.Results, error) {
q := s.descendantsQuery(id, filters)
return s.searchPaginated(ctx, pg_opts, q)
}
func (s *OpenSearchSpelunker) GetDescendantsFaceted(ctx context.Context, id int64, filters []spelunker.Filter, facets []*spelunker.Facet) ([]*spelunker.Faceting, error) {
q := s.descendantsFacetedQuery(id, filters, facets)
sz := 0
req := &opensearchapi.SearchRequest{
Body: strings.NewReader(q),
Size: &sz,
}
return s.facet(ctx, req, facets)
}
func (s *OpenSearchSpelunker) CountDescendants(ctx context.Context, id int64) (int64, error) {
filters := make([]spelunker.Filter, 0)
q := s.descendantsQuery(id, filters)
return s.countForQuery(ctx, q)
}