This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
forked from maximelamure/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
111 lines (100 loc) · 3.03 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
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 string `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"`
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 int `json:"total"`
MaxScore float32 `json:"max_score"`
Hits []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"`
} `json:"hits"`
}
// 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"`
}