@@ -20,7 +20,7 @@ If you have your own CA bundle to use you can configure via the `ca_certs` param
2020
2121[source,python]
2222------------------------------------
23- es = Elasticsearch(
23+ client = Elasticsearch(
2424 "https://...",
2525 ca_certs="/path/to/certs.pem"
2626)
@@ -32,7 +32,7 @@ In Python 3.9 and earlier only the leaf certificate will be verified but in Pyth
3232
3333[source,python]
3434------------------------------------
35- es = Elasticsearch(
35+ client = Elasticsearch(
3636 "https://...",
3737 ssl_assert_fingerprint=(
3838 "315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3"
@@ -44,7 +44,7 @@ To disable certificate verification use the `verify_certs=False` parameter. This
4444
4545[source,python]
4646------------------------------------
47- es = Elasticsearch(
47+ client = Elasticsearch(
4848 "https://...",
4949 verify_certs=False
5050)
@@ -59,7 +59,7 @@ Configuring the minimum TLS version to connect to is done via the `ssl_version`
5959------------------------------------
6060import ssl
6161
62- es = Elasticsearch(
62+ client = Elasticsearch(
6363 ...,
6464 ssl_version=ssl.TLSVersion.TLSv1_2
6565)
@@ -72,7 +72,7 @@ Elasticsearch can be configured to authenticate clients via TLS client certifica
7272
7373[source,python]
7474------------------------------------
75- es = Elasticsearch(
75+ client = Elasticsearch(
7676 ...,
7777 client_cert="/path/to/cert.pem",
7878 client_key="/path/to/key.pem",
@@ -93,7 +93,7 @@ import ssl
9393ctx = ssl.create_default_context()
9494ctx.load_verify_locations(...)
9595
96- es = Elasticsearch(
96+ client = Elasticsearch(
9797 ...,
9898 ssl_context=ctx
9999)
@@ -110,7 +110,7 @@ the `Accept-Encoding: gzip` HTTP header. By default compression is disabled.
110110
111111[source,python]
112112------------------------------------
113- es = Elasticsearch(
113+ client = Elasticsearch(
114114 ...,
115115 http_compress=True # Enable compression!
116116)
@@ -130,13 +130,13 @@ Setting `request_timeout` to `None` will disable timeouts.
130130
131131[source,python]
132132------------------------------------
133- es = Elasticsearch(
133+ client = Elasticsearch(
134134 ...,
135135 request_timeout=10 # 10 second timeout
136136)
137137
138138# Search request will timeout in 5 seconds
139- es .options(request_timeout=5).search(...)
139+ client .options(request_timeout=5).search(...)
140140------------------------------------
141141
142142[discrete]
@@ -148,7 +148,7 @@ In the example below there are three different configurable timeouts for the `cl
148148
149149[source,python]
150150------------------------------------
151- es .options(
151+ client .options(
152152 # Amount of time to wait for an HTTP response to start.
153153 request_timeout=30
154154).cluster.health(
@@ -170,13 +170,13 @@ The maximum number of retries per request can be configured via the `max_retries
170170
171171[source,python]
172172------------------------------------
173- es = Elasticsearch(
173+ client = Elasticsearch(
174174 ...,
175175 max_retries=5
176176)
177177
178178# For this API request we disable retries with 'max_retries=0'
179- es .options(max_retries=0).index(
179+ client .options(max_retries=0).index(
180180 index="blogs",
181181 document={
182182 "title": "..."
@@ -191,11 +191,11 @@ Connection errors are automatically retried if retries are enabled. Retrying req
191191
192192[source,python]
193193------------------------------------
194- es = Elasticsearch(
194+ client = Elasticsearch(
195195 ...,
196196 retry_on_timeout=True
197197)
198- es .options(retry_on_timeout=False).info()
198+ client .options(retry_on_timeout=False).info()
199199------------------------------------
200200
201201[discrete]
@@ -205,13 +205,13 @@ By default if retries are enabled `retry_on_status` is set to `(429, 502, 503, 5
205205
206206[source,python]
207207------------------------------------
208- es = Elasticsearch(
208+ client = Elasticsearch(
209209 ...,
210210 retry_on_status=()
211211)
212212
213213# Retry this API on '500 Internal Error' statuses
214- es .options(retry_on_status=[500]).index(
214+ client .options(retry_on_status=[500]).index(
215215 index="blogs",
216216 document={
217217 "title": "..."
@@ -228,14 +228,14 @@ A good example where this is useful is setting up or cleaning up resources in a
228228
229229[source,python]
230230------------------------------------
231- es = Elasticsearch(...)
231+ client = Elasticsearch(...)
232232
233233# API request is robust against the index not existing:
234- resp = es .options(ignore_status=404).indices.delete(index="delete-this")
234+ resp = client .options(ignore_status=404).indices.delete(index="delete-this")
235235resp.meta.status # Can be either '2XX' or '404'
236236
237237# API request is robust against the index already existing:
238- resp = es .options(ignore_status=[400]).indices.create(
238+ resp = client .options(ignore_status=[400]).indices.create(
239239 index="create-this",
240240 mapping={
241241 "properties": {"field": {"type": "integer"}}
@@ -322,7 +322,7 @@ You can specify a node selector pattern via the `node_selector_class` parameter.
322322
323323[source,python]
324324------------------------------------
325- es = Elasticsearch(
325+ client = Elasticsearch(
326326 ...,
327327 node_selector_class="round_robin"
328328)
@@ -337,7 +337,7 @@ from elastic_transport import NodeSelector
337337class CustomSelector(NodeSelector):
338338 def select(nodes): ...
339339
340- es = Elasticsearch(
340+ client = Elasticsearch(
341341 ...,
342342 node_selector_class=CustomSelector
343343)
@@ -374,7 +374,7 @@ class JsonSetSerializer(JsonSerializer):
374374 return list(data)
375375 return super().default(data)
376376
377- es = Elasticsearch(
377+ client = Elasticsearch(
378378 ...,
379379 # Serializers are a mapping of 'mimetype' to Serializer class.
380380 serializers={"application/json": JsonSetSerializer()}
@@ -397,7 +397,7 @@ For all of the built-in HTTP node implementations like `urllib3`, `requests`, an
397397------------------------------------
398398from elasticsearch import Elasticsearch
399399
400- es = Elasticsearch(
400+ client = Elasticsearch(
401401 ...,
402402 node_class="requests"
403403)
@@ -413,7 +413,7 @@ from elastic_transport import Urllib3HttpNode
413413class CustomHttpNode(Urllib3HttpNode):
414414 ...
415415
416- es = Elasticsearch(
416+ client = Elasticsearch(
417417 ...
418418 node_class=CustomHttpNode
419419)
@@ -426,7 +426,7 @@ Each node contains its own pool of HTTP connections to allow for concurrent requ
426426
427427[source,python]
428428------------------------------------
429- es = Elasticsearch(
429+ client = Elasticsearch(
430430 ...,
431431 connections_per_node=5
432432)
0 commit comments