Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit 6a9843b

Browse files
authored
use primary as source for FieldTranslate backup data (#2255)
* use primary as source for FieldTranslate backup data
1 parent 41b8505 commit 6a9843b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal_client.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -2259,9 +2259,17 @@ func (c *InternalClient) IndexTranslateDataReader(ctx context.Context, index str
22592259
func (c *InternalClient) FieldTranslateDataReader(ctx context.Context, index, field string) (io.ReadCloser, error) {
22602260
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.FieldTranslateDataReader")
22612261
defer span.Finish()
2262+
nodes, err := c.Nodes(ctx)
2263+
if err != nil {
2264+
return nil, err
2265+
}
22622266

2267+
primary := getPrimaryNode(nodes)
2268+
if primary == nil {
2269+
return nil, errors.New("no primary")
2270+
}
22632271
// Execute request against the host.
2264-
u := fmt.Sprintf("%s%s/internal/translate/data?index=%s&field=%s", c.defaultURI, c.prefix(), url.QueryEscape(index), url.QueryEscape(field))
2272+
u := fmt.Sprintf("%s%s/internal/translate/data?index=%s&field=%s", primary.URI, c.prefix(), url.QueryEscape(index), url.QueryEscape(field))
22652273

22662274
// Build request.
22672275
req, err := http.NewRequest("GET", u, nil)

0 commit comments

Comments
 (0)