-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsolr_response.go
60 lines (52 loc) · 1.22 KB
/
solr_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
package solr
type SolrResponse struct {
Status int `json:"status"`
QTime int `json:"qtime"`
Params struct {
Query string `json:"q"`
Indent string `json:"indent"`
Wt string `json:"wt"`
} `json:"params"`
Response Response `json:"response"`
NextCursorMark string `json:"nextCursorMark"`
Adds Adds `json:"adds"`
}
type Response struct {
NumFound uint32 `json:"numFound"`
Start int `json:"start"`
Docs []map[string]interface{} `json:"docs"`
}
func GetDocIdFromDoc(m map[string]interface{}) string {
if v, ok := m["id"]; ok {
return v.(string)
}
return ""
}
func GetVersionFromDoc(m map[string]interface{}) int {
if v, ok := m["_version_"]; ok {
switch v := v.(type) {
case float64:
return int(v)
case int:
return v
}
}
return 0
}
type Adds map[string]int
type UpdateResponse struct {
Response struct {
Status int `json:"status"`
QTime int `json:"QTime"`
RF int `json:"rf"`
MinRF int `json:"min_rf"`
} `json:"responseHeader"`
Error struct {
Metadata []string `json:"metadata"`
Msg string `json:"msg"`
Code int `json:"code"`
}
}
type DeleteRequest struct {
Delete []string `json:"delete"`
}