-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathterm.go
39 lines (31 loc) · 924 Bytes
/
term.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
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package dsl
func (n *Node) Term(field string, value interface{}, boost *float64) *Node {
childNode := n.appendOrSetChildNode(kKeywordTerm)
leaf := value
if boost != nil {
leaf = &struct {
Value interface{} `json:"value"`
Boost *float64 `json:"boost,omitempty"`
}{
value,
boost,
}
}
childNode.nodeMap = nodeMapT{field: &Node{
leaf: leaf,
}}
return childNode
}
func (n *Node) Terms(field string, value interface{}, boost *float64) *Node {
childNode := n.appendOrSetChildNode(kKeywordTerms)
childNode.nodeMap = nodeMapT{
field: &Node{leaf: value},
}
if boost != nil {
childNode.nodeMap[kKeywordBoost] = &Node{leaf: *boost}
}
return childNode
}