From 57e18a1a7a9df4465ccf956d4dfc02ee99a79306 Mon Sep 17 00:00:00 2001 From: Karl Becker Date: Mon, 20 Nov 2023 15:46:59 -0600 Subject: [PATCH 1/2] Add section for closing the client connection I could not find this anywhere in the JavaScript client docs, and I think it's worth a mention here --- docs/connecting.asciidoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index 77c2e7d11..c39db9ec7 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -13,6 +13,7 @@ This page contains the information you need to connect and use the Client with * <> * <> * <> +* <> [[authentication]] [discrete] @@ -691,6 +692,23 @@ const client = new Client({ }) ---- +[discrete] +[[close-connection]] +=== Close connection + +If you want to end a connection to an Elasticsearch server, use the `close()` function. + +[source,js] +---- +const client = new Client({ + node: 'http://localhost:9200' +}); +// ... do various queries +client.close(); +---- + + + [discrete] [[product-check]] === Automatic product check @@ -702,3 +720,4 @@ be sent to the server as part of the request pipeline before the main API call i In most cases, this will succeed during the very first API call that the client sends. Once the product check completes, no further product check HTTP requests are sent for subsequent API calls. + From d18f0988dc93ce057a891829301ac27d84425e74 Mon Sep 17 00:00:00 2001 From: Karl Becker Date: Mon, 20 Nov 2023 15:51:05 -0600 Subject: [PATCH 2/2] Improve the Table of Contents --- docs/connecting.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index c39db9ec7..85a9154a5 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -12,8 +12,8 @@ This page contains the information you need to connect and use the Client with * <> * <> * <> -* <> * <> +* <> [[authentication]] [discrete] @@ -692,9 +692,10 @@ const client = new Client({ }) ---- + +[[closing]] [discrete] -[[close-connection]] -=== Close connection +=== Closing the client If you want to end a connection to an Elasticsearch server, use the `close()` function. @@ -708,7 +709,6 @@ client.close(); ---- - [discrete] [[product-check]] === Automatic product check