Skip to content

Commit f01a2cd

Browse files
setup and update code examples (#2535) (#2549)
* setup and update code examples * adding generate-examples.py changes * removing space generate-examples.py * Fix formatting --------- Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co> (cherry picked from commit f32878e) Co-authored-by: Annie Hansen <annie.gale@elastic.co>
1 parent dbfa30d commit f01a2cd

File tree

36 files changed

+376
-0
lines changed

36 files changed

+376
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// modules/cluster/remote-clusters-migration.asciidoc:132
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={
7+
"persistent": {
8+
"cluster": {
9+
"remote": {
10+
"my_remote": {
11+
"mode": "proxy",
12+
"proxy_address": "my.remote.cluster.com:9443",
13+
}
14+
}
15+
}
16+
}
17+
},
18+
)
19+
print(resp)
20+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// modules/discovery/voting.asciidoc:26
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.state(
6+
filter_path="metadata.cluster_coordination.last_committed_config",
7+
)
8+
print(resp)
9+
----
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// setup/run-elasticsearch-locally.asciidoc:135
2+
3+
[source, python]
4+
----
5+
resp = client.bulk(
6+
index="customer",
7+
body=[
8+
{"create": {}},
9+
{"firstname": "Monica", "lastname": "Rambeau"},
10+
{"create": {}},
11+
{"firstname": "Carol", "lastname": "Danvers"},
12+
{"create": {}},
13+
{"firstname": "Wanda", "lastname": "Maximoff"},
14+
{"create": {}},
15+
{"firstname": "Jennifer", "lastname": "Takeda"},
16+
],
17+
)
18+
print(resp)
19+
----
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// setup/restart-cluster.asciidoc:35
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={
7+
"persistent": {"cluster.routing.allocation.enable": "primaries"}
8+
},
9+
)
10+
print(resp)
11+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/restart-cluster.asciidoc:147
2+
3+
[source, python]
4+
----
5+
resp = client.cat.health()
6+
print(resp)
7+
8+
resp = client.cat.recovery()
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// modules/indices/request_cache.asciidoc:139
2+
3+
[source, python]
4+
----
5+
resp = client.indices.stats(
6+
metric="request_cache",
7+
human=True,
8+
)
9+
print(resp)
10+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/restart-cluster.asciidoc:162
2+
3+
[source, python]
4+
----
5+
resp = client.ml.set_upgrade_mode(
6+
enabled="false",
7+
)
8+
print(resp)
9+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/run-elasticsearch-locally.asciidoc:125
2+
3+
[source, python]
4+
----
5+
resp = client.get(
6+
index="customer",
7+
id="1",
8+
)
9+
print(resp)
10+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// modules/cluster/misc.asciidoc:133
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={
7+
"persistent": {
8+
"cluster.metadata.administrator": "sysadmin@example.com"
9+
}
10+
},
11+
)
12+
print(resp)
13+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// modules/indices/request_cache.asciidoc:59
2+
3+
[source, python]
4+
----
5+
resp = client.indices.create(
6+
index="my-index-000001",
7+
body={"settings": {"index.requests.cache.enable": False}},
8+
)
9+
print(resp)
10+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/restart-cluster.asciidoc:233
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={"persistent": {"cluster.routing.allocation.enable": None}},
7+
)
8+
print(resp)
9+
----
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// setup/add-nodes.asciidoc:109
2+
3+
[source, python]
4+
----
5+
6+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// modules/cluster/misc.asciidoc:179
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={
7+
"persistent": {
8+
"logger.org.elasticsearch.indices.recovery": "DEBUG"
9+
}
10+
},
11+
)
12+
print(resp)
13+
----
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// modules/indices/request_cache.asciidoc:86
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="my-index-000001",
7+
request_cache="true",
8+
body={
9+
"size": 0,
10+
"aggs": {"popular_colors": {"terms": {"field": "colors"}}},
11+
},
12+
)
13+
print(resp)
14+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// upgrade/archived-settings.asciidoc:32
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={"persistent": {"archived.*": None}},
7+
)
8+
print(resp)
9+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// upgrade/archived-settings.asciidoc:73
2+
3+
[source, python]
4+
----
5+
resp = client.indices.put_settings(
6+
index="my-index",
7+
body={"archived.*": None},
8+
)
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/run-elasticsearch-locally.asciidoc:156
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="customer",
7+
body={"query": {"match": {"firstname": "Jennifer"}}},
8+
)
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/advanced-configuration.asciidoc:124
2+
3+
[source, python]
4+
----
5+
resp = client.nodes.info(
6+
node_id="_all",
7+
metric="jvm",
8+
)
9+
print(resp)
10+
----
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// setup/restart-cluster.asciidoc:219
2+
3+
[source, python]
4+
----
5+
resp = client.cat.nodes()
6+
print(resp)
7+
----
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// setup/run-elasticsearch-locally.asciidoc:109
2+
3+
[source, python]
4+
----
5+
resp = client.index(
6+
index="customer",
7+
id="1",
8+
body={"firstname": "Jennifer", "lastname": "Walters"},
9+
)
10+
print(resp)
11+
----
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// modules/indices/request_cache.asciidoc:146
2+
3+
[source, python]
4+
----
5+
resp = client.nodes.stats(
6+
metric="indices",
7+
index_metric="request_cache",
8+
human=True,
9+
)
10+
print(resp)
11+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/add-nodes.asciidoc:152
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.state(
6+
filter_path="metadata.cluster_coordination.voting_config_exclusions",
7+
)
8+
print(resp)
9+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/restart-cluster.asciidoc:54
2+
3+
[source, python]
4+
----
5+
resp = client.ml.set_upgrade_mode(
6+
enabled="true",
7+
)
8+
print(resp)
9+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/secure-settings.asciidoc:35
2+
3+
[source, python]
4+
----
5+
resp = client.nodes.reload_secure_settings(
6+
body={"secure_settings_password": "keystore-password"},
7+
)
8+
print(resp)
9+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// modules/cluster/remote-clusters-migration.asciidoc:96
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.get_settings(
6+
filter_path="persistent.cluster.remote",
7+
)
8+
print(resp)
9+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/restart-cluster.asciidoc:93
2+
3+
[source, python]
4+
----
5+
resp = client.cat.health()
6+
print(resp)
7+
8+
resp = client.cat.nodes()
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// setup/sysconfig/file-descriptors.asciidoc:29
2+
3+
[source, python]
4+
----
5+
resp = client.nodes.stats(
6+
metric="process",
7+
filter_path="**.max_file_descriptors",
8+
)
9+
print(resp)
10+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// modules/indices/request_cache.asciidoc:47
2+
3+
[source, python]
4+
----
5+
resp = client.indices.clear_cache(
6+
index=["my-index-000001", "my-index-000002"],
7+
request="true",
8+
)
9+
print(resp)
10+
----
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// modules/cluster/remote-clusters-migration.asciidoc:165
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.remote_info()
6+
print(resp)
7+
----
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// modules/indices/request_cache.asciidoc:72
2+
3+
[source, python]
4+
----
5+
resp = client.indices.put_settings(
6+
index="my-index-000001",
7+
body={"index.requests.cache.enable": True},
8+
)
9+
print(resp)
10+
----
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// setup/add-nodes.asciidoc:170
2+
3+
[source, python]
4+
----
5+
6+
----
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// setup/sysconfig/swap.asciidoc:77
2+
3+
[source, python]
4+
----
5+
resp = client.nodes.info(
6+
filter_path="**.mlockall",
7+
)
8+
print(resp)
9+
----

0 commit comments

Comments
 (0)