-
Notifications
You must be signed in to change notification settings - Fork 6
/
structs.go
139 lines (126 loc) · 3.83 KB
/
structs.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package elasticsearch
import "encoding/json"
// Response represents a boolean response sent back by the search egine
type Response struct {
Acknowledged bool
Error string
Status int
}
// Settings represents the mapping structure of one or several indices
type Settings struct {
Shards map[string]interface{} `json:"_shards"`
Indices map[string]interface{} `json:"indices"`
}
// Status represents the status of the search engine
type Status struct {
TagLine string
Version struct {
Number string
BuildHash string `json:"build_hash"`
BuildTimestamp string `json:"build_timestamp"`
BuildSnapshot bool `json:"build_snapshot"`
LuceneVersion string `json:"lucene_version"`
}
Name string
Status int
Ok bool
}
// InsertDocument represents the result of the insert operation of a document
type InsertDocument struct {
Created bool `json:"created"`
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
}
// Document represents a document
type Document struct {
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
Found bool `json:"found"`
Source json.RawMessage `json:"_source"`
}
// Bulk represents the result of the Bulk operation
type Bulk struct {
Took uint64 `json:"took"`
Errors bool `json:"errors"`
Items []struct {
Create struct {
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Status int `json:"status"`
Error string `json:"error"`
} `json:"create"`
Index struct {
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
Status int `json:"status"`
Error struct {
Type string `json:"status"`
Reason string `json:"reason"`
Index_UUID string `json:"index_uuid"`
Shard string `json:"shard"`
Index string `json:"index"`
} `json:"error"`
} `json:"index"`
} `json:"items"`
}
// SearchResult represents the result of the search operation
type SearchResult struct {
Took uint64 `json:"took"`
TimedOut bool `json:"timed_out"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
} `json:"_shards"`
Hits ResultHits `json:"hits"`
Aggregations json.RawMessage `json:"aggregations"`
}
// ResultHits represents the result of the search hits
type ResultHits struct {
Total struct {
Value int `json:"value"`
Relation string `json:"relation"`
} `json:"total"`
MaxScore float32 `json:"max_score"`
Hits []Hit `json:"hits"`
}
type Hit struct {
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Score float32 `json:"_score"`
Source json.RawMessage `json:"_source"`
Highlight map[string][]string `json:"highlight,omitempty"`
}
// MSearchQuery Multi Search query
type MSearchQuery struct {
Header string // index name, document type
Body string // query related to the declared index
}
// MSearchResult Multi search result
type MSearchResult struct {
Responses []SearchResult `json:"responses"`
}
type UpdateByQueryResult struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Total int `json:"total"`
Updated int `json:"updated"`
Deleted int `json:"deleted"`
Batches int `json:"batches"`
VersionConflicts int `json:"version_conflicts"`
Noops int `json:"noops"`
Retries struct {
Bulk int `json:"bulk"`
Search int `json:"search"`
} `json:"retries"`
Failures []interface{} `json:"failures"`
}