Skip to content

Commit fd5b446

Browse files
committed
updated
Signed-off-by: Naitik Yadav <naitik.yadav641@gmail.com>
1 parent 17cb927 commit fd5b446

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

opensearchutil/bulk_indexer.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"io"
3636
"net/http"
3737
"net/url"
38-
"path"
3938
"runtime"
4039
"strings"
4140
"sync"
@@ -282,10 +281,17 @@ func (bi *bulkIndexer) Add(ctx context.Context, item BulkIndexerItem) error {
282281
idx = bi.config.Index
283282
}
284283

285-
u := url.URL{Path: path.Join("/", idx, "_doc", item.DocumentID)}
286-
req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), nil)
284+
encodedPath := "/" + url.PathEscape(idx) + "/_doc/" + url.PathEscape(item.DocumentID)
285+
286+
if p, err := url.PathUnescape(encodedPath); err == nil {
287+
req := (&http.Request{
288+
Method: http.MethodPost,
289+
URL: &url.URL{
290+
Path: p,
291+
RawPath: encodedPath,
292+
},
293+
}).WithContext(ctx)
287294

288-
if err == nil {
289295
if hop, evalErr := bi.docRouter.Eval(ctx, req); evalErr == nil && hop.Conn != nil {
290296
bi.queues.RLock()
291297
targetQueue = bi.queues.m[hop.Conn]

0 commit comments

Comments
 (0)