NewBase creates a new [BaseClient] configured with the given options. It does not attach the esapi or typed API surface, which keeps the binary smaller for programs that only need [BaseClient.Perform]. With no options the client connects to http://localhost:9200, or to the address(es) in the ELASTI
(opts ...Option)
| 345 | // elasticsearch.WithAPIKey("base64-encoded-key"), |
| 346 | // ) |
| 347 | func NewBase(opts ...Option) (*BaseClient, error) { |
| 348 | ro, err := resolveOptions(opts, "") |
| 349 | if err != nil { |
| 350 | return nil, err |
| 351 | } |
| 352 | client := &BaseClient{ |
| 353 | Transport: ro.transport, |
| 354 | disableMetaHeader: ro.disableMetaHeader, |
| 355 | metaHeader: ro.metaHeader, |
| 356 | compatibilityHeader: ro.compatibilityHeader, |
| 357 | autoDrainBody: ro.autoDrainBody, |
| 358 | } |
| 359 | if ro.discoverNodesOnStart { |
| 360 | go func() { _ = client.DiscoverNodes() }() |
| 361 | } |
| 362 | return client, nil |
| 363 | } |
| 364 | |
| 365 | // NewTyped creates a new [TypedClient] configured with the given options. |
| 366 | // |