@@ -143,7 +143,7 @@ func (o *ElasticSearchOutput) Init(config interface{}) (err error) {
143
143
}
144
144
}
145
145
146
- o .bulkIndexer = NewHttpBulkIndexer (scheme , serverUrl .Host ,
146
+ o .bulkIndexer = NewHttpBulkIndexer (scheme , serverUrl .Host , serverUrl . Path ,
147
147
o .conf .FlushCount , o .conf .Username , o .conf .Password , o .conf .HTTPTimeout ,
148
148
o .conf .HTTPDisableKeepalives , o .conf .ConnectTimeout , tlsConf )
149
149
case "udp" :
@@ -403,6 +403,8 @@ type HttpBulkIndexer struct {
403
403
Protocol string
404
404
// Host name and port number (default to "localhost:9200").
405
405
Domain string
406
+ // Path (default to "")
407
+ Path string
406
408
// Maximum number of documents.
407
409
MaxCount int
408
410
// Internal HTTP Client.
@@ -413,7 +415,7 @@ type HttpBulkIndexer struct {
413
415
password string
414
416
}
415
417
416
- func NewHttpBulkIndexer (protocol string , domain string , maxCount int ,
418
+ func NewHttpBulkIndexer (protocol string , domain string , path string , maxCount int ,
417
419
username string , password string , httpTimeout uint32 , httpDisableKeepalives bool ,
418
420
connectTimeout uint32 , tlsConf * tls.Config ) * HttpBulkIndexer {
419
421
@@ -432,6 +434,7 @@ func NewHttpBulkIndexer(protocol string, domain string, maxCount int,
432
434
return & HttpBulkIndexer {
433
435
Protocol : protocol ,
434
436
Domain : domain ,
437
+ Path : path ,
435
438
MaxCount : maxCount ,
436
439
client : client ,
437
440
username : username ,
@@ -450,7 +453,7 @@ func (h *HttpBulkIndexer) Index(body []byte) (err error, retry bool) {
450
453
var response_body []byte
451
454
var response_body_json map [string ]interface {}
452
455
453
- url := fmt .Sprintf ("%s://%s%s" , h .Protocol , h .Domain , "/_bulk" )
456
+ url := fmt .Sprintf ("%s://%s%s%s " , h .Protocol , h .Domain , h . Path , "/_bulk" )
454
457
455
458
// Creating ElasticSearch Bulk HTTP request
456
459
request , err := http .NewRequest ("POST" , url , bytes .NewReader (body ))
0 commit comments