blob: 9a2456bdd535a2bb604c3534e3243b92593c4cc2 (
plain)
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
|
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
package elastic
// TermsLookup encapsulates the parameters needed to fetch terms.
//
// For more details, see
// https://www.elastic.co/guide/en/elasticsearch/reference/6.0/query-dsl-terms-query.html#query-dsl-terms-lookup.
type TermsLookup struct {
index string
typ string
id string
path string
routing string
}
// NewTermsLookup creates and initializes a new TermsLookup.
func NewTermsLookup() *TermsLookup {
t := &TermsLookup{}
return t
}
// Index name.
func (t *TermsLookup) Index(index string) *TermsLookup {
t.index = index
return t
}
// Type name.
func (t *TermsLookup) Type(typ string) *TermsLookup {
t.typ = typ
return t
}
// Id to look up.
func (t *TermsLookup) Id(id string) *TermsLookup {
t.id = id
return t
}
// Path to use for lookup.
func (t *TermsLookup) Path(path string) *TermsLookup {
t.path = path
return t
}
// Routing value.
func (t *TermsLookup) Routing(routing string) *TermsLookup {
t.routing = routing
return t
}
// Source creates the JSON source of the builder.
func (t *TermsLookup) Source() (interface{}, error) {
src := make(map[string]interface{})
if t.index != "" {
src["index"] = t.index
}
if t.typ != "" {
src["type"] = t.typ
}
if t.id != "" {
src["id"] = t.id
}
if t.path != "" {
src["path"] = t.path
}
if t.routing != "" {
src["routing"] = t.routing
}
return src, nil
}
|