-
Notifications
You must be signed in to change notification settings - Fork 10
/
response.go
109 lines (93 loc) · 3.1 KB
/
response.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
package solr
import "time"
// BaseResponse is the base response
type BaseResponse struct {
Header *ResponseHeader `json:"responseHeader"`
Error *ResponseError `json:"error,omitempty"`
}
// ResponseHeader is a response header
type ResponseHeader struct {
ZKConnected bool `json:"zkConnected"`
Status int `json:"status"`
QTime int `json:"QTime"`
}
// ResponseError is a response error
type ResponseError struct {
Code int `json:"code"`
Metadata []string `json:"metadata"`
Msg string `json:"msg"`
}
func (e ResponseError) Error() string {
return e.Msg
}
// UpdateResponse is an update response
type UpdateResponse struct {
*BaseResponse
}
// QueryResponse is a query response
type QueryResponse struct {
*BaseResponse
Response QueryResponseBody `json:"response,omitempty"`
Facets M `json:"facets,omitempty"`
}
// QueryResponseBody is the query response body
type QueryResponseBody struct {
NumFound int `json:"numFound,omitempty"`
Start int `json:"start,omitempty"`
MaxScore float64 `json:"maxScore,omitempty"`
Documents []M `json:"docs,omitempty"`
}
// SuggestResponse is the suggester response
type SuggestResponse struct {
*BaseResponse
Command string `json:"command,omitempty"`
Suggest *SuggestBody `json:"suggest,omitempty"`
}
// SuggestBody is the suggest body
type SuggestBody map[string]SuggestTerm
// SuggestTerm is suggest term
type SuggestTerm map[string]SuggestTermBody
// SuggestTermBody is the suggest term body
type SuggestTermBody struct {
NumFound int `json:"numFound,omitempty"`
Suggestions []Suggestion `json:"suggestions,omitempty"`
}
// Suggestion is a term suggestion
type Suggestion struct {
Term string `json:"term"`
Weight int `json:"weight"`
Payload string `json:"payload,omitempty"`
}
// CoreStatusResponse is the core status response
type CoreStatusResponse struct {
*BaseResponse
InitFailures M `json:"initFailures"`
Status map[string]*CoreStatus `json:"status"`
}
// CoreStatus is the core status
type CoreStatus struct {
Config string `json:"config"`
DataDir string `json:"dataDir"`
Index *Index `json:"index"`
InstanceDir string `json:"instanceDir"`
Name string `json:"name"`
Schema string `json:"schema"`
StartTime *time.Time `json:"startTime"`
Uptime int `json:"uptime"`
}
// Index is the index details from core status
type Index struct {
Current bool `json:"current"`
DeletedDocs int `json:"deletedDocs"`
Directory string `json:"directory"`
HasDeletions bool `json:"hasDeletions"`
IndexHeapUsageBytes int `json:"indexHeapUsageBytes"`
MaxDoc int `json:"maxDoc"`
NumDocs int `json:"numDocs"`
SegmentCount int `json:"segmentCount"`
SegmentFile string `json:"segmentFile"`
SegmentsFileSizeInBytes int `json:"segmentsFileSizeInBytes"`
Size string `json:"size"`
UserData M `json:"userData"`
Version int
}