forked from mattbaird/elastigo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
baseResponse.go
61 lines (51 loc) · 1.42 KB
/
baseResponse.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
package api
import (
"fmt"
)
type BaseResponse struct {
Ok bool `json:"ok"`
Index string `json:"_index,omitempty"`
Type string `json:"_type,omitempty"`
Id string `json:"_id,omitempty"`
Source interface{} `json:"_source,omitempty"` // depends on the schema you've defined
Version int `json:"_version,omitempty"`
Found bool `json:"found,omitempty"`
Exists bool `json:"exists,omitempty"`
}
type Status struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
}
type Match struct {
OK bool `json:"ok"`
Matches []string `json:"matches"`
Explaination Explaination `json:"explaination,omitempty"`
}
type Explaination struct {
Value float32 `json:"value"`
Description string `json:"description"`
Details []Explaination `json:"details,omitempty"`
}
func Pretty(pretty bool) string {
prettyString := ""
if pretty == true {
prettyString = "pretty=1"
}
return prettyString
}
// http://www.elasticsearch.org/guide/reference/api/search/search-type/
func Scan(scan int) string {
scanString := ""
if scan > 0 {
scanString = fmt.Sprintf("&search_type=scan&size=%v",scan)
}
return scanString
}
func Scroll(duration string) string {
scrollString := ""
if duration != "" {
scrollString = "&scroll="+duration
}
return scrollString
}