Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change BulkIndexerConfig to improve comptability with both Client and TypedClient #653

Open
ludovic-franconieri opened this issue Apr 5, 2023 · 1 comment

Comments

@ludovic-franconieri
Copy link

Hello,

The BulkIndexerConfig ask for a Client *elasticsearch.Client

// BulkIndexerConfig represents configuration of the indexer.
type BulkIndexerConfig struct {
...
	Client      *elasticsearch.Client   // The Elasticsearch client.
...
}

Even though it only use the transport part :

func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, error)

So, if you use a TypedClient, you can't use it in BulkIndexerConfig, you will have to instantiate a Client only for the BulkIndexerConfig.

What I propose is to change the BulkIndexerConfig to ask for a Transport so it can be compatible with both Client and TypedClient

// BulkIndexerConfig represents configuration of the indexer.
type BulkIndexerConfig struct {
...
	Transport   esapi.Transport         // The Elasticsearch transport.
...

If you want, I already push the changes in a branch => https://github.com/ludovic-franconieri/go-elasticsearch/tree/bulk_indexer_transport

Thanks

@arp242
Copy link

arp242 commented Sep 11, 2024

Another way to address the issue is to allow "converting" a TypedClient to a Client. You can kind-of already do this, and it works, but gives a go vet error. Patch to fix at: #905

Maybe a helper or some such might be nice too.

Personally I'd say that's enough to consider this fixed, and would be better than changing bulkindexer: it's fairly straight-forward, compatible, and simple.

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

No branches or pull requests

3 participants