File tree 9 files changed +54
-24
lines changed
9 files changed +54
-24
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,9 @@ func (s *AliasService) Do() (*AliasResult, error) {
81
81
if s .pretty {
82
82
params .Set ("pretty" , fmt .Sprintf ("%v" , s .pretty ))
83
83
}
84
- urls += "?" + params .Encode ()
84
+ if len (params ) > 0 {
85
+ urls += "?" + params .Encode ()
86
+ }
85
87
86
88
// Actions
87
89
body := make (map [string ]interface {})
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ func (s *AliasesService) Do() (*AliasesResult, error) {
76
76
if s .pretty {
77
77
params .Set ("pretty" , fmt .Sprintf ("%v" , s .pretty ))
78
78
}
79
- urls += "?" + params .Encode ()
79
+ if len (params ) > 0 {
80
+ urls += "?" + params .Encode ()
81
+ }
80
82
81
83
if s .debug {
82
84
out , _ := httputil .DumpRequestOut ((* http .Request )(req ), true )
Original file line number Diff line number Diff line change @@ -23,18 +23,18 @@ type BulkService struct {
23
23
requests []BulkableRequest
24
24
//replicationType string
25
25
//consistencyLevel string
26
- refresh * bool
27
- pretty bool
28
- debug bool
26
+ refresh * bool
27
+ pretty bool
28
+ debug bool
29
29
debugOnError bool
30
30
}
31
31
32
32
func NewBulkService (client * Client ) * BulkService {
33
33
builder := & BulkService {
34
- client : client ,
35
- requests : make ([]BulkableRequest , 0 ),
36
- pretty : false ,
37
- debug : false ,
34
+ client : client ,
35
+ requests : make ([]BulkableRequest , 0 ),
36
+ pretty : false ,
37
+ debug : false ,
38
38
debugOnError : false ,
39
39
}
40
40
return builder
@@ -132,7 +132,9 @@ func (s *BulkService) Do() (*BulkResponse, error) {
132
132
if s .refresh != nil {
133
133
params .Set ("refresh" , fmt .Sprintf ("%v" , * s .refresh ))
134
134
}
135
- urls += "?" + params .Encode ()
135
+ if len (params ) > 0 {
136
+ urls += "?" + params .Encode ()
137
+ }
136
138
137
139
// Set up a new request
138
140
req , err := s .client .NewRequest ("POST" , urls )
@@ -171,7 +173,7 @@ func (s *BulkService) Do() (*BulkResponse, error) {
171
173
}
172
174
defer res .Body .Close ()
173
175
174
- // Debug
176
+ // Debug
175
177
if s .debug {
176
178
out , _ := httputil .DumpResponse (res , true )
177
179
fmt .Printf ("%s\n " , string (out ))
Original file line number Diff line number Diff line change @@ -84,7 +84,9 @@ func (s *CountService) Do() (int64, error) {
84
84
if s .pretty {
85
85
params .Set ("pretty" , fmt .Sprintf ("%v" , s .pretty ))
86
86
}
87
- urls += "?" + params .Encode ()
87
+ if len (params ) > 0 {
88
+ urls += "?" + params .Encode ()
89
+ }
88
90
89
91
// Set up a new request
90
92
req , err := s .client .NewRequest ("GET" , urls )
Original file line number Diff line number Diff line change @@ -75,7 +75,9 @@ func (s *FlushService) Do() (*FlushResult, error) {
75
75
if s .full != nil {
76
76
params .Set ("full" , fmt .Sprintf ("%v" , * s .full ))
77
77
}
78
- urls += "?" + params .Encode ()
78
+ if len (params ) > 0 {
79
+ urls += "?" + params .Encode ()
80
+ }
79
81
80
82
// Set up a new request
81
83
req , err := s .client .NewRequest ("POST" , urls )
Original file line number Diff line number Diff line change @@ -20,15 +20,14 @@ type GetService struct {
20
20
routing string
21
21
preference string
22
22
fields []string
23
- refresh bool
24
- realtime bool
23
+ refresh * bool
24
+ realtime * bool
25
25
}
26
26
27
27
func NewGetService (client * Client ) * GetService {
28
28
builder := & GetService {
29
- client : client ,
30
- _type : "_all" ,
31
- realtime : true ,
29
+ client : client ,
30
+ _type : "_all" ,
32
31
}
33
32
return builder
34
33
}
@@ -82,12 +81,12 @@ func (b *GetService) Fields(fields ...string) *GetService {
82
81
}
83
82
84
83
func (b * GetService ) Refresh (refresh bool ) * GetService {
85
- b .refresh = refresh
84
+ b .refresh = & refresh
86
85
return b
87
86
}
88
87
89
88
func (b * GetService ) Realtime (realtime bool ) * GetService {
90
- b .realtime = realtime
89
+ b .realtime = & realtime
91
90
return b
92
91
}
93
92
@@ -99,8 +98,23 @@ func (b *GetService) Do() (*GetResult, error) {
99
98
urls = strings .Replace (urls , "{id}" , cleanPathString (b .id ), 1 )
100
99
101
100
params := make (url.Values )
101
+ if b .realtime != nil {
102
+ params .Add ("realtime" , fmt .Sprintf ("%v" , * b .realtime ))
103
+ }
104
+ if len (b .fields ) > 0 {
105
+ params .Add ("fields" , strings .Join (b .fields , "," ))
106
+ }
107
+ if b .routing != "" {
108
+ params .Add ("routing" , b .routing )
109
+ }
110
+ if b .preference != "" {
111
+ params .Add ("preference" , b .preference )
112
+ }
113
+ if b .refresh != nil {
114
+ params .Add ("refresh" , fmt .Sprintf ("%v" , * b .refresh ))
115
+ }
102
116
if len (params ) > 0 {
103
- urls += params .Encode ()
117
+ urls += "?" + params .Encode ()
104
118
}
105
119
106
120
// Set up a new request
Original file line number Diff line number Diff line change @@ -89,7 +89,9 @@ func (b *IndexService) Do() (*IndexResult, error) {
89
89
if b .pretty {
90
90
params .Set ("pretty" , fmt .Sprintf ("%v" , b .pretty ))
91
91
}
92
- urls += "?" + params .Encode ()
92
+ if len (params ) > 0 {
93
+ urls += "?" + params .Encode ()
94
+ }
93
95
94
96
// Set up a new request
95
97
req , err := b .client .NewRequest ("PUT" , urls )
Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ func (s *ScanService) Do() (*ScanCursor, error) {
153
153
if s .size != nil && * s .size > 0 {
154
154
params .Set ("size" , fmt .Sprintf ("%d" , * s .size ))
155
155
}
156
- urls += "?" + params .Encode ()
156
+ if len (params ) > 0 {
157
+ urls += "?" + params .Encode ()
158
+ }
157
159
158
160
// Set up a new request
159
161
req , err := s .client .NewRequest ("POST" , urls )
Original file line number Diff line number Diff line change @@ -212,7 +212,9 @@ func (s *SearchService) Do() (*SearchResult, error) {
212
212
if s .searchType != "" {
213
213
params .Set ("search_type" , s .searchType )
214
214
}
215
- urls += "?" + params .Encode ()
215
+ if len (params ) > 0 {
216
+ urls += "?" + params .Encode ()
217
+ }
216
218
217
219
// Set up a new request
218
220
req , err := s .client .NewRequest ("POST" , urls )
You can’t perform that action at this time.
0 commit comments