Skip to content

Conversation

@arp242
Copy link
Contributor

@arp242 arp242 commented Sep 11, 2024

I would like to convert a TypedClient to a regular Client; my main use-case for this is so I can use it for the bulk indexer.

Converting a TypedClient to Client is fairly straight-forward:

func ToClient(tc *elasticsearch.TypedClient) *elasticsearch.Client {
	c := &elasticsearch.Client{
		BaseClient: tc.BaseClient,
	}
	c.API = esapi.New(c)
	return c
}

Which works, but also gives an error on go vet;

literal copies lock value from ns.TypedClient.BaseClient:
github.com/elastic/go-elasticsearch/v8.BaseClient contains sync.RWMutex

This fixes that.

@cla-checker-service
Copy link

cla-checker-service bot commented Sep 11, 2024

💚 CLA has been signed

I would like to convert a TypedClient to a regular Client; my main
use-case for this is so I can use it for the bulk indexer.

Converting a TypedClient to Client is fairly straight-forward:

	func ToClient(tc *elasticsearch.TypedClient) *elasticsearch.Client {
		c := &elasticsearch.Client{
			BaseClient: tc.BaseClient,
		}
		c.API = esapi.New(c)
		return c
	}

Which works, but also gives an error on go vet;

	literal copies lock value from ns.TypedClient.BaseClient:
	github.com/elastic/go-elasticsearch/v8.BaseClient contains sync.RWMutex

This fixes that.
@Anaethelion
Copy link
Contributor

Thank you, however I'm closing this in favor of #957

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants