Skip to content

Commit 964a596

Browse files
committed
more fixed examples
1 parent 24fbb8f commit 964a596

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

docs/examples/languageExamples.json

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,23 +1380,27 @@
13801380
"specification/cluster/put_component_template/examples/request/ClusterPutComponentTemplateRequestExample2.yaml": [
13811381
{
13821382
"language": "Python",
1383-
"code": "resp = client.cluster.put_component_template(\n name=\"template_1\",\n template=None,\n settings={\n \"number_of_shards\": 1\n },\n aliases={\n \"alias1\": {},\n \"alias2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n },\n \"{index}-alias\": {}\n },\n)"
1383+
"code": "resp = client.cluster.put_component_template(\n name=\"template_1\",\n template={\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"aliases\": {\n \"alias1\": {},\n \"alias2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n },\n \"{index}-alias\": {}\n }\n },\n)"
13841384
},
13851385
{
13861386
"language": "JavaScript",
1387-
"code": "const response = await client.cluster.putComponentTemplate({\n name: \"template_1\",\n template: null,\n settings: {\n number_of_shards: 1,\n },\n aliases: {\n alias1: {},\n alias2: {\n filter: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n routing: \"shard-1\",\n },\n \"{index}-alias\": {},\n },\n});"
1387+
"code": "const response = await client.cluster.putComponentTemplate({\n name: \"template_1\",\n template: {\n settings: {\n number_of_shards: 1,\n },\n aliases: {\n alias1: {},\n alias2: {\n filter: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n routing: \"shard-1\",\n },\n \"{index}-alias\": {},\n },\n },\n});"
13881388
},
13891389
{
13901390
"language": "Ruby",
1391-
"code": "response = client.cluster.put_component_template(\n name: \"template_1\",\n body: {\n \"template\": nil,\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"aliases\": {\n \"alias1\": {},\n \"alias2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n },\n \"{index}-alias\": {}\n }\n }\n)"
1391+
"code": "response = client.cluster.put_component_template(\n name: \"template_1\",\n body: {\n \"template\": {\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"aliases\": {\n \"alias1\": {},\n \"alias2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n },\n \"{index}-alias\": {}\n }\n }\n }\n)"
13921392
},
13931393
{
13941394
"language": "PHP",
1395-
"code": "$resp = $client->cluster()->putComponentTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"template\" => null,\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"aliases\" => [\n \"alias1\" => new ArrayObject([]),\n \"alias2\" => [\n \"filter\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"routing\" => \"shard-1\",\n ],\n \"{index}-alias\" => new ArrayObject([]),\n ],\n ],\n]);"
1395+
"code": "$resp = $client->cluster()->putComponentTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"template\" => [\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"aliases\" => [\n \"alias1\" => new ArrayObject([]),\n \"alias2\" => [\n \"filter\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"routing\" => \"shard-1\",\n ],\n \"{index}-alias\" => new ArrayObject([]),\n ],\n ],\n ],\n]);"
13961396
},
13971397
{
13981398
"language": "curl",
1399-
"code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"template\":null,\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}' \"$ELASTICSEARCH_URL/_component_template/template_1\""
1399+
"code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"template\":{\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}}' \"$ELASTICSEARCH_URL/_component_template/template_1\""
1400+
},
1401+
{
1402+
"language": "Java",
1403+
"code": "client.cluster().putComponentTemplate(p -> p\n .name(\"template_1\")\n .template(t -> t\n .aliases(Map.of(\"alias1\", Alias.of(a -> a),\"{index}-alias\", Alias.of(a -> a),\"alias2\", Alias.of(a -> a\n .filter(f -> f\n .term(te -> te\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .routing(\"shard-1\")\n )))\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n )\n);\n"
14001404
}
14011405
],
14021406
"specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml": [
@@ -1422,7 +1426,7 @@
14221426
},
14231427
{
14241428
"language": "Java",
1425-
"code": "\n"
1429+
"code": "client.cluster().getSettings(g -> g);\n"
14261430
}
14271431
],
14281432
"specification/cluster/reroute/examples/request/ClusterRerouteRequestExample1.yaml": [
@@ -1445,6 +1449,10 @@
14451449
{
14461450
"language": "curl",
14471451
"code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"commands\":[{\"move\":{\"index\":\"test\",\"shard\":0,\"from_node\":\"node1\",\"to_node\":\"node2\"}},{\"allocate_replica\":{\"index\":\"test\",\"shard\":1,\"node\":\"node3\"}}]}' \"$ELASTICSEARCH_URL/_cluster/reroute?metric=none\""
1452+
},
1453+
{
1454+
"language": "Java",
1455+
"code": "client.cluster().reroute(r -> r\n .commands(List.of(Command.of(c -> c\n .move(m -> m\n .index(\"test\")\n .shard(0)\n .fromNode(\"node1\")\n .toNode(\"node2\")\n )\n ),Command.of(c -> c\n .allocateReplica(a -> a\n .index(\"test\")\n .shard(1)\n .node(\"node3\")\n )\n )))\n .metric(\"none\")\n);\n"
14481456
}
14491457
],
14501458
"specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml": [
@@ -1574,7 +1582,7 @@
15741582
},
15751583
{
15761584
"language": "Java",
1577-
"code": "\n"
1585+
"code": "client.cluster().state(s -> s);\n"
15781586
}
15791587
],
15801588
"specification/cluster/info/examples/request/ClusterInfoExample1.yaml": [
@@ -1652,7 +1660,7 @@
16521660
},
16531661
{
16541662
"language": "Java",
1655-
"code": "\n"
1663+
"code": "client.cluster().stats(s -> s);\n"
16561664
}
16571665
],
16581666
"specification/cluster/get_component_template/examples/request/ClusterGetComponentTemplateExample1.yaml": [
@@ -1753,6 +1761,10 @@
17531761
{
17541762
"language": "curl",
17551763
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?detailed=true&actions=*/delete/byquery\""
1764+
},
1765+
{
1766+
"language": "Java",
1767+
"code": "client.tasks().list(l -> l\n .actions(\"*/delete/byquery\")\n .detailed(true)\n);\n"
17561768
}
17571769
],
17581770
"specification/tasks/list/examples/request/ListTasksRequestExample1.yaml": [
@@ -1775,6 +1787,10 @@
17751787
{
17761788
"language": "curl",
17771789
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?actions=*search&detailed\""
1790+
},
1791+
{
1792+
"language": "Java",
1793+
"code": "client.tasks().list(l -> l\n .actions(\"*search\")\n .detailed(true)\n);\n"
17781794
}
17791795
],
17801796
"specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml": [
@@ -2213,6 +2229,10 @@
22132229
{
22142230
"language": "curl",
22152231
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_all/_settings?expand_wildcards=all&filter_path=*.settings.index.*.slowlog\""
2232+
},
2233+
{
2234+
"language": "Java",
2235+
"code": "client.indices().getSettings(g -> g\n .expandWildcards(\"all\")\n .index(\"_all\")\n);\n"
22162236
}
22172237
],
22182238
"specification/indices/promote_data_stream/examples/request/IndicesPromoteDataStreamExample1.yaml": [
@@ -2339,6 +2359,10 @@
23392359
{
23402360
"language": "curl",
23412361
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_resolve/index/f*,remoteCluster1:bar*?expand_wildcards=all\""
2362+
},
2363+
{
2364+
"language": "Java",
2365+
"code": "client.indices().resolveIndex(r -> r\n .expandWildcards(\"all\")\n .name(List.of(\"f*\",\"remoteCluster1:bar*\"))\n);\n"
23422366
}
23432367
],
23442368
"specification/indices/exists/examples/request/IndicesExistsExample1.yaml": [
@@ -2390,7 +2414,7 @@
23902414
},
23912415
{
23922416
"language": "Java",
2393-
"code": "\n"
2417+
"code": "client.indices().recovery(r -> r);\n"
23942418
}
23952419
],
23962420
"specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample3.yaml": [
@@ -3110,7 +3134,7 @@
31103134
},
31113135
{
31123136
"language": "Java",
3113-
"code": "\n"
3137+
"code": "client.indices().getIndexTemplate(g -> g\n .name(\"*\")\n);\n"
31143138
}
31153139
],
31163140
"specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml": [
@@ -3136,7 +3160,7 @@
31363160
},
31373161
{
31383162
"language": "Java",
3139-
"code": "\n"
3163+
"code": "client.indices().getDataLifecycle(g -> g\n .name(\"{name}\")\n);\n"
31403164
}
31413165
],
31423166
"specification/indices/get_data_stream/examples/request/IndicesGetDataStreamExample1.yaml": [
@@ -3393,6 +3417,10 @@
33933417
{
33943418
"language": "curl",
33953419
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_shard_stores?status=green\""
3420+
},
3421+
{
3422+
"language": "Java",
3423+
"code": "client.indices().shardStores(s -> s\n .status(\"green\")\n);\n"
33963424
}
33973425
],
33983426
"specification/indices/get_data_stream_settings/examples/request/IndicesGetDataStreamSettingsRequestExample1.yaml": [
@@ -3756,7 +3784,7 @@
37563784
},
37573785
{
37583786
"language": "Java",
3759-
"code": "\n"
3787+
"code": "client.indices().stats(s -> s\n .fields(\"my_join_field\")\n .metric(\"fielddata\")\n);\n"
37603788
}
37613789
],
37623790
"specification/indices/segments/examples/request/IndicesSegmentsExample1.yaml": [
@@ -4951,6 +4979,10 @@
49514979
{
49524980
"language": "curl",
49534981
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grid_agg\":\"geotile\",\"grid_precision\":2,\"fields\":[\"name\",\"price\"],\"query\":{\"term\":{\"included\":true}},\"aggs\":{\"min_price\":{\"min\":{\"field\":\"price\"}},\"max_price\":{\"max\":{\"field\":\"price\"}},\"avg_price\":{\"avg\":{\"field\":\"price\"}}}}' \"$ELASTICSEARCH_URL/museums/_mvt/location/13/4207/2692\""
4982+
},
4983+
{
4984+
"language": "Java",
4985+
"code": "client.searchMvt(s -> s\n .aggs(Map.of(\"max_price\", Aggregation.of(a -> a\n .max(m -> m\n .field(\"price\")\n )\n ),\"min_price\", Aggregation.of(ag -> ag\n .min(m -> m\n .field(\"price\")\n )\n ),\"avg_price\", Aggregation.of(agg -> agg\n .avg(av -> av\n .field(\"price\")\n )\n )))\n .field(\"location\")\n .fields(List.of(\"name\",\"price\"))\n .gridAgg(GridAggregationType.Geotile)\n .gridPrecision(2)\n .index(\"museums\")\n .query(q -> q\n .term(t -> t\n .field(\"included\")\n .value(FieldValue.of(true))\n )\n )\n .x(4207)\n .y(2692)\n .zoom(13)\n);\n"
49544986
}
49554987
],
49564988
"specification/_global/delete_by_query_rethrottle/examples/request/DeleteByQueryRethrottleRequestExample1.yaml": [
@@ -4999,6 +5031,10 @@
49995031
{
50005032
"language": "curl",
50015033
"code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/1?stored_fields=tags,counter\""
5034+
},
5035+
{
5036+
"language": "Java",
5037+
"code": "client.get(g -> g\n .id(\"1\")\n .index(\"my-index-000001\")\n .storedFields(List.of(\"tags\",\"counter\"))\n);\n"
50025038
}
50035039
],
50045040
"specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml": [
@@ -5229,6 +5265,10 @@
52295265
{
52305266
"language": "curl",
52315267
"code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_filter\":{\"range\":{\"@timestamp\":{\"gte\":\"2018\"}}}}' \"$ELASTICSEARCH_URL/my-index-*/_field_caps?fields=rating\""
5268+
},
5269+
{
5270+
"language": "Java",
5271+
"code": "client.fieldCaps(f -> f\n .fields(\"rating\")\n .index(\"my-index-*\")\n .indexFilter(i -> i\n .range(r -> r\n .untyped(u -> u\n .field(\"@timestamp\")\n .gte(JsonData.fromJson(\"\\\"2018\\\"\"))\n )\n )\n )\n);\n"
52325272
}
52335273
],
52345274
"specification/_global/search/examples/request/SearchRequestExample1.yaml": [
@@ -9458,7 +9498,7 @@
94589498
},
94599499
{
94609500
"language": "Java",
9461-
"code": "\n"
9501+
"code": "client.nodes().stats(s -> s\n .metric(\"process\")\n);\n"
94629502
}
94639503
],
94649504
"specification/ingest/get_pipeline/examples/request/IngestGetPipelineExample1.yaml": [
@@ -9952,7 +9992,7 @@
99529992
},
99539993
{
99549994
"language": "Java",
9955-
"code": "\n"
9995+
"code": "client.slm().getLifecycle(g -> g\n .policyId(\"daily-snapshots\")\n);\n"
99569996
}
99579997
],
99589998
"specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml": [
@@ -10296,23 +10336,23 @@
1029610336
"specification/synonyms/put_synonym/examples/request/SynonymsPutRequestExample1.yaml": [
1029710337
{
1029810338
"language": "Python",
10299-
"code": "resp = client.synonyms.put_synonym(\n id=\"my-synonyms-set\",\n)"
10339+
"code": "resp = client.synonyms.put_synonym(\n id=\"my-synonyms-set\",\n synonyms_set=\"hello, hi, howdy\",\n)"
1030010340
},
1030110341
{
1030210342
"language": "JavaScript",
10303-
"code": "const response = await client.synonyms.putSynonym({\n id: \"my-synonyms-set\",\n});"
10343+
"code": "const response = await client.synonyms.putSynonym({\n id: \"my-synonyms-set\",\n synonyms_set: \"hello, hi, howdy\",\n});"
1030410344
},
1030510345
{
1030610346
"language": "Ruby",
10307-
"code": "response = client.synonyms.put_synonym(\n id: \"my-synonyms-set\"\n)"
10347+
"code": "response = client.synonyms.put_synonym(\n id: \"my-synonyms-set\",\n body: {\n \"synonyms_set\": \"hello, hi, howdy\"\n }\n)"
1030810348
},
1030910349
{
1031010350
"language": "PHP",
10311-
"code": "$resp = $client->synonyms()->putSynonym([\n \"id\" => \"my-synonyms-set\",\n]);"
10351+
"code": "$resp = $client->synonyms()->putSynonym([\n \"id\" => \"my-synonyms-set\",\n \"body\" => [\n \"synonyms_set\" => \"hello, hi, howdy\",\n ],\n]);"
1031210352
},
1031310353
{
1031410354
"language": "curl",
10315-
"code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\""
10355+
"code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"synonyms_set\":\"hello, hi, howdy\"}' \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\""
1031610356
}
1031710357
],
1031810358
"specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml": [
@@ -10702,7 +10742,7 @@
1070210742
},
1070310743
{
1070410744
"language": "Java",
10705-
"code": "\n"
10745+
"code": "client.ml().putDatafeed(p -> p\n .datafeedId(\"datafeed-test-job\")\n .indices(\"kibana_sample_data_logs\")\n .jobId(\"test-job\")\n .query(q -> q\n .bool(b -> b\n .must(m -> m\n .matchAll(ma -> ma)\n )\n )\n )\n);\n"
1070610746
}
1070710747
],
1070810748
"specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml": [
@@ -11690,7 +11730,7 @@
1169011730
},
1169111731
{
1169211732
"language": "Java",
11693-
"code": "\n"
11733+
"code": "client.ml().getMemoryStats(g -> g);\n"
1169411734
}
1169511735
],
1169611736
"specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml": [
@@ -12077,6 +12117,10 @@
1207712117
{
1207812118
"language": "curl",
1207912119
"code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"definition\":\"...\",\"total_definition_length\":265632637,\"total_parts\":64}' \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/definition/0\""
12120+
},
12121+
{
12122+
"language": "Java",
12123+
"code": "client.ml().putTrainedModelDefinitionPart(p -> p\n .definition(\"...\")\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .part(0)\n .totalDefinitionLength(265632637L)\n .totalParts(64)\n);\n"
1208012124
}
1208112125
],
1208212126
"specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml": [
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
method_request: PUT _synonyms/my-synonyms-set
2+
description: ''
3+
type: request
4+
value: "{
5+
6+
\ \"synonyms_set\": \"hello, hi, howdy\"
7+
8+
}"

0 commit comments

Comments
 (0)