From bdaa7c4ee61c7076891f2fec05b5120afa315342 Mon Sep 17 00:00:00 2001 From: Liam Thompson Date: Tue, 19 Aug 2025 09:18:15 +0200 Subject: [PATCH 1/3] [DOCS] Remove instances of added in 0.0.0 + unrelated randomness (#5147) (cherry picked from commit 4401b0b5538f0884407a80d24fa76bbb7364fb86) --- docs/examples/languageExamples.json | 17226 ++++++++++++++++ output/openapi/elasticsearch-openapi.json | 40 +- output/schema/schema.json | 7 - .../snapshot/create/SnapshotCreateRequest.ts | 2 +- .../SnapshotCreateRepositoryRequest.ts | 2 +- .../SnapshotDeleteRepositoryRequest.ts | 2 +- .../snapshot/get/SnapshotGetRequest.ts | 2 +- .../SnapshotGetRepositoryRequest.ts | 2 +- .../restore/SnapshotRestoreRequest.ts | 2 +- .../SnapshotVerifyRepositoryRequest.ts | 2 +- 10 files changed, 17253 insertions(+), 34 deletions(-) create mode 100644 docs/examples/languageExamples.json diff --git a/docs/examples/languageExamples.json b/docs/examples/languageExamples.json new file mode 100644 index 0000000000..52cdfb6409 --- /dev/null +++ b/docs/examples/languageExamples.json @@ -0,0 +1,17226 @@ +{ + "specification/xpack/usage/examples/request/XPackUsageRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.xpack.usage()" + }, + { + "language": "JavaScript", + "code": "const response = await client.xpack.usage();" + }, + { + "language": "Ruby", + "code": "response = client.xpack.usage" + }, + { + "language": "PHP", + "code": "$resp = $client->xpack()->usage();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_xpack/usage\"" + }, + { + "language": "Java", + "code": "client.xpack().usage(u -> u);\n" + } + ], + "specification/xpack/info/examples/request/XPackInfoRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.xpack.info()" + }, + { + "language": "JavaScript", + "code": "const response = await client.xpack.info();" + }, + { + "language": "Ruby", + "code": "response = client.xpack.info" + }, + { + "language": "PHP", + "code": "$resp = $client->xpack()->info();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_xpack\"" + }, + { + "language": "Java", + "code": "client.xpack().info(i -> i);\n" + } + ], + "specification/cat/shards/examples/request/CatShardsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.shards(\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.shards({\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.shards(\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->shards([\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/shards?format=json\"" + }, + { + "language": "Java", + "code": "client.cat().shards();\n" + } + ], + "specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.component_templates(\n name=\"my-template-*\",\n v=True,\n s=\"name\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.componentTemplates({\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.component_templates(\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->componentTemplates([\n \"name\" => \"my-template-*\",\n \"v\" => \"true\",\n \"s\" => \"name\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/component_templates/my-template-*?v=true&s=name&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().componentTemplates();\n" + } + ], + "specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.tasks(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.tasks({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.tasks(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->tasks([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/tasks?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().tasks();\n" + } + ], + "specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.indices(\n index=\"my-index-*\",\n v=True,\n s=\"index\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.indices({\n index: \"my-index-*\",\n v: \"true\",\n s: \"index\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.indices(\n index: \"my-index-*\",\n v: \"true\",\n s: \"index\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->indices([\n \"index\" => \"my-index-*\",\n \"v\" => \"true\",\n \"s\" => \"index\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/indices/my-index-*?v=true&s=index&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().indices();\n" + } + ], + "specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.thread_pool(\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.threadPool({\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.thread_pool(\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->threadPool([\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/thread_pool?format=json\"" + }, + { + "language": "Java", + "code": "client.cat().threadPool();\n" + } + ], + "specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.pending_tasks(\n v=\"trueh=insertOrder,timeInQueue,priority,source\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.pendingTasks({\n v: \"trueh=insertOrder,timeInQueue,priority,source\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.pending_tasks(\n v: \"trueh=insertOrder,timeInQueue,priority,source\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->pendingTasks([\n \"v\" => \"trueh=insertOrder,timeInQueue,priority,source\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/pending_tasks?v=trueh=insertOrder,timeInQueue,priority,source&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().pendingTasks();\n" + } + ], + "specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.nodeattrs(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.nodeattrs({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.nodeattrs(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->nodeattrs([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/nodeattrs?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().nodeattrs();\n" + } + ], + "specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.snapshots(\n repository=\"repo1\",\n v=True,\n s=\"id\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.snapshots({\n repository: \"repo1\",\n v: \"true\",\n s: \"id\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.snapshots(\n repository: \"repo1\",\n v: \"true\",\n s: \"id\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->snapshots([\n \"repository\" => \"repo1\",\n \"v\" => \"true\",\n \"s\" => \"id\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/snapshots/repo1?v=true&s=id&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().snapshots();\n" + } + ], + "specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.nodes(\n v=True,\n h=\"id,ip,port,v,m\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.nodes({\n v: \"true\",\n h: \"id,ip,port,v,m\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.nodes(\n v: \"true\",\n h: \"id,ip,port,v,m\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->nodes([\n \"v\" => \"true\",\n \"h\" => \"id,ip,port,v,m\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/nodes?v=true&h=id,ip,port,v,m&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().nodes();\n" + } + ], + "specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.ml_datafeeds(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.mlDatafeeds({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.ml_datafeeds(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->mlDatafeeds([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/datafeeds?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().mlDatafeeds();\n" + } + ], + "specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.plugins(\n v=True,\n s=\"component\",\n h=\"name,component,version,description\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.plugins({\n v: \"true\",\n s: \"component\",\n h: \"name,component,version,description\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.plugins(\n v: \"true\",\n s: \"component\",\n h: \"name,component,version,description\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->plugins([\n \"v\" => \"true\",\n \"s\" => \"component\",\n \"h\" => \"name,component,version,description\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/plugins?v=true&s=component&h=name,component,version,description&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().plugins();\n" + } + ], + "specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.recovery(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.recovery({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.recovery(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->recovery([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/recovery?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().recovery();\n" + } + ], + "specification/cat/health/examples/request/CatHealthRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.health(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.health({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.health(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->health([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/health?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().health();\n" + } + ], + "specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.ml_jobs(\n h=\"id,s,dpr,mb\",\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.mlJobs({\n h: \"id,s,dpr,mb\",\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.ml_jobs(\n h: \"id,s,dpr,mb\",\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->mlJobs([\n \"h\" => \"id,s,dpr,mb\",\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/anomaly_detectors?h=id,s,dpr,mb&v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().mlJobs();\n" + } + ], + "specification/cat/count/examples/request/CatCountRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.count(\n index=\"my-index-000001\",\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.count({\n index: \"my-index-000001\",\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.count(\n index: \"my-index-000001\",\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->count([\n \"index\" => \"my-index-000001\",\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/count/my-index-000001?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().count();\n" + } + ], + "specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.repositories(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.repositories({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.repositories(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->repositories([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/repositories?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().repositories();\n" + } + ], + "specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.ml_data_frame_analytics(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.mlDataFrameAnalytics({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.ml_data_frame_analytics(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->mlDataFrameAnalytics([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/data_frame/analytics?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().mlDataFrameAnalytics();\n" + } + ], + "specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.transforms(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.transforms({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.transforms(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->transforms([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/transforms?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().transforms();\n" + } + ], + "specification/cat/master/examples/request/CatMasterRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.master(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.master({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.master(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->master([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/master?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().master();\n" + } + ], + "specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.templates(\n name=\"my-template-*\",\n v=True,\n s=\"name\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.templates({\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.templates(\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->templates([\n \"name\" => \"my-template-*\",\n \"v\" => \"true\",\n \"s\" => \"name\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/templates/my-template-*?v=true&s=name&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().templates();\n" + } + ], + "specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.ml_trained_models(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.mlTrainedModels({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.ml_trained_models(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->mlTrainedModels([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/trained_models?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().mlTrainedModels();\n" + } + ], + "specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.aliases(\n format=\"json\",\n v=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.aliases({\n format: \"json\",\n v: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.aliases(\n format: \"json\",\n v: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->aliases([\n \"format\" => \"json\",\n \"v\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/aliases?format=json&v=true\"" + }, + { + "language": "Java", + "code": "client.cat().aliases();\n" + } + ], + "specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.fielddata(\n v=True,\n fields=\"body\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.fielddata({\n v: \"true\",\n fields: \"body\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.fielddata(\n v: \"true\",\n fields: \"body\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->fielddata([\n \"v\" => \"true\",\n \"fields\" => \"body\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/fielddata?v=true&fields=body&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().fielddata();\n" + } + ], + "specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.segments(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.segments({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.segments(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->segments([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/segments?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().segments();\n" + } + ], + "specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cat.allocation(\n v=True,\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cat.allocation({\n v: \"true\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cat.allocation(\n v: \"true\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cat()->allocation([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/allocation?v=true&format=json\"" + }, + { + "language": "Java", + "code": "client.cat().allocation();\n" + } + ], + "specification/searchable_snapshots/cache_stats/examples/request/CacheStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.searchable_snapshots.cache_stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchableSnapshots.cacheStats();" + }, + { + "language": "Ruby", + "code": "response = client.searchable_snapshots.cache_stats" + }, + { + "language": "PHP", + "code": "$resp = $client->searchableSnapshots()->cacheStats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_searchable_snapshots/cache/stats\"" + }, + { + "language": "Java", + "code": "client.searchableSnapshots().cacheStats(c -> c);\n" + } + ], + "specification/searchable_snapshots/clear_cache/examples/request/SearchableSnapshotsClearCacheExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.searchable_snapshots.clear_cache(\n index=\"my-index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchableSnapshots.clearCache({\n index: \"my-index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.searchable_snapshots.clear_cache(\n index: \"my-index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchableSnapshots()->clearCache([\n \"index\" => \"my-index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index/_searchable_snapshots/cache/clear\"" + }, + { + "language": "Java", + "code": "client.searchableSnapshots().clearCache(c -> c\n .index(\"my-index\")\n);\n" + } + ], + "specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.searchable_snapshots.mount(\n repository=\"my_repository\",\n snapshot=\"my_snapshot\",\n wait_for_completion=True,\n index=\"my_docs\",\n renamed_index=\"docs\",\n index_settings={\n \"index.number_of_replicas\": 0\n },\n ignore_index_settings=[\n \"index.refresh_interval\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchableSnapshots.mount({\n repository: \"my_repository\",\n snapshot: \"my_snapshot\",\n wait_for_completion: \"true\",\n index: \"my_docs\",\n renamed_index: \"docs\",\n index_settings: {\n \"index.number_of_replicas\": 0,\n },\n ignore_index_settings: [\"index.refresh_interval\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.searchable_snapshots.mount(\n repository: \"my_repository\",\n snapshot: \"my_snapshot\",\n wait_for_completion: \"true\",\n body: {\n \"index\": \"my_docs\",\n \"renamed_index\": \"docs\",\n \"index_settings\": {\n \"index.number_of_replicas\": 0\n },\n \"ignore_index_settings\": [\n \"index.refresh_interval\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchableSnapshots()->mount([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"my_snapshot\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"index\" => \"my_docs\",\n \"renamed_index\" => \"docs\",\n \"index_settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"ignore_index_settings\" => array(\n \"index.refresh_interval\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_docs\",\"renamed_index\":\"docs\",\"index_settings\":{\"index.number_of_replicas\":0},\"ignore_index_settings\":[\"index.refresh_interval\"]}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/my_snapshot/_mount?wait_for_completion=true\"" + }, + { + "language": "Java", + "code": "client.searchableSnapshots().mount(m -> m\n .ignoreIndexSettings(\"index.refresh_interval\")\n .index(\"my_docs\")\n .indexSettings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n .renamedIndex(\"docs\")\n .repository(\"my_repository\")\n .snapshot(\"my_snapshot\")\n .waitForCompletion(true)\n);\n" + } + ], + "specification/searchable_snapshots/stats/examples/request/SearchableSnapshotsStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.searchable_snapshots.stats(\n index=\"my-index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchableSnapshots.stats({\n index: \"my-index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.searchable_snapshots.stats(\n index: \"my-index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchableSnapshots()->stats([\n \"index\" => \"my-index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index/_searchable_snapshots/stats\"" + }, + { + "language": "Java", + "code": "client.searchableSnapshots().stats(s -> s\n .index(\"my-index\")\n);\n" + } + ], + "specification/snapshot/delete_repository/examples/request/SnapshotDeleteRepositoryExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.delete_repository(\n name=\"my_repository\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.deleteRepository({\n name: \"my_repository\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.delete_repository(\n repository: \"my_repository\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->deleteRepository([\n \"repository\" => \"my_repository\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().deleteRepository(d -> d\n .name(\"my_repository\")\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_s3_repository\",\n repository={\n \"type\": \"s3\",\n \"settings\": {\n \"bucket\": \"my-bucket\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_s3_repository\",\n repository: {\n type: \"s3\",\n settings: {\n bucket: \"my-bucket\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_s3_repository\",\n body: {\n \"type\": \"s3\",\n \"settings\": {\n \"bucket\": \"my-bucket\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_s3_repository\",\n \"body\" => [\n \"type\" => \"s3\",\n \"settings\" => [\n \"bucket\" => \"my-bucket\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"s3\",\"settings\":{\"bucket\":\"my-bucket\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_s3_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_s3_repository\")\n .repository(r -> r\n .s3(s -> s\n .settings(se -> se\n .bucket(\"my-bucket\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_src_only_repository\",\n repository={\n \"type\": \"source\",\n \"settings\": {\n \"delegate_type\": \"fs\",\n \"location\": \"my_backup_repository\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_src_only_repository\",\n repository: {\n type: \"source\",\n settings: {\n delegate_type: \"fs\",\n location: \"my_backup_repository\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_src_only_repository\",\n body: {\n \"type\": \"source\",\n \"settings\": {\n \"delegate_type\": \"fs\",\n \"location\": \"my_backup_repository\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_src_only_repository\",\n \"body\" => [\n \"type\" => \"source\",\n \"settings\" => [\n \"delegate_type\" => \"fs\",\n \"location\" => \"my_backup_repository\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"source\",\"settings\":{\"delegate_type\":\"fs\",\"location\":\"my_backup_repository\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_src_only_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_src_only_repository\")\n .repository(r -> r\n .source(s -> s\n .settings(se -> se\n .delegateType(\"fs\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_backup\",\n repository={\n \"type\": \"azure\",\n \"settings\": {\n \"client\": \"secondary\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_backup\",\n repository: {\n type: \"azure\",\n settings: {\n client: \"secondary\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_backup\",\n body: {\n \"type\": \"azure\",\n \"settings\": {\n \"client\": \"secondary\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_backup\",\n \"body\" => [\n \"type\" => \"azure\",\n \"settings\" => [\n \"client\" => \"secondary\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"azure\",\"settings\":{\"client\":\"secondary\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_backup\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_backup\")\n .repository(r -> r\n .azure(a -> a\n .settings(s -> s\n .client(\"secondary\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_gcs_repository\",\n repository={\n \"type\": \"gcs\",\n \"settings\": {\n \"bucket\": \"my_other_bucket\",\n \"base_path\": \"dev\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_gcs_repository\",\n repository: {\n type: \"gcs\",\n settings: {\n bucket: \"my_other_bucket\",\n base_path: \"dev\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_gcs_repository\",\n body: {\n \"type\": \"gcs\",\n \"settings\": {\n \"bucket\": \"my_other_bucket\",\n \"base_path\": \"dev\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_gcs_repository\",\n \"body\" => [\n \"type\" => \"gcs\",\n \"settings\" => [\n \"bucket\" => \"my_other_bucket\",\n \"base_path\" => \"dev\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"gcs\",\"settings\":{\"bucket\":\"my_other_bucket\",\"base_path\":\"dev\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_gcs_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_gcs_repository\")\n .repository(r -> r\n .gcs(g -> g\n .settings(s -> s\n .bucket(\"my_other_bucket\")\n .basePath(\"dev\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_repository\",\n repository={\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_repository\",\n repository: {\n type: \"fs\",\n settings: {\n location: \"my_backup_location\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_repository\",\n body: {\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_repository\",\n \"body\" => [\n \"type\" => \"fs\",\n \"settings\" => [\n \"location\" => \"my_backup_location\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"fs\",\"settings\":{\"location\":\"my_backup_location\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_repository\")\n .repository(r -> r\n .fs(f -> f\n .settings(s -> s\n .location(\"my_backup_location\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create_repository(\n name=\"my_read_only_url_repository\",\n repository={\n \"type\": \"url\",\n \"settings\": {\n \"url\": \"file:/mount/backups/my_fs_backup_location\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.createRepository({\n name: \"my_read_only_url_repository\",\n repository: {\n type: \"url\",\n settings: {\n url: \"file:/mount/backups/my_fs_backup_location\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create_repository(\n repository: \"my_read_only_url_repository\",\n body: {\n \"type\": \"url\",\n \"settings\": {\n \"url\": \"file:/mount/backups/my_fs_backup_location\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_read_only_url_repository\",\n \"body\" => [\n \"type\" => \"url\",\n \"settings\" => [\n \"url\" => \"file:/mount/backups/my_fs_backup_location\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"url\",\"settings\":{\"url\":\"file:/mount/backups/my_fs_backup_location\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_read_only_url_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().createRepository(c -> c\n .name(\"my_read_only_url_repository\")\n .repository(r -> r\n .url(u -> u\n .settings(s -> s\n .url(\"file:/mount/backups/my_fs_backup_location\")\n )\n )\n )\n);\n" + } + ], + "specification/snapshot/delete/examples/request/SnapshotDeleteRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.delete(\n repository=\"my_repository\",\n snapshot=\"snapshot_2,snapshot_3\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.delete({\n repository: \"my_repository\",\n snapshot: \"snapshot_2,snapshot_3\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.delete(\n repository: \"my_repository\",\n snapshot: \"snapshot_2,snapshot_3\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->delete([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2,snapshot_3\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2,snapshot_3\"" + }, + { + "language": "Java", + "code": "client.snapshot().delete(d -> d\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2,snapshot_3\")\n);\n" + } + ], + "specification/snapshot/verify_repository/examples/request/SnapshotVerifyRepositoryExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.verify_repository(\n name=\"my_unverified_backup\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.verifyRepository({\n name: \"my_unverified_backup\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.verify_repository(\n repository: \"my_unverified_backup\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->verifyRepository([\n \"repository\" => \"my_unverified_backup\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_unverified_backup/_verify\"" + }, + { + "language": "Java", + "code": "client.snapshot().verifyRepository(v -> v\n .name(\"my_unverified_backup\")\n);\n" + } + ], + "specification/snapshot/get/examples/request/SnapshotGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.get(\n repository=\"my_repository\",\n snapshot=\"snapshot_*\",\n sort=\"start_time\",\n from_sort_value=\"1577833200000\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.get({\n repository: \"my_repository\",\n snapshot: \"snapshot_*\",\n sort: \"start_time\",\n from_sort_value: 1577833200000,\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.get(\n repository: \"my_repository\",\n snapshot: \"snapshot_*\",\n sort: \"start_time\",\n from_sort_value: \"1577833200000\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->get([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_*\",\n \"sort\" => \"start_time\",\n \"from_sort_value\" => \"1577833200000\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_*?sort=start_time&from_sort_value=1577833200000\"" + }, + { + "language": "Java", + "code": "client.snapshot().get(g -> g\n .fromSortValue(\"1577833200000\")\n .repository(\"my_repository\")\n .snapshot(\"snapshot_*\")\n .sort(SnapshotSort.StartTime)\n);\n" + } + ], + "specification/snapshot/repository_analyze/examples/request/SnapshotRepositoryAnalyzeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.repository_analyze(\n name=\"my_repository\",\n blob_count=\"10\",\n max_blob_size=\"1mb\",\n timeout=\"120s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.repositoryAnalyze({\n name: \"my_repository\",\n blob_count: 10,\n max_blob_size: \"1mb\",\n timeout: \"120s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.repository_analyze(\n repository: \"my_repository\",\n blob_count: \"10\",\n max_blob_size: \"1mb\",\n timeout: \"120s\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->repositoryAnalyze([\n \"repository\" => \"my_repository\",\n \"blob_count\" => \"10\",\n \"max_blob_size\" => \"1mb\",\n \"timeout\" => \"120s\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_analyze?blob_count=10&max_blob_size=1mb&timeout=120s\"" + }, + { + "language": "Java", + "code": "client.snapshot().repositoryAnalyze(r -> r\n .blobCount(10)\n .maxBlobSize(\"1mb\")\n .name(\"my_repository\")\n .timeout(t -> t\n .offset(120)\n )\n);\n" + } + ], + "specification/snapshot/status/examples/request/SnapshotStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.status(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.status({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.status(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->status([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_status\"" + }, + { + "language": "Java", + "code": "client.snapshot().status(s -> s\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n);\n" + } + ], + "specification/snapshot/cleanup_repository/examples/request/SnapshotCleanupRepositoryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.cleanup_repository(\n name=\"my_repository\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.cleanupRepository({\n name: \"my_repository\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.cleanup_repository(\n repository: \"my_repository\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->cleanupRepository([\n \"repository\" => \"my_repository\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_cleanup\"" + }, + { + "language": "Java", + "code": "client.snapshot().cleanupRepository(c -> c\n .name(\"my_repository\")\n);\n" + } + ], + "specification/snapshot/repository_verify_integrity/examples/request/SnapshotRepositoryVerifyIntegrityExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.repository_verify_integrity(\n name=\"my_repository\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.repositoryVerifyIntegrity({\n name: \"my_repository\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.repository_verify_integrity(\n repository: \"my_repository\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->repositoryVerifyIntegrity([\n \"repository\" => \"my_repository\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_verify_integrity\"" + }, + { + "language": "Java", + "code": "client.snapshot().repositoryVerifyIntegrity(r -> r\n .name(\"my_repository\")\n);\n" + } + ], + "specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.clone(\n repository=\"my_repository\",\n snapshot=\"source_snapshot\",\n target_snapshot=\"target_snapshot\",\n indices=\"index_a,index_b\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.clone({\n repository: \"my_repository\",\n snapshot: \"source_snapshot\",\n target_snapshot: \"target_snapshot\",\n indices: \"index_a,index_b\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.clone(\n repository: \"my_repository\",\n snapshot: \"source_snapshot\",\n target_snapshot: \"target_snapshot\",\n body: {\n \"indices\": \"index_a,index_b\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->clone([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"source_snapshot\",\n \"target_snapshot\" => \"target_snapshot\",\n \"body\" => [\n \"indices\" => \"index_a,index_b\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_a,index_b\"}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/source_snapshot/_clone/target_snapshot\"" + }, + { + "language": "Java", + "code": "client.snapshot().clone(c -> c\n .indices(\"index_a,index_b\")\n .repository(\"my_repository\")\n .snapshot(\"source_snapshot\")\n .targetSnapshot(\"target_snapshot\")\n);\n" + } + ], + "specification/snapshot/get_repository/examples/request/SnapshotGetRepositoryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.get_repository(\n name=\"my_repository\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.getRepository({\n name: \"my_repository\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.get_repository(\n repository: \"my_repository\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->getRepository([\n \"repository\" => \"my_repository\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" + }, + { + "language": "Java", + "code": "client.snapshot().getRepository(g -> g\n .name(\"my_repository\")\n);\n" + } + ], + "specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.create(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n wait_for_completion=True,\n indices=\"index_1,index_2\",\n ignore_unavailable=True,\n include_global_state=False,\n metadata={\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.create({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n indices: \"index_1,index_2\",\n ignore_unavailable: true,\n include_global_state: false,\n metadata: {\n taken_by: \"user123\",\n taken_because: \"backup before upgrading\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.create(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n body: {\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->create([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"indices\" => \"index_1,index_2\",\n \"ignore_unavailable\" => true,\n \"include_global_state\" => false,\n \"metadata\" => [\n \"taken_by\" => \"user123\",\n \"taken_because\" => \"backup before upgrading\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"metadata\":{\"taken_by\":\"user123\",\"taken_because\":\"backup before upgrading\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2?wait_for_completion=true\"" + }, + { + "language": "Java", + "code": "client.snapshot().create(c -> c\n .ignoreUnavailable(true)\n .includeGlobalState(false)\n .indices(\"index_1,index_2\")\n .metadata(Map.of(\"taken_by\", JsonData.fromJson(\"\\\"user123\\\"\"),\"taken_because\", JsonData.fromJson(\"\\\"backup before upgrading\\\"\")))\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n .waitForCompletion(true)\n);\n" + } + ], + "specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.put_settings(\n indices=\"index_1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.putSettings({\n indices: \"index_1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.put_settings(\n body: {\n \"indices\": \"index_1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"indices\" => \"index_1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1\"}' \"$ELASTICSEARCH_URL/_cluster/settings\"" + }, + { + "language": "Java", + "code": "client.cluster().putSettings();\n" + } + ], + "specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.snapshot.restore(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n wait_for_completion=True,\n indices=\"index_1,index_2\",\n ignore_unavailable=True,\n include_global_state=False,\n rename_pattern=\"index_(.+)\",\n rename_replacement=\"restored_index_$1\",\n include_aliases=False,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.snapshot.restore({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n indices: \"index_1,index_2\",\n ignore_unavailable: true,\n include_global_state: false,\n rename_pattern: \"index_(.+)\",\n rename_replacement: \"restored_index_$1\",\n include_aliases: false,\n});" + }, + { + "language": "Ruby", + "code": "response = client.snapshot.restore(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n body: {\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"rename_pattern\": \"index_(.+)\",\n \"rename_replacement\": \"restored_index_$1\",\n \"include_aliases\": false\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->snapshot()->restore([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"indices\" => \"index_1,index_2\",\n \"ignore_unavailable\" => true,\n \"include_global_state\" => false,\n \"rename_pattern\" => \"index_(.+)\",\n \"rename_replacement\" => \"restored_index_$1\",\n \"include_aliases\" => false,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"rename_pattern\":\"index_(.+)\",\"rename_replacement\":\"restored_index_$1\",\"include_aliases\":false}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true\"" + }, + { + "language": "Java", + "code": "client.snapshot().restore(r -> r\n .ignoreUnavailable(true)\n .includeAliases(false)\n .includeGlobalState(false)\n .indices(\"index_1,index_2\")\n .renamePattern(\"index_(.+)\")\n .renameReplacement(\"restored_index_$1\")\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n .waitForCompletion(true)\n);\n" + } + ], + "specification/cluster/delete_component_template/examples/request/ClusterDeleteComponentTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.delete_component_template(\n name=\"template_1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.deleteComponentTemplate({\n name: \"template_1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.delete_component_template(\n name: \"template_1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->deleteComponentTemplate([\n \"name\" => \"template_1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_component_template/template_1\"" + }, + { + "language": "Java", + "code": "client.cluster().deleteComponentTemplate(d -> d\n .name(\"template_1\")\n);\n" + } + ], + "specification/cluster/pending_tasks/examples/request/ClusterPendingTasksExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.pending_tasks()" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.pendingTasks();" + }, + { + "language": "Ruby", + "code": "response = client.cluster.pending_tasks" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->pendingTasks();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/pending_tasks\"" + }, + { + "language": "Java", + "code": "client.cluster().pendingTasks(p -> p);\n" + } + ], + "specification/cluster/put_component_template/examples/request/ClusterPutComponentTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.put_component_template(\n name=\"template_1\",\n template=None,\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"_source\": {\n \"enabled\": False\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.putComponentTemplate({\n name: \"template_1\",\n template: null,\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n _source: {\n enabled: false,\n },\n properties: {\n host_name: {\n type: \"keyword\",\n },\n created_at: {\n type: \"date\",\n format: \"EEE MMM dd HH:mm:ss Z yyyy\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "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 \"mappings\": {\n \"_source\": {\n \"enabled\": false\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->putComponentTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"template\" => null,\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"_source\" => [\n \"enabled\" => false,\n ],\n \"properties\" => [\n \"host_name\" => [\n \"type\" => \"keyword\",\n ],\n \"created_at\" => [\n \"type\" => \"date\",\n \"format\" => \"EEE MMM dd HH:mm:ss Z yyyy\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"template\":null,\"settings\":{\"number_of_shards\":1},\"mappings\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"keyword\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\"}}}}' \"$ELASTICSEARCH_URL/_component_template/template_1\"" + } + ], + "specification/cluster/put_component_template/examples/request/ClusterPutComponentTemplateRequestExample2.yaml": [ + { + "language": "Python", + "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)" + }, + { + "language": "JavaScript", + "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});" + }, + { + "language": "Ruby", + "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)" + }, + { + "language": "PHP", + "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]);" + }, + { + "language": "curl", + "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\"" + } + ], + "specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.get_settings(\n filter_path=\"persistent.cluster.remote\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.getSettings({\n filter_path: \"persistent.cluster.remote\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.get_settings(\n filter_path: \"persistent.cluster.remote\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->getSettings([\n \"filter_path\" => \"persistent.cluster.remote\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/settings?filter_path=persistent.cluster.remote\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/cluster/reroute/examples/request/ClusterRerouteRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.reroute(\n metric=\"none\",\n commands=[\n {\n \"move\": {\n \"index\": \"test\",\n \"shard\": 0,\n \"from_node\": \"node1\",\n \"to_node\": \"node2\"\n }\n },\n {\n \"allocate_replica\": {\n \"index\": \"test\",\n \"shard\": 1,\n \"node\": \"node3\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.reroute({\n metric: \"none\",\n commands: [\n {\n move: {\n index: \"test\",\n shard: 0,\n from_node: \"node1\",\n to_node: \"node2\",\n },\n },\n {\n allocate_replica: {\n index: \"test\",\n shard: 1,\n node: \"node3\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.reroute(\n metric: \"none\",\n body: {\n \"commands\": [\n {\n \"move\": {\n \"index\": \"test\",\n \"shard\": 0,\n \"from_node\": \"node1\",\n \"to_node\": \"node2\"\n }\n },\n {\n \"allocate_replica\": {\n \"index\": \"test\",\n \"shard\": 1,\n \"node\": \"node3\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->reroute([\n \"metric\" => \"none\",\n \"body\" => [\n \"commands\" => array(\n [\n \"move\" => [\n \"index\" => \"test\",\n \"shard\" => 0,\n \"from_node\" => \"node1\",\n \"to_node\" => \"node2\",\n ],\n ],\n [\n \"allocate_replica\" => [\n \"index\" => \"test\",\n \"shard\" => 1,\n \"node\" => \"node3\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "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\"" + } + ], + "specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.allocation_explain(\n index=\"my-index-000001\",\n shard=0,\n primary=False,\n current_node=\"my-node\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.allocationExplain({\n index: \"my-index-000001\",\n shard: 0,\n primary: false,\n current_node: \"my-node\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.allocation_explain(\n body: {\n \"index\": \"my-index-000001\",\n \"shard\": 0,\n \"primary\": false,\n \"current_node\": \"my-node\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->allocationExplain([\n \"body\" => [\n \"index\" => \"my-index-000001\",\n \"shard\" => 0,\n \"primary\" => false,\n \"current_node\" => \"my-node\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my-index-000001\",\"shard\":0,\"primary\":false,\"current_node\":\"my-node\"}' \"$ELASTICSEARCH_URL/_cluster/allocation/explain\"" + }, + { + "language": "Java", + "code": "client.cluster().allocationExplain(a -> a\n .currentNode(\"my-node\")\n .index(\"my-index-000001\")\n .primary(false)\n .shard(0)\n);\n" + } + ], + "specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.put_settings(\n persistent={\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.putSettings({\n persistent: {\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.put_settings(\n body: {\n \"persistent\": {\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"persistent\" => [\n \"action.auto_create_index\" => \"my-index-000001,index10,-index1*,+ind*\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"persistent\":{\"action.auto_create_index\":\"my-index-000001,index10,-index1*,+ind*\"}}' \"$ELASTICSEARCH_URL/_cluster/settings\"" + }, + { + "language": "Java", + "code": "client.cluster().putSettings(p -> p\n .persistent(\"action.auto_create_index\", JsonData.fromJson(\"\\\"my-index-000001,index10,-index1*,+ind*\\\"\"))\n);\n" + } + ], + "specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.put_settings(\n persistent={\n \"indices.recovery.max_bytes_per_sec\": \"50mb\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.putSettings({\n persistent: {\n \"indices.recovery.max_bytes_per_sec\": \"50mb\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.put_settings(\n body: {\n \"persistent\": {\n \"indices.recovery.max_bytes_per_sec\": \"50mb\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"persistent\" => [\n \"indices.recovery.max_bytes_per_sec\" => \"50mb\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"persistent\":{\"indices.recovery.max_bytes_per_sec\":\"50mb\"}}' \"$ELASTICSEARCH_URL/_cluster/settings\"" + }, + { + "language": "Java", + "code": "client.cluster().putSettings(p -> p\n .persistent(\"indices.recovery.max_bytes_per_sec\", JsonData.fromJson(\"\\\"50mb\\\"\"))\n);\n" + } + ], + "specification/cluster/health/examples/request/ClusterHealthRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.health()" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.health();" + }, + { + "language": "Ruby", + "code": "response = client.cluster.health" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->health();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/health\"" + }, + { + "language": "Java", + "code": "client.cluster().health(h -> h);\n" + } + ], + "specification/cluster/state/examples/request/ClusterStateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.state(\n filter_path=\"metadata.cluster_coordination.last_committed_config\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.state({\n filter_path: \"metadata.cluster_coordination.last_committed_config\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.state(\n filter_path: \"metadata.cluster_coordination.last_committed_config\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->state([\n \"filter_path\" => \"metadata.cluster_coordination.last_committed_config\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/state?filter_path=metadata.cluster_coordination.last_committed_config\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/cluster/info/examples/request/ClusterInfoExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.info(\n target=\"_all\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.info({\n target: \"_all\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.info(\n target: \"_all\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->info([\n \"target\" => \"_all\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_info/_all\"" + }, + { + "language": "Java", + "code": "client.cluster().info(i -> i\n .target(\"_all\")\n);\n" + } + ], + "specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.remote_info()" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.remoteInfo();" + }, + { + "language": "Ruby", + "code": "response = client.cluster.remote_info" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->remoteInfo();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_remote/info\"" + }, + { + "language": "Java", + "code": "client.cluster().remoteInfo();\n" + } + ], + "specification/cluster/stats/examples/request/ClusterStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.stats(\n human=True,\n filter_path=\"indices.mappings.total_deduplicated_mapping_size*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.stats({\n human: \"true\",\n filter_path: \"indices.mappings.total_deduplicated_mapping_size*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.stats(\n human: \"true\",\n filter_path: \"indices.mappings.total_deduplicated_mapping_size*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->stats([\n \"human\" => \"true\",\n \"filter_path\" => \"indices.mappings.total_deduplicated_mapping_size*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/stats?human&filter_path=indices.mappings.total_deduplicated_mapping_size*\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/cluster/get_component_template/examples/request/ClusterGetComponentTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.get_component_template(\n name=\"template_1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.getComponentTemplate({\n name: \"template_1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.get_component_template(\n name: \"template_1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->getComponentTemplate([\n \"name\" => \"template_1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_component_template/template_1\"" + }, + { + "language": "Java", + "code": "client.cluster().getComponentTemplate(g -> g\n .name(\"template_1\")\n);\n" + } + ], + "specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ssl.certificates()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ssl.certificates();" + }, + { + "language": "Ruby", + "code": "response = client.ssl.certificates" + }, + { + "language": "PHP", + "code": "$resp = $client->ssl()->certificates();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ssl/certificates\"" + }, + { + "language": "Java", + "code": "client.ssl().certificates();\n" + } + ], + "specification/tasks/cancel/examples/request/TasksCancelExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.tasks.cancel(\n task_id=\"\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.tasks.cancel({\n task_id: \"\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.tasks.cancel(\n task_id: \"\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->tasks()->cancel([\n \"task_id\" => \"\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks//_cancel\"" + }, + { + "language": "Java", + "code": "client.tasks().cancel(c -> c\n .taskId(\"\")\n);\n" + } + ], + "specification/tasks/get/examples/request/GetTaskRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.tasks.list(\n detailed=True,\n actions=\"*/delete/byquery\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.tasks.list({\n detailed: \"true\",\n actions: \"*/delete/byquery\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.tasks.list(\n detailed: \"true\",\n actions: \"*/delete/byquery\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->tasks()->list([\n \"detailed\" => \"true\",\n \"actions\" => \"*/delete/byquery\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?detailed=true&actions=*/delete/byquery\"" + } + ], + "specification/tasks/list/examples/request/ListTasksRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.tasks.list(\n actions=\"*search\",\n detailed=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.tasks.list({\n actions: \"*search\",\n detailed: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.tasks.list(\n actions: \"*search\",\n detailed: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->tasks()->list([\n \"actions\" => \"*search\",\n \"detailed\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?actions=*search&detailed\"" + } + ], + "specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.simulate_template(\n index_patterns=[\n \"my-index-*\"\n ],\n composed_of=[\n \"ct2\"\n ],\n priority=10,\n template={\n \"settings\": {\n \"index.number_of_replicas\": 1\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.simulateTemplate({\n index_patterns: [\"my-index-*\"],\n composed_of: [\"ct2\"],\n priority: 10,\n template: {\n settings: {\n \"index.number_of_replicas\": 1,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.simulate_template(\n body: {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"ct2\"\n ],\n \"priority\": 10,\n \"template\": {\n \"settings\": {\n \"index.number_of_replicas\": 1\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->simulateTemplate([\n \"body\" => [\n \"index_patterns\" => array(\n \"my-index-*\",\n ),\n \"composed_of\" => array(\n \"ct2\",\n ),\n \"priority\" => 10,\n \"template\" => [\n \"settings\" => [\n \"index.number_of_replicas\" => 1,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"ct2\"],\"priority\":10,\"template\":{\"settings\":{\"index.number_of_replicas\":1}}}' \"$ELASTICSEARCH_URL/_index_template/_simulate\"" + }, + { + "language": "Java", + "code": "client.indices().simulateTemplate(s -> s\n .composedOf(\"ct2\")\n .indexPatterns(\"my-index-*\")\n .priority(10L)\n .template(t -> t\n .settings(se -> se\n .otherSettings(\"index.number_of_replicas\", JsonData.fromJson(\"1\"))\n )\n )\n);\n" + } + ], + "specification/indices/split/examples/request/indicesSplitRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.split(\n index=\"my-index-000001\",\n target=\"split-my-index-000001\",\n settings={\n \"index.number_of_shards\": 2\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.split({\n index: \"my-index-000001\",\n target: \"split-my-index-000001\",\n settings: {\n \"index.number_of_shards\": 2,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.split(\n index: \"my-index-000001\",\n target: \"split-my-index-000001\",\n body: {\n \"settings\": {\n \"index.number_of_shards\": 2\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->split([\n \"index\" => \"my-index-000001\",\n \"target\" => \"split-my-index-000001\",\n \"body\" => [\n \"settings\" => [\n \"index.number_of_shards\" => 2,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.number_of_shards\":2}}' \"$ELASTICSEARCH_URL/my-index-000001/_split/split-my-index-000001\"" + }, + { + "language": "Java", + "code": "client.indices().split(s -> s\n .index(\"my-index-000001\")\n .settings(\"index.number_of_shards\", JsonData.fromJson(\"2\"))\n .target(\"split-my-index-000001\")\n);\n" + } + ], + "specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.update_aliases(\n actions=[\n {\n \"add\": {\n \"index\": \"logs-nginx.access-prod\",\n \"alias\": \"logs\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.updateAliases({\n actions: [\n {\n add: {\n index: \"logs-nginx.access-prod\",\n alias: \"logs\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.update_aliases(\n body: {\n \"actions\": [\n {\n \"add\": {\n \"index\": \"logs-nginx.access-prod\",\n \"alias\": \"logs\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->updateAliases([\n \"body\" => [\n \"actions\" => array(\n [\n \"add\" => [\n \"index\" => \"logs-nginx.access-prod\",\n \"alias\" => \"logs\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"add\":{\"index\":\"logs-nginx.access-prod\",\"alias\":\"logs\"}}]}' \"$ELASTICSEARCH_URL/_aliases\"" + }, + { + "language": "Java", + "code": "client.indices().updateAliases(u -> u\n .actions(a -> a\n .add(ad -> ad\n .alias(\"logs\")\n .index(\"logs-nginx.access-prod\")\n )\n )\n);\n" + } + ], + "specification/indices/exists_alias/examples/request/IndicesExistsAliasExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.exists_alias(\n name=\"my-alias\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.existsAlias({\n name: \"my-alias\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.exists_alias(\n name: \"my-alias\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->existsAlias([\n \"name\" => \"my-alias\",\n]);" + }, + { + "language": "curl", + "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_alias/my-alias\"" + }, + { + "language": "Java", + "code": "client.indices().existsAlias(e -> e\n .name(\"my-alias\")\n);\n" + } + ], + "specification/indices/get_data_stream_mappings/examples/request/IndicesGetDataStreamMappingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_data_stream_mappings(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getDataStreamMappings({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_data_stream_mappings(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getDataStreamMappings([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings\"" + } + ], + "specification/indices/delete_template/examples/request/IndicesDeleteTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete_template(\n name=\".cloud-hot-warm-allocation-0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.deleteTemplate({\n name: \".cloud-hot-warm-allocation-0\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete_template(\n name: \".cloud-hot-warm-allocation-0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->deleteTemplate([\n \"name\" => \".cloud-hot-warm-allocation-0\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/.cloud-hot-warm-allocation-0\"" + }, + { + "language": "Java", + "code": "client.indices().deleteTemplate(d -> d\n .name(\".cloud-hot-warm-allocation-0\")\n);\n" + } + ], + "specification/indices/data_streams_stats/examples/request/indicesDataStreamStatsExampleRequest1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.data_streams_stats(\n name=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.dataStreamsStats({\n name: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.data_streams_stats(\n name: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->dataStreamsStats([\n \"name\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-index-000001/_stats\"" + }, + { + "language": "Java", + "code": "client.indices().dataStreamsStats(d -> d\n .name(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/delete_index_template/examples/request/IndicesDeleteIndexTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete_index_template(\n name=\"my-index-template\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.deleteIndexTemplate({\n name: \"my-index-template\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete_index_template(\n name: \"my-index-template\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->deleteIndexTemplate([\n \"name\" => \"my-index-template\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/my-index-template\"" + }, + { + "language": "Java", + "code": "client.indices().deleteIndexTemplate(d -> d\n .name(\"my-index-template\")\n);\n" + } + ], + "specification/indices/simulate_index_template/examples/request/indicesSimulateIndexTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.simulate_index_template(\n name=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.simulateIndexTemplate({\n name: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.simulate_index_template(\n name: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->simulateIndexTemplate([\n \"name\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/_simulate_index/my-index-000001\"" + }, + { + "language": "Java", + "code": "client.indices().simulateIndexTemplate(s -> s\n .name(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_template(\n name=\"template_1\",\n index_patterns=[\n \"te*\"\n ],\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)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putTemplate({\n name: \"template_1\",\n index_patterns: [\"te*\"],\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});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"te*\"\n ],\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)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"te*\",\n ),\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]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"te*\"],\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" + }, + { + "language": "Java", + "code": "client.indices().putTemplate(p -> p\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(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .routing(\"shard-1\"))))\n .indexPatterns(\"te*\")\n .name(\"template_1\")\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" + } + ], + "specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_template(\n name=\"template_1\",\n index_patterns=[\n \"te*\",\n \"bar*\"\n ],\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"_source\": {\n \"enabled\": False\n }\n },\n properties={\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putTemplate({\n name: \"template_1\",\n index_patterns: [\"te*\", \"bar*\"],\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n _source: {\n enabled: false,\n },\n },\n properties: {\n host_name: {\n type: \"keyword\",\n },\n created_at: {\n type: \"date\",\n format: \"EEE MMM dd HH:mm:ss Z yyyy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"te*\",\n \"bar*\"\n ],\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n \"_source\": {\n \"enabled\": false\n }\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"te*\",\n \"bar*\",\n ),\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"_source\" => [\n \"enabled\" => false,\n ],\n ],\n \"properties\" => [\n \"host_name\" => [\n \"type\" => \"keyword\",\n ],\n \"created_at\" => [\n \"type\" => \"date\",\n \"format\" => \"EEE MMM dd HH:mm:ss Z yyyy\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"te*\",\"bar*\"],\"settings\":{\"number_of_shards\":1},\"mappings\":{\"_source\":{\"enabled\":false}},\"properties\":{\"host_name\":{\"type\":\"keyword\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\"}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" + }, + { + "language": "Java", + "code": "client.indices().putTemplate(p -> p\n .indexPatterns(List.of(\"te*\",\"bar*\"))\n .mappings(m -> m\n .source(s -> s\n .enabled(false)\n )\n )\n .name(\"template_1\")\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" + } + ], + "specification/indices/put_data_stream_mappings/examples/request/IndicesPutDataStreamMappingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_data_stream_mappings(\n name=\"my-data-stream\",\n mappings={\n \"properties\": {\n \"field1\": {\n \"type\": \"ip\"\n },\n \"field3\": {\n \"type\": \"text\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putDataStreamMappings({\n name: \"my-data-stream\",\n mappings: {\n properties: {\n field1: {\n type: \"ip\",\n },\n field3: {\n type: \"text\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_data_stream_mappings(\n name: \"my-data-stream\",\n body: {\n \"properties\": {\n \"field1\": {\n \"type\": \"ip\"\n },\n \"field3\": {\n \"type\": \"text\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putDataStreamMappings([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"properties\" => [\n \"field1\" => [\n \"type\" => \"ip\",\n ],\n \"field3\" => [\n \"type\" => \"text\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"properties\":{\"field1\":{\"type\":\"ip\"},\"field3\":{\"type\":\"text\"}}}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings\"" + } + ], + "specification/indices/delete_data_lifecycle/examples/request/IndicesDeleteDataLifecycleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete_data_lifecycle(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.deleteDataLifecycle({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete_data_lifecycle(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->deleteDataLifecycle([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_lifecycle\"" + }, + { + "language": "Java", + "code": "client.indices().deleteDataLifecycle(d -> d\n .name(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_create_from/my-index/my-new-index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n {},\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n);\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_create_from/my-index/my-new-index\"" + }, + { + "language": "Java", + "code": "client.indices().createFrom(c -> c\n .dest(\"my-new-index\")\n .source(\"my-index\")\n .createFrom(cr -> cr)\n);\n" + } + ], + "specification/indices/close/examples/request/CloseIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.close(\n index=\"my-index-00001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.close({\n index: \"my-index-00001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.close(\n index: \"my-index-00001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->close([\n \"index\" => \"my-index-00001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-00001/_close\"" + }, + { + "language": "Java", + "code": "client.indices().close(c -> c\n .index(\"my-index-00001\")\n);\n" + } + ], + "specification/indices/get_migrate_reindex_status/examples/request/IndicesGetMigrateReindexStatusExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"GET\",\n path: \"/_migration/reindex/my-data-stream/_status\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n {},\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n);\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/reindex/my-data-stream/_status\"" + }, + { + "language": "Java", + "code": "client.indices().getMigrateReindexStatus(g -> g\n .index(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/get_settings/examples/request/IndicesGetSettingsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_settings(\n index=\"_all\",\n expand_wildcards=\"all\",\n filter_path=\"*.settings.index.*.slowlog\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getSettings({\n index: \"_all\",\n expand_wildcards: \"all\",\n filter_path: \"*.settings.index.*.slowlog\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_settings(\n index: \"_all\",\n expand_wildcards: \"all\",\n filter_path: \"*.settings.index.*.slowlog\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getSettings([\n \"index\" => \"_all\",\n \"expand_wildcards\" => \"all\",\n \"filter_path\" => \"*.settings.index.*.slowlog\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_all/_settings?expand_wildcards=all&filter_path=*.settings.index.*.slowlog\"" + } + ], + "specification/indices/promote_data_stream/examples/request/IndicesPromoteDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.promote_data_stream(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.promoteDataStream({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.promote_data_stream(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->promoteDataStream([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/_promote/my-data-stream\"" + }, + { + "language": "Java", + "code": "client.indices().promoteDataStream(p -> p\n .name(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/flush/examples/request/IndicesFlushExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.flush()" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.flush();" + }, + { + "language": "Ruby", + "code": "response = client.indices.flush" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->flush();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_flush\"" + }, + { + "language": "Java", + "code": "client.indices().flush(f -> f);\n" + } + ], + "specification/indices/delete/examples/request/IndicesDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete(\n index=\"books\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.delete({\n index: \"books\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete(\n index: \"books\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->delete([\n \"index\" => \"books\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/books\"" + }, + { + "language": "Java", + "code": "client.indices().delete(d -> d\n .index(\"books\")\n);\n" + } + ], + "specification/indices/refresh/examples/request/IndicesRefreshExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.refresh()" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.refresh();" + }, + { + "language": "Ruby", + "code": "response = client.indices.refresh" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->refresh();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_refresh\"" + }, + { + "language": "Java", + "code": "client.indices().refresh(r -> r);\n" + } + ], + "specification/indices/resolve_index/examples/request/ResolveIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.resolve_index(\n name=\"f*,remoteCluster1:bar*\",\n expand_wildcards=\"all\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.resolveIndex({\n name: \"f*,remoteCluster1:bar*\",\n expand_wildcards: \"all\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.resolve_index(\n name: \"f*,remoteCluster1:bar*\",\n expand_wildcards: \"all\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->resolveIndex([\n \"name\" => \"f*,remoteCluster1:bar*\",\n \"expand_wildcards\" => \"all\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_resolve/index/f*,remoteCluster1:bar*?expand_wildcards=all\"" + } + ], + "specification/indices/exists/examples/request/IndicesExistsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.exists(\n index=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.exists({\n index: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.exists(\n index: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->exists([\n \"index\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-data-stream\"" + }, + { + "language": "Java", + "code": "client.indices().exists(e -> e\n .index(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.recovery(\n human=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.recovery({\n human: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.recovery(\n human: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->recovery([\n \"human\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_recovery?human\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"analysis\": {\n \"analyzer\": {\n \"content\": {\n \"type\": \"custom\",\n \"tokenizer\": \"whitespace\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n analysis: {\n analyzer: {\n content: {\n type: \"custom\",\n tokenizer: \"whitespace\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"analysis\": {\n \"analyzer\": {\n \"content\": {\n \"type\": \"custom\",\n \"tokenizer\": \"whitespace\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"analysis\" => [\n \"analyzer\" => [\n \"content\" => [\n \"type\" => \"custom\",\n \"tokenizer\" => \"whitespace\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis\":{\"analyzer\":{\"content\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" + }, + { + "language": "Java", + "code": "client.indices().putSettings(p -> p\n .index(\"my-index-000001\")\n .settings(s -> s\n .analysis(a -> a\n .analyzer(\"content\", an -> an\n .custom(c -> c\n .tokenizer(\"whitespace\")\n )\n )\n )\n )\n);\n" + } + ], + "specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"index\": {\n \"refresh_interval\": None\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n index: {\n refresh_interval: null,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"index\": {\n \"refresh_interval\": nil\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"index\" => [\n \"refresh_interval\" => null,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":{\"refresh_interval\":null}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" + } + ], + "specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"index\": {\n \"number_of_replicas\": 2\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n index: {\n number_of_replicas: 2,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"index\": {\n \"number_of_replicas\": 2\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"index\" => [\n \"number_of_replicas\" => 2,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":{\"number_of_replicas\":2}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" + }, + { + "language": "Java", + "code": "client.indices().putSettings(p -> p\n .index(\"my-index-000001\")\n .settings(s -> s\n .index(i -> i\n .numberOfReplicas(\"2\")\n )\n )\n);\n" + } + ], + "specification/indices/clear_cache/examples/request/IndicesClearCacheExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.clear_cache(\n index=\"my-index-000001,my-index-000002\",\n request=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.clearCache({\n index: \"my-index-000001,my-index-000002\",\n request: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.clear_cache(\n index: \"my-index-000001,my-index-000002\",\n request: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->clearCache([\n \"index\" => \"my-index-000001,my-index-000002\",\n \"request\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001,my-index-000002/_cache/clear?request=true\"" + }, + { + "language": "Java", + "code": "client.indices().clearCache(c -> c\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n .request(true)\n);\n" + } + ], + "specification/indices/reload_search_analyzers/examples/request/ReloadSearchAnalyzersRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.reload_search_analyzers(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.reloadSearchAnalyzers({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.reload_search_analyzers(\n index: \"my-index-000001\",\n body: {\n \"_shards\": {\n \"total\": 2,\n \"successful\": 2,\n \"failed\": 0\n },\n \"reload_details\": [\n {\n \"index\": \"my-index-000001\",\n \"reloaded_analyzers\": [\n \"my_synonyms\"\n ],\n \"reloaded_node_ids\": [\n \"mfdqTXn_T7SGr2Ho2KT8uw\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->reloadSearchAnalyzers([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"_shards\" => [\n \"total\" => 2,\n \"successful\" => 2,\n \"failed\" => 0,\n ],\n \"reload_details\" => array(\n [\n \"index\" => \"my-index-000001\",\n \"reloaded_analyzers\" => array(\n \"my_synonyms\",\n ),\n \"reloaded_node_ids\" => array(\n \"mfdqTXn_T7SGr2Ho2KT8uw\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"_shards\":{\"total\":2,\"successful\":2,\"failed\":0},\"reload_details\":[{\"index\":\"my-index-000001\",\"reloaded_analyzers\":[\"my_synonyms\"],\"reloaded_node_ids\":[\"mfdqTXn_T7SGr2Ho2KT8uw\"]}]}' \"$ELASTICSEARCH_URL/my-index-000001/_reload_search_analyzers\"" + } + ], + "specification/indices/cancel_migrate_reindex/examples/request/IndicesCancelMigrateReindexExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_migration/reindex/my-data-stream/_cancel\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n {},\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n);\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/reindex/my-data-stream/_cancel\"" + }, + { + "language": "Java", + "code": "client.indices().cancelMigrateReindex(c -> c\n .index(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/delete_data_stream/examples/request/IndicesDeleteDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete_data_stream(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.deleteDataStream({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete_data_stream(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->deleteDataStream([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream\"" + }, + { + "language": "Java", + "code": "client.indices().deleteDataStream(d -> d\n .name(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/get/examples/request/IndicesGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.get({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->get([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001\"" + }, + { + "language": "Java", + "code": "client.indices().get(g -> g\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/disk_usage/examples/request/IndicesDiskUsageExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.disk_usage(\n index=\"my-index-000001\",\n run_expensive_tasks=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.diskUsage({\n index: \"my-index-000001\",\n run_expensive_tasks: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.disk_usage(\n index: \"my-index-000001\",\n run_expensive_tasks: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->diskUsage([\n \"index\" => \"my-index-000001\",\n \"run_expensive_tasks\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_disk_usage?run_expensive_tasks=true\"" + }, + { + "language": "Java", + "code": "client.indices().diskUsage(d -> d\n .index(\"my-index-000001\")\n .runExpensiveTasks(true)\n);\n" + } + ], + "specification/indices/create_data_stream/examples/request/IndicesCreateDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.create_data_stream(\n name=\"logs-foo-bar\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.createDataStream({\n name: \"logs-foo-bar\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.create_data_stream(\n name: \"logs-foo-bar\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->createDataStream([\n \"name\" => \"logs-foo-bar\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/logs-foo-bar\"" + }, + { + "language": "Java", + "code": "client.indices().createDataStream(c -> c\n .name(\"logs-foo-bar\")\n);\n" + } + ], + "specification/indices/delete_alias/examples/request/IndicesDeleteAliasExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.delete_alias(\n index=\"my-data-stream\",\n name=\"my-alias\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.deleteAlias({\n index: \"my-data-stream\",\n name: \"my-alias\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.delete_alias(\n index: \"my-data-stream\",\n name: \"my-alias\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->deleteAlias([\n \"index\" => \"my-data-stream\",\n \"name\" => \"my-alias\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-data-stream/_alias/my-alias\"" + }, + { + "language": "Java", + "code": "client.indices().deleteAlias(d -> d\n .index(\"my-data-stream\")\n .name(\"my-alias\")\n);\n" + } + ], + "specification/indices/forcemerge/examples/request/IndicesForcemergeExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.forcemerge(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.forcemerge({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.forcemerge(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->forcemerge([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_forcemerge\"" + }, + { + "language": "Java", + "code": "client.indices().forcemerge(f -> f\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.downsample(\n index=\"my-time-series-index\",\n target_index=\"my-downsampled-time-series-index\",\n config={\n \"fixed_interval\": \"1d\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.downsample({\n index: \"my-time-series-index\",\n target_index: \"my-downsampled-time-series-index\",\n config: {\n fixed_interval: \"1d\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.downsample(\n index: \"my-time-series-index\",\n target_index: \"my-downsampled-time-series-index\",\n body: {\n \"fixed_interval\": \"1d\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->downsample([\n \"index\" => \"my-time-series-index\",\n \"target_index\" => \"my-downsampled-time-series-index\",\n \"body\" => [\n \"fixed_interval\" => \"1d\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fixed_interval\":\"1d\"}' \"$ELASTICSEARCH_URL/my-time-series-index/_downsample/my-downsampled-time-series-index\"" + }, + { + "language": "Java", + "code": "client.indices().downsample(d -> d\n .index(\"my-time-series-index\")\n .targetIndex(\"my-downsampled-time-series-index\")\n .config(c -> c\n .fixedInterval(f -> f\n .time(\"1d\")\n )\n )\n);\n" + } + ], + "specification/indices/get_template/examples/request/IndicesGetTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_template(\n name=\".monitoring-*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getTemplate({\n name: \".monitoring-*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_template(\n name: \".monitoring-*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getTemplate([\n \"name\" => \".monitoring-*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/.monitoring-*\"" + }, + { + "language": "Java", + "code": "client.indices().getTemplate(g -> g\n .name(\".monitoring-*\")\n);\n" + } + ], + "specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.shrink(\n index=\"my_source_index\",\n target=\"my_target_index\",\n settings={\n \"index.routing.allocation.require._name\": None,\n \"index.blocks.write\": None\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.shrink({\n index: \"my_source_index\",\n target: \"my_target_index\",\n settings: {\n \"index.routing.allocation.require._name\": null,\n \"index.blocks.write\": null,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.shrink(\n index: \"my_source_index\",\n target: \"my_target_index\",\n body: {\n \"settings\": {\n \"index.routing.allocation.require._name\": nil,\n \"index.blocks.write\": nil\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->shrink([\n \"index\" => \"my_source_index\",\n \"target\" => \"my_target_index\",\n \"body\" => [\n \"settings\" => [\n \"index.routing.allocation.require._name\" => null,\n \"index.blocks.write\" => null,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.routing.allocation.require._name\":null,\"index.blocks.write\":null}}' \"$ELASTICSEARCH_URL/my_source_index/_shrink/my_target_index\"" + }, + { + "language": "Java", + "code": "client.indices().shrink(s -> s\n .index(\"my_source_index\")\n .settings(Map.of(\"index.blocks.write\", JsonData.fromJson(\"null\"),\"index.routing.allocation.require._name\", JsonData.fromJson(\"null\")))\n .target(\"my_target_index\")\n);\n" + } + ], + "specification/indices/explain_data_lifecycle/examples/request/IndicesExplainDataLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.explain_data_lifecycle(\n index=\".ds-metrics-2023.03.22-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.explainDataLifecycle({\n index: \".ds-metrics-2023.03.22-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.explain_data_lifecycle(\n index: \".ds-metrics-2023.03.22-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->explainDataLifecycle([\n \"index\" => \".ds-metrics-2023.03.22-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-metrics-2023.03.22-000001/_lifecycle/explain\"" + }, + { + "language": "Java", + "code": "client.indices().explainDataLifecycle(e -> e\n .index(\".ds-metrics-2023.03.22-000001\")\n);\n" + } + ], + "specification/indices/get_mapping/examples/request/IndicesGetMappingExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_mapping(\n index=\"books\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getMapping({\n index: \"books\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_mapping(\n index: \"books\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getMapping([\n \"index\" => \"books\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/books/_mapping\"" + }, + { + "language": "Java", + "code": "client.indices().getMapping(g -> g\n .index(\"books\")\n);\n" + } + ], + "specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_data_lifecycle_stats(\n human=True,\n pretty=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getDataLifecycleStats({\n human: \"true\",\n pretty: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_data_lifecycle_stats(\n human: \"true\",\n pretty: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getDataLifecycleStats([\n \"human\" => \"true\",\n \"pretty\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_lifecycle/stats?human&pretty\"" + }, + { + "language": "Java", + "code": "client.indices().getDataLifecycleStats();\n" + } + ], + "specification/indices/add_block/examples/request/IndicesAddBlockRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.add_block(\n index=\"my-index-000001\",\n block=\"write\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.addBlock({\n index: \"my-index-000001\",\n block: \"write\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.add_block(\n index: \"my-index-000001\",\n block: \"write\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->addBlock([\n \"index\" => \"my-index-000001\",\n \"block\" => \"write\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_block/write\"" + }, + { + "language": "Java", + "code": "client.indices().addBlock(a -> a\n .block(IndicesBlockOptions.Write)\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.rollover(\n alias=\"my-data-stream\",\n conditions={\n \"max_age\": \"7d\",\n \"max_docs\": 1000,\n \"max_primary_shard_size\": \"50gb\",\n \"max_primary_shard_docs\": \"2000\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.rollover({\n alias: \"my-data-stream\",\n conditions: {\n max_age: \"7d\",\n max_docs: 1000,\n max_primary_shard_size: \"50gb\",\n max_primary_shard_docs: \"2000\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.rollover(\n alias: \"my-data-stream\",\n body: {\n \"conditions\": {\n \"max_age\": \"7d\",\n \"max_docs\": 1000,\n \"max_primary_shard_size\": \"50gb\",\n \"max_primary_shard_docs\": \"2000\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->rollover([\n \"alias\" => \"my-data-stream\",\n \"body\" => [\n \"conditions\" => [\n \"max_age\" => \"7d\",\n \"max_docs\" => 1000,\n \"max_primary_shard_size\" => \"50gb\",\n \"max_primary_shard_docs\" => \"2000\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"conditions\":{\"max_age\":\"7d\",\"max_docs\":1000,\"max_primary_shard_size\":\"50gb\",\"max_primary_shard_docs\":\"2000\"}}' \"$ELASTICSEARCH_URL/my-data-stream/_rollover\"" + }, + { + "language": "Java", + "code": "client.indices().rollover(r -> r\n .alias(\"my-data-stream\")\n .conditions(c -> c\n .maxAge(m -> m\n .time(\"7d\")\n )\n .maxDocs(1000L)\n .maxPrimaryShardSize(\"50gb\")\n .maxPrimaryShardDocs(2000L)\n )\n);\n" + } + ], + "specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_data_lifecycle(\n name=\"my-data-stream\",\n data_retention=\"7d\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putDataLifecycle({\n name: \"my-data-stream\",\n data_retention: \"7d\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_data_lifecycle(\n name: \"my-data-stream\",\n body: {\n \"data_retention\": \"7d\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putDataLifecycle([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"data_retention\" => \"7d\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"data_retention\":\"7d\"}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_lifecycle\"" + }, + { + "language": "Java", + "code": "client.indices().putDataLifecycle(p -> p\n .dataRetention(d -> d\n .time(\"7d\")\n )\n .name(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_data_lifecycle(\n name=\"my-weather-sensor-data-stream\",\n downsampling=[\n {\n \"after\": \"1d\",\n \"fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \"fixed_interval\": \"1d\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putDataLifecycle({\n name: \"my-weather-sensor-data-stream\",\n downsampling: [\n {\n after: \"1d\",\n fixed_interval: \"10m\",\n },\n {\n after: \"7d\",\n fixed_interval: \"1d\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_data_lifecycle(\n name: \"my-weather-sensor-data-stream\",\n body: {\n \"downsampling\": [\n {\n \"after\": \"1d\",\n \"fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \"fixed_interval\": \"1d\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putDataLifecycle([\n \"name\" => \"my-weather-sensor-data-stream\",\n \"body\" => [\n \"downsampling\" => array(\n [\n \"after\" => \"1d\",\n \"fixed_interval\" => \"10m\",\n ],\n [\n \"after\" => \"7d\",\n \"fixed_interval\" => \"1d\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"downsampling\":[{\"after\":\"1d\",\"fixed_interval\":\"10m\"},{\"after\":\"7d\",\"fixed_interval\":\"1d\"}]}' \"$ELASTICSEARCH_URL/_data_stream/my-weather-sensor-data-stream/_lifecycle\"" + } + ], + "specification/indices/exists_template/examples/request/IndicesExistsTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.exists_template(\n name=\"template_1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.existsTemplate({\n name: \"template_1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.exists_template(\n name: \"template_1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->existsTemplate([\n \"name\" => \"template_1\",\n]);" + }, + { + "language": "curl", + "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/template_1\"" + }, + { + "language": "Java", + "code": "client.indices().existsTemplate(e -> e\n .name(\"template_1\")\n);\n" + } + ], + "specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.validate_query(\n index=\"my-index-000001\",\n q=\"user.id:kimchy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.validateQuery({\n index: \"my-index-000001\",\n q: \"user.id:kimchy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.validate_query(\n index: \"my-index-000001\",\n q: \"user.id:kimchy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->validateQuery([\n \"index\" => \"my-index-000001\",\n \"q\" => \"user.id:kimchy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_validate/query?q=user.id:kimchy\"" + }, + { + "language": "Java", + "code": "client.indices().validateQuery(v -> v\n .index(\"my-index-000001\")\n .q(\"user.id:kimchy\")\n);\n" + } + ], + "specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_index_template(\n name=\"template_1\",\n index_patterns=[\n \"template*\"\n ],\n priority=1,\n template={\n \"settings\": {\n \"number_of_shards\": 2\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putIndexTemplate({\n name: \"template_1\",\n index_patterns: [\"template*\"],\n priority: 1,\n template: {\n settings: {\n number_of_shards: 2,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_index_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"template*\"\n ],\n \"priority\": 1,\n \"template\": {\n \"settings\": {\n \"number_of_shards\": 2\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putIndexTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"template*\",\n ),\n \"priority\" => 1,\n \"template\" => [\n \"settings\" => [\n \"number_of_shards\" => 2,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"template*\"],\"priority\":1,\"template\":{\"settings\":{\"number_of_shards\":2}}}' \"$ELASTICSEARCH_URL/_index_template/template_1\"" + }, + { + "language": "Java", + "code": "client.indices().putIndexTemplate(p -> p\n .indexPatterns(\"template*\")\n .name(\"template_1\")\n .priority(1L)\n .template(t -> t\n .settings(s -> s\n .numberOfShards(\"2\")\n )\n )\n);\n" + } + ], + "specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_index_template(\n name=\"template_1\",\n index_patterns=[\n \"template*\"\n ],\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)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putIndexTemplate({\n name: \"template_1\",\n index_patterns: [\"template*\"],\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});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_index_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"template*\"\n ],\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)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putIndexTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"template*\",\n ),\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]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"template*\"],\"template\":{\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}}' \"$ELASTICSEARCH_URL/_index_template/template_1\"" + }, + { + "language": "Java", + "code": "client.indices().putIndexTemplate(p -> p\n .indexPatterns(\"template*\")\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 .settings(s -> s\n .numberOfShards(\"1\")\n )\n )\n);\n" + } + ], + "specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.clone(\n index=\"my_source_index\",\n target=\"my_target_index\",\n settings={\n \"index.refresh_interval\": \"2s\"\n },\n aliases={\n \"my_search_indices\": {}\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.clone({\n index: \"my_source_index\",\n target: \"my_target_index\",\n settings: {\n \"index.refresh_interval\": \"2s\",\n },\n aliases: {\n my_search_indices: {},\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.clone(\n index: \"my_source_index\",\n target: \"my_target_index\",\n body: {\n \"settings\": {\n \"index.refresh_interval\": \"2s\"\n },\n \"aliases\": {\n \"my_search_indices\": {}\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->clone([\n \"index\" => \"my_source_index\",\n \"target\" => \"my_target_index\",\n \"body\" => [\n \"settings\" => [\n \"index.refresh_interval\" => \"2s\",\n ],\n \"aliases\" => [\n \"my_search_indices\" => new ArrayObject([]),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.refresh_interval\":\"2s\"},\"aliases\":{\"my_search_indices\":{}}}' \"$ELASTICSEARCH_URL/my_source_index/_clone/my_target_index\"" + }, + { + "language": "Java", + "code": "client.indices().clone(c -> c\n .aliases(\"my_search_indices\", a -> a)\n .index(\"my_source_index\")\n .settings(\"index.number_of_shards\", JsonData.fromJson(\"5\"))\n .target(\"my_target_index\")\n);\n" + } + ], + "specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_index_template(\n name=\"*\",\n filter_path=\"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getIndexTemplate({\n name: \"*\",\n filter_path:\n \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_index_template(\n name: \"*\",\n filter_path: \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getIndexTemplate([\n \"name\" => \"*\",\n \"filter_path\" => \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_data_lifecycle(\n name=\"{name}\",\n human=True,\n pretty=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getDataLifecycle({\n name: \"{name}\",\n human: \"true\",\n pretty: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_data_lifecycle(\n name: \"{name}\",\n human: \"true\",\n pretty: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getDataLifecycle([\n \"name\" => \"{name}\",\n \"human\" => \"true\",\n \"pretty\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/%7Bname%7D/_lifecycle?human&pretty\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/indices/get_data_stream/examples/request/IndicesGetDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_data_stream(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getDataStream({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_data_stream(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getDataStream([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream\"" + }, + { + "language": "Java", + "code": "client.indices().getDataStream(g -> g\n .name(\"my-data-stream\")\n);\n" + } + ], + "specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.modify_data_stream(\n actions=[\n {\n \"remove_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001\"\n }\n },\n {\n \"add_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001-downsample\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.modifyDataStream({\n actions: [\n {\n remove_backing_index: {\n data_stream: \"my-data-stream\",\n index: \".ds-my-data-stream-2023.07.26-000001\",\n },\n },\n {\n add_backing_index: {\n data_stream: \"my-data-stream\",\n index: \".ds-my-data-stream-2023.07.26-000001-downsample\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.modify_data_stream(\n body: {\n \"actions\": [\n {\n \"remove_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001\"\n }\n },\n {\n \"add_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001-downsample\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->modifyDataStream([\n \"body\" => [\n \"actions\" => array(\n [\n \"remove_backing_index\" => [\n \"data_stream\" => \"my-data-stream\",\n \"index\" => \".ds-my-data-stream-2023.07.26-000001\",\n ],\n ],\n [\n \"add_backing_index\" => [\n \"data_stream\" => \"my-data-stream\",\n \"index\" => \".ds-my-data-stream-2023.07.26-000001-downsample\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"remove_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001\"}},{\"add_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001-downsample\"}}]}' \"$ELASTICSEARCH_URL/_data_stream/_modify\"" + }, + { + "language": "Java", + "code": "client.indices().modifyDataStream(m -> m\n .actions(List.of(Action.of(a -> a\n .removeBackingIndex(r -> r\n .dataStream(\"my-data-stream\")\n .index(\".ds-my-data-stream-2023.07.26-000001\")\n )),Action.of(ac -> ac\n .addBackingIndex(ad -> ad\n .dataStream(\"my-data-stream\")\n .index(\".ds-my-data-stream-2023.07.26-000001-downsample\")\n ))))\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n tokenizer=\"keyword\",\n filter=[\n \"lowercase\"\n ],\n char_filter=[\n \"html_strip\"\n ],\n text=\"this is a test\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n tokenizer: \"keyword\",\n filter: [\"lowercase\"],\n char_filter: [\"html_strip\"],\n text: \"this is a test\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"keyword\",\n \"filter\": [\n \"lowercase\"\n ],\n \"char_filter\": [\n \"html_strip\"\n ],\n \"text\": \"this is a test\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"keyword\",\n \"filter\" => array(\n \"lowercase\",\n ),\n \"char_filter\" => array(\n \"html_strip\",\n ),\n \"text\" => \"this is a test\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"keyword\",\"filter\":[\"lowercase\"],\"char_filter\":[\"html_strip\"],\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .charFilter(c -> c\n .name(\"html_strip\")\n )\n .filter(f -> f\n .name(\"lowercase\")\n )\n .text(\"this is a test\")\n .tokenizer(t -> t\n .name(\"keyword\")\n )\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n analyzer=\"standard\",\n text=[\n \"this is a test\",\n \"the second text\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n analyzer: \"standard\",\n text: [\"this is a test\", \"the second text\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n body: {\n \"analyzer\": \"standard\",\n \"text\": [\n \"this is a test\",\n \"the second text\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"analyzer\" => \"standard\",\n \"text\" => array(\n \"this is a test\",\n \"the second text\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analyzer\":\"standard\",\"text\":[\"this is a test\",\"the second text\"]}' \"$ELASTICSEARCH_URL/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .analyzer(\"standard\")\n .text(List.of(\"this is a test\",\"the second text\"))\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n index=\"analyze_sample\",\n field=\"obj1.field1\",\n text=\"this is a test\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n index: \"analyze_sample\",\n field: \"obj1.field1\",\n text: \"this is a test\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n index: \"analyze_sample\",\n body: {\n \"field\": \"obj1.field1\",\n \"text\": \"this is a test\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"index\" => \"analyze_sample\",\n \"body\" => [\n \"field\" => \"obj1.field1\",\n \"text\" => \"this is a test\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"field\":\"obj1.field1\",\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/analyze_sample/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .field(\"obj1.field1\")\n .index(\"analyze_sample\")\n .text(\"this is a test\")\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n tokenizer=\"whitespace\",\n filter=[\n \"lowercase\",\n {\n \"type\": \"stop\",\n \"stopwords\": [\n \"a\",\n \"is\",\n \"this\"\n ]\n }\n ],\n text=\"this is a test\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n tokenizer: \"whitespace\",\n filter: [\n \"lowercase\",\n {\n type: \"stop\",\n stopwords: [\"a\", \"is\", \"this\"],\n },\n ],\n text: \"this is a test\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"whitespace\",\n \"filter\": [\n \"lowercase\",\n {\n \"type\": \"stop\",\n \"stopwords\": [\n \"a\",\n \"is\",\n \"this\"\n ]\n }\n ],\n \"text\": \"this is a test\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"whitespace\",\n \"filter\" => array(\n \"lowercase\",\n [\n \"type\" => \"stop\",\n \"stopwords\" => array(\n \"a\",\n \"is\",\n \"this\",\n ),\n ],\n ),\n \"text\" => \"this is a test\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"whitespace\",\"filter\":[\"lowercase\",{\"type\":\"stop\",\"stopwords\":[\"a\",\"is\",\"this\"]}],\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .filter(List.of(TokenFilter.of(t -> t\n .name(\"lowercase\"\n )),TokenFilter.of(to -> to\n .definition(d -> d\n .stop(s -> s\n .stopwords(List.of(\"a\",\"is\",\"this\"))\n )\n ))))\n .text(\"this is a test\")\n .tokenizer(tok -> tok\n .name(\"whitespace\")\n )\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n tokenizer=\"standard\",\n filter=[\n \"snowball\"\n ],\n text=\"detailed output\",\n explain=True,\n attributes=[\n \"keyword\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n tokenizer: \"standard\",\n filter: [\"snowball\"],\n text: \"detailed output\",\n explain: true,\n attributes: [\"keyword\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"standard\",\n \"filter\": [\n \"snowball\"\n ],\n \"text\": \"detailed output\",\n \"explain\": true,\n \"attributes\": [\n \"keyword\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"standard\",\n \"filter\" => array(\n \"snowball\",\n ),\n \"text\" => \"detailed output\",\n \"explain\" => true,\n \"attributes\" => array(\n \"keyword\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"standard\",\"filter\":[\"snowball\"],\"text\":\"detailed output\",\"explain\":true,\"attributes\":[\"keyword\"]}' \"$ELASTICSEARCH_URL/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .attributes(\"keyword\")\n .explain(true)\n .filter(f -> f\n .name(\"snowball\")\n )\n .text(\"detailed output\")\n .tokenizer(t -> t\n .name(\"standard\")\n )\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n index=\"analyze_sample\",\n normalizer=\"my_normalizer\",\n text=\"BaR\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n index: \"analyze_sample\",\n normalizer: \"my_normalizer\",\n text: \"BaR\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n index: \"analyze_sample\",\n body: {\n \"normalizer\": \"my_normalizer\",\n \"text\": \"BaR\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"index\" => \"analyze_sample\",\n \"body\" => [\n \"normalizer\" => \"my_normalizer\",\n \"text\" => \"BaR\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"normalizer\":\"my_normalizer\",\"text\":\"BaR\"}' \"$ELASTICSEARCH_URL/analyze_sample/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .index(\"analyze_sample\")\n .normalizer(\"my_normalizer\")\n .text(\"BaR\")\n);\n" + } + ], + "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.analyze(\n analyzer=\"standard\",\n text=\"this is a test\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.analyze({\n analyzer: \"standard\",\n text: \"this is a test\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.analyze(\n body: {\n \"analyzer\": \"standard\",\n \"text\": \"this is a test\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"analyzer\" => \"standard\",\n \"text\" => \"this is a test\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analyzer\":\"standard\",\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" + }, + { + "language": "Java", + "code": "client.indices().analyze(a -> a\n .analyzer(\"standard\")\n .text(\"this is a test\")\n);\n" + } + ], + "specification/indices/shard_stores/examples/request/indicesShardStoresRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.shard_stores(\n status=\"green\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.shardStores({\n status: \"green\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.shard_stores(\n status: \"green\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->shardStores([\n \"status\" => \"green\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_shard_stores?status=green\"" + } + ], + "specification/indices/get_data_stream_settings/examples/request/IndicesGetDataStreamSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_data_stream_settings(\n name=\"my-data-stream\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getDataStreamSettings({\n name: \"my-data-stream\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_data_stream_settings(\n name: \"my-data-stream\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getDataStreamSettings([\n \"name\" => \"my-data-stream\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_settings\"" + } + ], + "specification/indices/get_alias/examples/request/IndicesGetAliasExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_alias()" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getAlias();" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_alias" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getAlias();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_alias\"" + }, + { + "language": "Java", + "code": "client.indices().getAlias(g -> g);\n" + } + ], + "specification/indices/remove_block/examples/request/IndicesRemoveBlockRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.remove_block(\n index=\"my-index-000001\",\n block=\"write\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.removeBlock({\n index: \"my-index-000001\",\n block: \"write\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.remove_block(\n index: \"my-index-000001\",\n block: \"write\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->removeBlock([\n \"index\" => \"my-index-000001\",\n \"block\" => \"write\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_block/write\"" + }, + { + "language": "Java", + "code": "client.indices().removeBlock(a -> a\n .block(IndicesBlockOptions.Write)\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.update_aliases(\n actions=[\n {\n \"add\": {\n \"index\": \"my-data-stream\",\n \"alias\": \"my-alias\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.updateAliases({\n actions: [\n {\n add: {\n index: \"my-data-stream\",\n alias: \"my-alias\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.update_aliases(\n body: {\n \"actions\": [\n {\n \"add\": {\n \"index\": \"my-data-stream\",\n \"alias\": \"my-alias\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->updateAliases([\n \"body\" => [\n \"actions\" => array(\n [\n \"add\" => [\n \"index\" => \"my-data-stream\",\n \"alias\" => \"my-alias\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"add\":{\"index\":\"my-data-stream\",\"alias\":\"my-alias\"}}]}' \"$ELASTICSEARCH_URL/_aliases\"" + }, + { + "language": "Java", + "code": "client.indices().updateAliases(u -> u\n .actions(a -> a\n .add(ad -> ad\n .alias(\"my-alias\")\n .index(\"my-data-stream\")\n )\n )\n);\n" + } + ], + "specification/indices/put_data_stream_settings/examples/request/IndicesPutDataStreamSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_data_stream_settings(\n name=\"my-data-stream\",\n settings={\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putDataStreamSettings({\n name: \"my-data-stream\",\n settings: {\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_data_stream_settings(\n name: \"my-data-stream\",\n body: {\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putDataStreamSettings([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"index.lifecycle.name\" => \"new-test-policy\",\n \"index.number_of_shards\" => 11,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index.lifecycle.name\":\"new-test-policy\",\"index.number_of_shards\":11}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_settings\"" + } + ], + "specification/indices/get_field_mapping/examples/request/indicesGetFieldMappingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.get_field_mapping(\n index=\"publications\",\n fields=\"title\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.getFieldMapping({\n index: \"publications\",\n fields: \"title\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.get_field_mapping(\n index: \"publications\",\n fields: \"title\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->getFieldMapping([\n \"index\" => \"publications\",\n \"fields\" => \"title\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/publications/_mapping/field/title\"" + }, + { + "language": "Java", + "code": "client.indices().getFieldMapping(g -> g\n .fields(\"title\")\n .index(\"publications\")\n);\n" + } + ], + "specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"POST\",\n \"/_migration/reindex\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"source\": {\n \"index\": \"my-data-stream\"\n },\n \"mode\": \"upgrade\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_migration/reindex\",\n body: {\n source: {\n index: \"my-data-stream\",\n },\n mode: \"upgrade\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"POST\",\n \"/_migration/reindex\",\n {},\n {\n \"source\": {\n \"index\": \"my-data-stream\"\n },\n \"mode\": \"upgrade\"\n },\n { \"Content-Type\": \"application/json\" },\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_migration/reindex\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"source\" => [\n \"index\" => \"my-data-stream\",\n ],\n \"mode\" => \"upgrade\",\n ]),\n));\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-data-stream\"},\"mode\":\"upgrade\"}' \"$ELASTICSEARCH_URL/_migration/reindex\"" + }, + { + "language": "Java", + "code": "client.indices().migrateReindex(m -> m\n .reindex(r -> r\n .mode(ModeEnum.Upgrade)\n .source(s -> s\n .index(\"my-data-stream\")\n )\n )\n);\n" + } + ], + "specification/indices/create/examples/request/indicesCreateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.create(\n index=\"my-index-000001\",\n settings={\n \"number_of_shards\": 3,\n \"number_of_replicas\": 2\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.create({\n index: \"my-index-000001\",\n settings: {\n number_of_shards: 3,\n number_of_replicas: 2,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.create(\n index: \"my-index-000001\",\n body: {\n \"settings\": {\n \"number_of_shards\": 3,\n \"number_of_replicas\": 2\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->create([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"settings\" => [\n \"number_of_shards\" => 3,\n \"number_of_replicas\" => 2,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"number_of_shards\":3,\"number_of_replicas\":2}}' \"$ELASTICSEARCH_URL/my-index-000001\"" + }, + { + "language": "Java", + "code": "client.indices().create(c -> c\n .index(\"my-index-000001\")\n .settings(s -> s\n .numberOfShards(\"3\")\n .numberOfReplicas(\"2\")\n )\n);\n" + } + ], + "specification/indices/create/examples/request/indicesCreateRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.create(\n index=\"test\",\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"properties\": {\n \"field1\": {\n \"type\": \"text\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.create({\n index: \"test\",\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n properties: {\n field1: {\n type: \"text\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.create(\n index: \"test\",\n body: {\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n \"properties\": {\n \"field1\": {\n \"type\": \"text\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->create([\n \"index\" => \"test\",\n \"body\" => [\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"properties\" => [\n \"field1\" => [\n \"type\" => \"text\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"number_of_shards\":1},\"mappings\":{\"properties\":{\"field1\":{\"type\":\"text\"}}}}' \"$ELASTICSEARCH_URL/test\"" + }, + { + "language": "Java", + "code": "client.indices().create(c -> c\n .index(\"test\")\n .mappings(m -> m\n .properties(\"field1\", p -> p\n .text(t -> t)\n )\n )\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" + } + ], + "specification/indices/create/examples/request/indicesCreateRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.create(\n index=\"test\",\n aliases={\n \"alias_1\": {},\n \"alias_2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.create({\n index: \"test\",\n aliases: {\n alias_1: {},\n alias_2: {\n filter: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n routing: \"shard-1\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.create(\n index: \"test\",\n body: {\n \"aliases\": {\n \"alias_1\": {},\n \"alias_2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->create([\n \"index\" => \"test\",\n \"body\" => [\n \"aliases\" => [\n \"alias_1\" => new ArrayObject([]),\n \"alias_2\" => [\n \"filter\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"routing\" => \"shard-1\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"aliases\":{\"alias_1\":{},\"alias_2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"}}}' \"$ELASTICSEARCH_URL/test\"" + }, + { + "language": "Java", + "code": "client.indices().create(c -> c\n .aliases(Map.of(\"alias_2\", Alias.of(a -> a\n .filter(f -> f\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .routing(\"shard-1\")),\"alias_1\", Alias.of(al -> al)))\n .index(\"test\")\n);\n" + } + ], + "specification/indices/field_usage_stats/examples/request/indicesFieldUsageStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.field_usage_stats(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.fieldUsageStats({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.field_usage_stats(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->fieldUsageStats([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_field_usage_stats\"" + }, + { + "language": "Java", + "code": "client.indices().fieldUsageStats(f -> f\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/migrate_to_data_stream/examples/request/IndicesMigrateToDataStreamExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.migrate_to_data_stream(\n name=\"my-time-series-data\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.migrateToDataStream({\n name: \"my-time-series-data\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.migrate_to_data_stream(\n name: \"my-time-series-data\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->migrateToDataStream([\n \"name\" => \"my-time-series-data\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/_migrate/my-time-series-data\"" + }, + { + "language": "Java", + "code": "client.indices().migrateToDataStream(m -> m\n .name(\"my-time-series-data\")\n);\n" + } + ], + "specification/indices/open/examples/request/IndicesOpenExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.open(\n index=\".ds-my-data-stream-2099.03.07-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.open({\n index: \".ds-my-data-stream-2099.03.07-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.open(\n index: \".ds-my-data-stream-2099.03.07-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->open([\n \"index\" => \".ds-my-data-stream-2099.03.07-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-my-data-stream-2099.03.07-000001/_open/\"" + }, + { + "language": "Java", + "code": "client.indices().open(o -> o\n .index(\".ds-my-data-stream-2099.03.07-000001\")\n);\n" + } + ], + "specification/indices/stats/examples/request/IndicesStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.stats(\n metric=\"fielddata\",\n human=True,\n fields=\"my_join_field\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.stats({\n metric: \"fielddata\",\n human: \"true\",\n fields: \"my_join_field\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.stats(\n metric: \"fielddata\",\n human: \"true\",\n fields: \"my_join_field\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->stats([\n \"metric\" => \"fielddata\",\n \"human\" => \"true\",\n \"fields\" => \"my_join_field\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_stats/fielddata?human&fields=my_join_field#question\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/indices/segments/examples/request/IndicesSegmentsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.segments(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.segments({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.segments(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->segments([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_segments\"" + }, + { + "language": "Java", + "code": "client.indices().segments(s -> s\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.put_mapping(\n index=\"my-index-000001\",\n properties={\n \"user\": {\n \"properties\": {\n \"name\": {\n \"type\": \"keyword\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.putMapping({\n index: \"my-index-000001\",\n properties: {\n user: {\n properties: {\n name: {\n type: \"keyword\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.put_mapping(\n index: \"my-index-000001\",\n body: {\n \"properties\": {\n \"user\": {\n \"properties\": {\n \"name\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->putMapping([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"properties\" => [\n \"user\" => [\n \"properties\" => [\n \"name\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"properties\":{\"user\":{\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_mapping\"" + }, + { + "language": "Java", + "code": "client.indices().putMapping(p -> p\n .index(\"my-index-000001\")\n .properties(\"user\", pr -> pr\n .object(o -> o\n .properties(\"name\", pro -> pro\n .keyword(k -> k)\n )\n )\n )\n);\n" + } + ], + "specification/indices/resolve_cluster/examples/request/ResolveClusterRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.indices.resolve_cluster(\n name=\"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable=False,\n timeout=\"5s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.indices.resolveCluster({\n name: \"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable: \"false\",\n timeout: \"5s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.indices.resolve_cluster(\n name: \"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable: \"false\",\n timeout: \"5s\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->indices()->resolveCluster([\n \"name\" => \"not-present,clust*:my-index*,oldcluster:*\",\n \"ignore_unavailable\" => \"false\",\n \"timeout\" => \"5s\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_resolve/cluster/not-present,clust*:my-index*,oldcluster:*?ignore_unavailable=false&timeout=5s\"" + }, + { + "language": "Java", + "code": "client.indices().resolveCluster(r -> r\n .ignoreUnavailable(false)\n .name(List.of(\"not-present\",\"clust*:my-index*\",\"oldcluster:*\"))\n .timeout(t -> t\n .offset(5)\n )\n);\n" + } + ], + "specification/_global/get_source/examples/request/GetSourceRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.get_source(\n index=\"my-index-000001\",\n id=\"1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.getSource({\n index: \"my-index-000001\",\n id: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.get_source(\n index: \"my-index-000001\",\n id: \"1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->getSource([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_source/1\"" + }, + { + "language": "Java", + "code": "client.getSource(g -> g\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.get_script_languages()" + }, + { + "language": "JavaScript", + "code": "const response = await client.getScriptLanguages();" + }, + { + "language": "Ruby", + "code": "response = client.get_script_languages" + }, + { + "language": "PHP", + "code": "$resp = $client->getScriptLanguages();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_script_language\"" + }, + { + "language": "Java", + "code": "client.getScriptLanguages();\n" + } + ], + "specification/_global/update_by_query_rethrottle/examples/request/UpdateByQueryRethrottleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.update_by_query_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.updateByQueryRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.update_by_query_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->updateByQueryRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_update_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" + }, + { + "language": "Java", + "code": "client.updateByQueryRethrottle(u -> u\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" + } + ], + "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"doc['field'].value.length() <= params.max_length\",\n \"params\": {\n \"max_length\": 4\n }\n },\n context=\"filter\",\n context_setup={\n \"index\": \"my-index-000001\",\n \"document\": {\n \"field\": \"four\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"doc['field'].value.length() <= params.max_length\",\n params: {\n max_length: 4,\n },\n },\n context: \"filter\",\n context_setup: {\n index: \"my-index-000001\",\n document: {\n field: \"four\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"doc['field'].value.length() <= params.max_length\",\n \"params\": {\n \"max_length\": 4\n }\n },\n \"context\": \"filter\",\n \"context_setup\": {\n \"index\": \"my-index-000001\",\n \"document\": {\n \"field\": \"four\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"doc['field'].value.length() <= params.max_length\",\n \"params\" => [\n \"max_length\" => 4,\n ],\n ],\n \"context\" => \"filter\",\n \"context_setup\" => [\n \"index\" => \"my-index-000001\",\n \"document\" => [\n \"field\" => \"four\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"doc['\"'\"'field'\"'\"'].value.length() <= params.max_length\",\"params\":{\"max_length\":4}},\"context\":\"filter\",\"context_setup\":{\"index\":\"my-index-000001\",\"document\":{\"field\":\"four\"}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" + }, + { + "language": "Java", + "code": "client.scriptsPainlessExecute(s -> s\n .context(PainlessContext.Filter)\n .contextSetup(c -> c\n .document(JsonData.fromJson(\"{\\\"field\\\":\\\"four\\\"}\"))\n .index(\"my-index-000001\")\n )\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"doc['field'].value.length() <= params.max_length\")\n )\n .params(\"max_length\", JsonData.fromJson(\"4\"))\n )\n);\n" + } + ], + "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"doc['rank'].value / params.max_rank\",\n \"params\": {\n \"max_rank\": 5\n }\n },\n context=\"score\",\n context_setup={\n \"index\": \"my-index-000001\",\n \"document\": {\n \"rank\": 4\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"doc['rank'].value / params.max_rank\",\n params: {\n max_rank: 5,\n },\n },\n context: \"score\",\n context_setup: {\n index: \"my-index-000001\",\n document: {\n rank: 4,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"doc['rank'].value / params.max_rank\",\n \"params\": {\n \"max_rank\": 5\n }\n },\n \"context\": \"score\",\n \"context_setup\": {\n \"index\": \"my-index-000001\",\n \"document\": {\n \"rank\": 4\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"doc['rank'].value / params.max_rank\",\n \"params\" => [\n \"max_rank\" => 5,\n ],\n ],\n \"context\" => \"score\",\n \"context_setup\" => [\n \"index\" => \"my-index-000001\",\n \"document\" => [\n \"rank\" => 4,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"doc['\"'\"'rank'\"'\"'].value / params.max_rank\",\"params\":{\"max_rank\":5}},\"context\":\"score\",\"context_setup\":{\"index\":\"my-index-000001\",\"document\":{\"rank\":4}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" + }, + { + "language": "Java", + "code": "client.scriptsPainlessExecute(s -> s\n .context(PainlessContext.Score)\n .contextSetup(c -> c\n .document(JsonData.fromJson(\"{\\\"rank\\\":4}\"))\n .index(\"my-index-000001\")\n )\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"doc['rank'].value / params.max_rank\")\n )\n .params(\"max_rank\", JsonData.fromJson(\"5\"))\n )\n);\n" + } + ], + "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"params.count / params.total\",\n \"params\": {\n \"count\": 100,\n \"total\": 1000\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"params.count / params.total\",\n params: {\n count: 100,\n total: 1000,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"params.count / params.total\",\n \"params\": {\n \"count\": 100,\n \"total\": 1000\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"params.count / params.total\",\n \"params\" => [\n \"count\" => 100,\n \"total\" => 1000,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"params.count / params.total\",\"params\":{\"count\":100,\"total\":1000}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" + }, + { + "language": "Java", + "code": "client.scriptsPainlessExecute(s -> s\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"params.count / params.total\")\n )\n .params(Map.of(\"total\", JsonData.fromJson(\"1000\"),\"count\", JsonData.fromJson(\"100\")))\n )\n);\n" + } + ], + "specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.get_script_context()" + }, + { + "language": "JavaScript", + "code": "const response = await client.getScriptContext();" + }, + { + "language": "Ruby", + "code": "response = client.get_script_context" + }, + { + "language": "PHP", + "code": "$resp = $client->getScriptContext();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_script_context\"" + }, + { + "language": "Java", + "code": "client.getScriptContext();\n" + } + ], + "specification/_global/msearch_template/examples/request/MultiSearchTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.msearch_template(\n index=\"my-index\",\n search_templates=[\n {},\n {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n },\n {},\n {\n \"id\": \"my-other-search-template\",\n \"params\": {\n \"query_type\": \"match_all\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.msearchTemplate({\n index: \"my-index\",\n search_templates: [\n {},\n {\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 0,\n size: 10,\n },\n },\n {},\n {\n id: \"my-other-search-template\",\n params: {\n query_type: \"match_all\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.msearch_template(\n index: \"my-index\",\n body: [\n {},\n {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n },\n {},\n {\n \"id\": \"my-other-search-template\",\n \"params\": {\n \"query_type\": \"match_all\"\n }\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->msearchTemplate([\n \"index\" => \"my-index\",\n \"body\" => array(\n new ArrayObject([]),\n [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 0,\n \"size\" => 10,\n ],\n ],\n new ArrayObject([]),\n [\n \"id\" => \"my-other-search-template\",\n \"params\" => [\n \"query_type\" => \"match_all\",\n ],\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{},{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":0,\"size\":10}},{},{\"id\":\"my-other-search-template\",\"params\":{\"query_type\":\"match_all\"}}]' \"$ELASTICSEARCH_URL/my-index/_msearch/template\"" + } + ], + "specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.terms_enum(\n index=\"stackoverflow\",\n field=\"tags\",\n string=\"kiba\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termsEnum({\n index: \"stackoverflow\",\n field: \"tags\",\n string: \"kiba\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.terms_enum(\n index: \"stackoverflow\",\n body: {\n \"field\": \"tags\",\n \"string\": \"kiba\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termsEnum([\n \"index\" => \"stackoverflow\",\n \"body\" => [\n \"field\" => \"tags\",\n \"string\" => \"kiba\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"field\":\"tags\",\"string\":\"kiba\"}' \"$ELASTICSEARCH_URL/stackoverflow/_terms_enum\"" + }, + { + "language": "Java", + "code": "client.termsEnum(t -> t\n .field(\"tags\")\n .index(\"stackoverflow\")\n .string(\"kiba\")\n);\n" + } + ], + "specification/_global/bulk/examples/request/BulkRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.bulk(\n operations=[\n {\n \"index\": {\n \"_index\": \"my_index\",\n \"_id\": \"1\",\n \"dynamic_templates\": {\n \"work_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value1\",\n \"work_location\": \"41.12,-71.34\",\n \"raw_location\": \"41.12,-71.34\"\n },\n {\n \"create\": {\n \"_index\": \"my_index\",\n \"_id\": \"2\",\n \"dynamic_templates\": {\n \"home_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value2\",\n \"home_location\": \"41.12,-71.34\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.bulk({\n operations: [\n {\n index: {\n _index: \"my_index\",\n _id: \"1\",\n dynamic_templates: {\n work_location: \"geo_point\",\n },\n },\n },\n {\n field: \"value1\",\n work_location: \"41.12,-71.34\",\n raw_location: \"41.12,-71.34\",\n },\n {\n create: {\n _index: \"my_index\",\n _id: \"2\",\n dynamic_templates: {\n home_location: \"geo_point\",\n },\n },\n },\n {\n field: \"value2\",\n home_location: \"41.12,-71.34\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.bulk(\n body: [\n {\n \"index\": {\n \"_index\": \"my_index\",\n \"_id\": \"1\",\n \"dynamic_templates\": {\n \"work_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value1\",\n \"work_location\": \"41.12,-71.34\",\n \"raw_location\": \"41.12,-71.34\"\n },\n {\n \"create\": {\n \"_index\": \"my_index\",\n \"_id\": \"2\",\n \"dynamic_templates\": {\n \"home_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value2\",\n \"home_location\": \"41.12,-71.34\"\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"index\" => [\n \"_index\" => \"my_index\",\n \"_id\" => \"1\",\n \"dynamic_templates\" => [\n \"work_location\" => \"geo_point\",\n ],\n ],\n ],\n [\n \"field\" => \"value1\",\n \"work_location\" => \"41.12,-71.34\",\n \"raw_location\" => \"41.12,-71.34\",\n ],\n [\n \"create\" => [\n \"_index\" => \"my_index\",\n \"_id\" => \"2\",\n \"dynamic_templates\" => [\n \"home_location\" => \"geo_point\",\n ],\n ],\n ],\n [\n \"field\" => \"value2\",\n \"home_location\" => \"41.12,-71.34\",\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"index\":{\"_index\":\"my_index\",\"_id\":\"1\",\"dynamic_templates\":{\"work_location\":\"geo_point\"}}},{\"field\":\"value1\",\"work_location\":\"41.12,-71.34\",\"raw_location\":\"41.12,-71.34\"},{\"create\":{\"_index\":\"my_index\",\"_id\":\"2\",\"dynamic_templates\":{\"home_location\":\"geo_point\"}}},{\"field\":\"value2\",\"home_location\":\"41.12,-71.34\"}]' \"$ELASTICSEARCH_URL/_bulk\"" + } + ], + "specification/_global/bulk/examples/request/BulkRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.bulk(\n operations=[\n {\n \"update\": {\n \"_id\": \"5\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"update\": {\n \"_id\": \"6\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"create\": {\n \"_id\": \"7\",\n \"_index\": \"index1\"\n }\n },\n {\n \"my_field\": \"foo\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.bulk({\n operations: [\n {\n update: {\n _id: \"5\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n my_field: \"foo\",\n },\n },\n {\n update: {\n _id: \"6\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n my_field: \"foo\",\n },\n },\n {\n create: {\n _id: \"7\",\n _index: \"index1\",\n },\n },\n {\n my_field: \"foo\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.bulk(\n body: [\n {\n \"update\": {\n \"_id\": \"5\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"update\": {\n \"_id\": \"6\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"create\": {\n \"_id\": \"7\",\n \"_index\": \"index1\"\n }\n },\n {\n \"my_field\": \"foo\"\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"update\" => [\n \"_id\" => \"5\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"my_field\" => \"foo\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"6\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"my_field\" => \"foo\",\n ],\n ],\n [\n \"create\" => [\n \"_id\" => \"7\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"my_field\" => \"foo\",\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"update\":{\"_id\":\"5\",\"_index\":\"index1\"}},{\"doc\":{\"my_field\":\"foo\"}},{\"update\":{\"_id\":\"6\",\"_index\":\"index1\"}},{\"doc\":{\"my_field\":\"foo\"}},{\"create\":{\"_id\":\"7\",\"_index\":\"index1\"}},{\"my_field\":\"foo\"}]' \"$ELASTICSEARCH_URL/_bulk\"" + } + ], + "specification/_global/bulk/examples/request/BulkRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.bulk(\n operations=[\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"0\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"script\": {\n \"source\": \"ctx._source.counter += params.param1\",\n \"lang\": \"painless\",\n \"params\": {\n \"param1\": 1\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n },\n {\n \"update\": {\n \"_id\": \"2\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"doc_as_upsert\": True\n },\n {\n \"update\": {\n \"_id\": \"3\",\n \"_index\": \"index1\",\n \"_source\": True\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"4\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"_source\": True\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.bulk({\n operations: [\n {\n update: {\n _id: \"1\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n },\n {\n update: {\n _id: \"0\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n script: {\n source: \"ctx._source.counter += params.param1\",\n lang: \"painless\",\n params: {\n param1: 1,\n },\n },\n upsert: {\n counter: 1,\n },\n },\n {\n update: {\n _id: \"2\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n doc_as_upsert: true,\n },\n {\n update: {\n _id: \"3\",\n _index: \"index1\",\n _source: true,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n },\n {\n update: {\n _id: \"4\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n field: \"value\",\n },\n _source: true,\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.bulk(\n body: [\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"0\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"script\": {\n \"source\": \"ctx._source.counter += params.param1\",\n \"lang\": \"painless\",\n \"params\": {\n \"param1\": 1\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n },\n {\n \"update\": {\n \"_id\": \"2\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"doc_as_upsert\": true\n },\n {\n \"update\": {\n \"_id\": \"3\",\n \"_index\": \"index1\",\n \"_source\": true\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"4\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"_source\": true\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"update\" => [\n \"_id\" => \"1\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"0\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.param1\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"param1\" => 1,\n ],\n ],\n \"upsert\" => [\n \"counter\" => 1,\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"2\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n \"doc_as_upsert\" => true,\n ],\n [\n \"update\" => [\n \"_id\" => \"3\",\n \"_index\" => \"index1\",\n \"_source\" => true,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"4\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n \"_source\" => true,\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"update\":{\"_id\":\"1\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"doc\":{\"field\":\"value\"}},{\"update\":{\"_id\":\"0\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"script\":{\"source\":\"ctx._source.counter += params.param1\",\"lang\":\"painless\",\"params\":{\"param1\":1}},\"upsert\":{\"counter\":1}},{\"update\":{\"_id\":\"2\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"doc\":{\"field\":\"value\"},\"doc_as_upsert\":true},{\"update\":{\"_id\":\"3\",\"_index\":\"index1\",\"_source\":true}},{\"doc\":{\"field\":\"value\"}},{\"update\":{\"_id\":\"4\",\"_index\":\"index1\"}},{\"doc\":{\"field\":\"value\"},\"_source\":true}]' \"$ELASTICSEARCH_URL/_bulk\"" + } + ], + "specification/_global/bulk/examples/request/BulkRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.bulk(\n operations=[\n {\n \"index\": {\n \"_index\": \"test\",\n \"_id\": \"1\"\n }\n },\n {\n \"field1\": \"value1\"\n },\n {\n \"delete\": {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n },\n {\n \"create\": {\n \"_index\": \"test\",\n \"_id\": \"3\"\n }\n },\n {\n \"field1\": \"value3\"\n },\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"test\"\n }\n },\n {\n \"doc\": {\n \"field2\": \"value2\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.bulk({\n operations: [\n {\n index: {\n _index: \"test\",\n _id: \"1\",\n },\n },\n {\n field1: \"value1\",\n },\n {\n delete: {\n _index: \"test\",\n _id: \"2\",\n },\n },\n {\n create: {\n _index: \"test\",\n _id: \"3\",\n },\n },\n {\n field1: \"value3\",\n },\n {\n update: {\n _id: \"1\",\n _index: \"test\",\n },\n },\n {\n doc: {\n field2: \"value2\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.bulk(\n body: [\n {\n \"index\": {\n \"_index\": \"test\",\n \"_id\": \"1\"\n }\n },\n {\n \"field1\": \"value1\"\n },\n {\n \"delete\": {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n },\n {\n \"create\": {\n \"_index\": \"test\",\n \"_id\": \"3\"\n }\n },\n {\n \"field1\": \"value3\"\n },\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"test\"\n }\n },\n {\n \"doc\": {\n \"field2\": \"value2\"\n }\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"index\" => [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n ],\n ],\n [\n \"field1\" => \"value1\",\n ],\n [\n \"delete\" => [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n ],\n ],\n [\n \"create\" => [\n \"_index\" => \"test\",\n \"_id\" => \"3\",\n ],\n ],\n [\n \"field1\" => \"value3\",\n ],\n [\n \"update\" => [\n \"_id\" => \"1\",\n \"_index\" => \"test\",\n ],\n ],\n [\n \"doc\" => [\n \"field2\" => \"value2\",\n ],\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"index\":{\"_index\":\"test\",\"_id\":\"1\"}},{\"field1\":\"value1\"},{\"delete\":{\"_index\":\"test\",\"_id\":\"2\"}},{\"create\":{\"_index\":\"test\",\"_id\":\"3\"}},{\"field1\":\"value3\"},{\"update\":{\"_id\":\"1\",\"_index\":\"test\"}},{\"doc\":{\"field2\":\"value2\"}}]' \"$ELASTICSEARCH_URL/_bulk\"" + } + ], + "specification/_global/explain/examples/request/ExplainRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.explain(\n index=\"my-index-000001\",\n id=\"0\",\n query={\n \"match\": {\n \"message\": \"elasticsearch\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.explain({\n index: \"my-index-000001\",\n id: 0,\n query: {\n match: {\n message: \"elasticsearch\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.explain(\n index: \"my-index-000001\",\n id: \"0\",\n body: {\n \"query\": {\n \"match\": {\n \"message\": \"elasticsearch\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->explain([\n \"index\" => \"my-index-000001\",\n \"id\" => \"0\",\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"elasticsearch\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"message\":\"elasticsearch\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_explain/0\"" + }, + { + "language": "Java", + "code": "client.explain(e -> e\n .id(\"0\")\n .index(\"my-index-000001\")\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"elasticsearch\"))\n )\n )\n);\n" + } + ], + "specification/_global/get_script/examples/request/GetScriptRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.get_script(\n id=\"my-search-template\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.getScript({\n id: \"my-search-template\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.get_script(\n id: \"my-search-template\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->getScript([\n \"id\" => \"my-search-template\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" + }, + { + "language": "Java", + "code": "client.getScript(g -> g\n .id(\"my-search-template\")\n);\n" + } + ], + "specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_template(\n index=\"my-index\",\n id=\"my-search-template\",\n params={\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchTemplate({\n index: \"my-index\",\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 0,\n size: 10,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_template(\n index: \"my-index\",\n body: {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchTemplate([\n \"index\" => \"my-index\",\n \"body\" => [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 0,\n \"size\" => 10,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":0,\"size\":10}}' \"$ELASTICSEARCH_URL/my-index/_search/template\"" + }, + { + "language": "Java", + "code": "client.searchTemplate(s -> s\n .id(\"my-search-template\")\n .index(\"my-index\")\n .params(Map.of(\"size\", JsonData.fromJson(\"10\"),\"from\", JsonData.fromJson(\"0\"),\"query_string\", JsonData.fromJson(\"\\\"hello world\\\"\")))\n);\n" + } + ], + "specification/_global/scroll/examples/request/ScrollRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.scroll(\n scroll_id=\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.scroll({\n scroll_id: \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.scroll(\n body: {\n \"scroll_id\": \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->scroll([\n \"body\" => [\n \"scroll_id\" => \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scroll_id\":\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"}' \"$ELASTICSEARCH_URL/_search/scroll\"" + }, + { + "language": "Java", + "code": "client.scroll(s -> s\n .scrollId(\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\")\n);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample7.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"green\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source:\n \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n lang: \"painless\",\n params: {\n tag: \"green\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"green\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"green\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"if (ctx._source.tags.contains(params.tag)) { ctx.op = '\"'\"'delete'\"'\"' } else { ctx.op = '\"'\"'noop'\"'\"' }\",\"lang\":\"painless\",\"params\":{\"tag\":\"green\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"green\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source['my-object'].remove('my-subfield')\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source['my-object'].remove('my-subfield')\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source['my-object'].remove('my-subfield')\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source['my-object'].remove('my-subfield')\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source['\"'\"'my-object'\"'\"'].remove('\"'\"'my-subfield'\"'\"')\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['my-object'].remove('my-subfield')\")\n )\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.counter += params.count\",\n lang: \"painless\",\n params: {\n count: 4,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.count\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.counter += params.count\",\"lang\":\"painless\",\"params\":{\"count\":4}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.counter += params.count\")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n .lang(\"painless\")\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source:\n \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n lang: \"painless\",\n params: {\n tag: \"blue\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"blue\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\"lang\":\"painless\",\"params\":{\"tag\":\"blue\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"blue\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.tags.add(params.tag)\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.tags.add(params.tag)\",\n lang: \"painless\",\n params: {\n tag: \"blue\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.tags.add(params.tag)\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.tags.add(params.tag)\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"blue\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.tags.add(params.tag)\",\"lang\":\"painless\",\"params\":{\"tag\":\"blue\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.tags.add(params.tag)\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"blue\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source.remove('new_field')\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source.remove('new_field')\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source.remove('new_field')\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source.remove('new_field')\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source.remove('\"'\"'new_field'\"'\"')\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.remove('new_field')\")\n )\n )\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample10.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n scripted_upsert=True,\n script={\n \"source\": \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\": {\n \"count\": 4\n }\n },\n upsert={},\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n scripted_upsert: true,\n script: {\n source:\n \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n params: {\n count: 4,\n },\n },\n upsert: {},\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"scripted_upsert\": true,\n \"script\": {\n \"source\": \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\": {\n \"count\": 4\n }\n },\n \"upsert\": {}\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"scripted_upsert\" => true,\n \"script\" => [\n \"source\" => \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n \"upsert\" => new ArrayObject([]),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scripted_upsert\":true,\"script\":{\"source\":\"\\n if ( ctx.op == '\"'\"'create'\"'\"' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\"params\":{\"count\":4}},\"upsert\":{}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"\n if ( ctx.op == 'create' ) {\n ctx._source.counter = params.count\n } else {\n ctx._source.counter += params.count\n }\n \")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n )\n .scriptedUpsert(true)\n .upsert(JsonData.fromJson(\"{}\"))\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample9.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n upsert={\n \"counter\": 1\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.counter += params.count\",\n lang: \"painless\",\n params: {\n count: 4,\n },\n },\n upsert: {\n counter: 1,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.count\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n \"upsert\" => [\n \"counter\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.counter += params.count\",\"lang\":\"painless\",\"params\":{\"count\":4}},\"upsert\":{\"counter\":1}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.counter += params.count\")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n .lang(\"painless\")\n )\n .upsert(JsonData.fromJson(\"{\\\"counter\\\":1}\"))\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample8.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n doc={\n \"name\": \"new_name\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n doc: {\n name: \"new_name\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"doc\": {\n \"name\": \"new_name\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"doc\" => [\n \"name\" => \"new_name\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"name\":\"new_name\"}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .doc(JsonData.fromJson(\"{\\\"name\\\":\\\"new_name\\\"}\"))\n .id(\"1\")\n .index(\"test\")\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample11.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n doc={\n \"name\": \"new_name\"\n },\n doc_as_upsert=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n doc: {\n name: \"new_name\",\n },\n doc_as_upsert: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"doc\": {\n \"name\": \"new_name\"\n },\n \"doc_as_upsert\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"doc\" => [\n \"name\" => \"new_name\",\n ],\n \"doc_as_upsert\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"name\":\"new_name\"},\"doc_as_upsert\":true}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .doc(JsonData.fromJson(\"{\\\"name\\\":\\\"new_name\\\"}\"))\n .docAsUpsert(true)\n .id(\"1\")\n .index(\"test\")\n,Void.class);\n" + } + ], + "specification/_global/update/examples/request/UpdateRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source.new_field = 'value_of_new_field'\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source.new_field = 'value_of_new_field'\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source.new_field = 'value_of_new_field'\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source.new_field = 'value_of_new_field'\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source.new_field = '\"'\"'value_of_new_field'\"'\"'\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" + }, + { + "language": "Java", + "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.new_field = 'value_of_new_field'\")\n )\n )\n,Void.class);\n" + } + ], + "specification/_global/delete/examples/request/DeleteRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.delete(\n index=\"my-index-000001\",\n id=\"1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.delete({\n index: \"my-index-000001\",\n id: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete(\n index: \"my-index-000001\",\n id: \"1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->delete([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/1\"" + }, + { + "language": "Java", + "code": "client.delete(d -> d\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n refresh=True,\n slices=\"5\",\n script={\n \"source\": \"ctx._source['extra'] = 'test'\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: 5,\n script: {\n source: \"ctx._source['extra'] = 'test'\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: \"5\",\n body: {\n \"script\": {\n \"source\": \"ctx._source['extra'] = 'test'\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"refresh\" => \"true\",\n \"slices\" => \"5\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source['extra'] = 'test'\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source['\"'\"'extra'\"'\"'] = '\"'\"'test'\"'\"'\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query?refresh&slices=5\"" + }, + { + "language": "Java", + "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .refresh(true)\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['extra'] = 'test'\")\n )\n )\n .slices(sl -> sl\n .value(5)\n )\n);\n" + } + ], + "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n script={\n \"source\": \"ctx._source.count++\",\n \"lang\": \"painless\"\n },\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n script: {\n source: \"ctx._source.count++\",\n lang: \"painless\",\n },\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.count++\",\n \"lang\": \"painless\"\n },\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.count++\",\n \"lang\" => \"painless\",\n ],\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.count++\",\"lang\":\"painless\"},\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query\"" + }, + { + "language": "Java", + "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.count++\")\n )\n .lang(\"painless\")\n )\n);\n" + } + ], + "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n slice={\n \"id\": 0,\n \"max\": 2\n },\n script={\n \"source\": \"ctx._source['extra'] = 'test'\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n script: {\n source: \"ctx._source['extra'] = 'test'\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"script\": {\n \"source\": \"ctx._source['extra'] = 'test'\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"script\" => [\n \"source\" => \"ctx._source['extra'] = 'test'\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"script\":{\"source\":\"ctx._source['\"'\"'extra'\"'\"'] = '\"'\"'test'\"'\"'\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query\"" + }, + { + "language": "Java", + "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['extra'] = 'test'\")\n )\n )\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n);\n" + } + ], + "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n conflicts=\"proceed\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n conflicts: \"proceed\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n conflicts: \"proceed\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"conflicts\" => \"proceed\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query?conflicts=proceed\"" + }, + { + "language": "Java", + "code": "client.updateByQuery(u -> u\n .conflicts(Conflicts.Proceed)\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" + } + ], + "specification/_global/exists/examples/request/DocumentExistsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.exists(\n index=\"my-index-000001\",\n id=\"0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.exists({\n index: \"my-index-000001\",\n id: 0,\n});" + }, + { + "language": "Ruby", + "code": "response = client.exists(\n index: \"my-index-000001\",\n id: \"0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->exists([\n \"index\" => \"my-index-000001\",\n \"id\" => \"0\",\n]);" + }, + { + "language": "curl", + "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/0\"" + }, + { + "language": "Java", + "code": "client.exists(e -> e\n .id(\"0\")\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/put_script/examples/request/PutScriptRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.put_script(\n id=\"my-search-template\",\n script={\n \"lang\": \"mustache\",\n \"source\": {\n \"query\": {\n \"match\": {\n \"message\": \"{{query_string}}\"\n }\n },\n \"from\": \"{{from}}\",\n \"size\": \"{{size}}\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.putScript({\n id: \"my-search-template\",\n script: {\n lang: \"mustache\",\n source: {\n query: {\n match: {\n message: \"{{query_string}}\",\n },\n },\n from: \"{{from}}\",\n size: \"{{size}}\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.put_script(\n id: \"my-search-template\",\n body: {\n \"script\": {\n \"lang\": \"mustache\",\n \"source\": {\n \"query\": {\n \"match\": {\n \"message\": \"{{query_string}}\"\n }\n },\n \"from\": \"{{from}}\",\n \"size\": \"{{size}}\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->putScript([\n \"id\" => \"my-search-template\",\n \"body\" => [\n \"script\" => [\n \"lang\" => \"mustache\",\n \"source\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"{{query_string}}\",\n ],\n ],\n \"from\" => \"{{from}}\",\n \"size\" => \"{{size}}\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"lang\":\"mustache\",\"source\":{\"query\":{\"match\":{\"message\":\"{{query_string}}\"}},\"from\":\"{{from}}\",\"size\":\"{{size}}\"}}}' \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" + } + ], + "specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.put_script(\n id=\"my-stored-script\",\n script={\n \"lang\": \"painless\",\n \"source\": \"Math.log(_score * 2) + params['my_modifier']\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.putScript({\n id: \"my-stored-script\",\n script: {\n lang: \"painless\",\n source: \"Math.log(_score * 2) + params['my_modifier']\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.put_script(\n id: \"my-stored-script\",\n body: {\n \"script\": {\n \"lang\": \"painless\",\n \"source\": \"Math.log(_score * 2) + params['my_modifier']\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->putScript([\n \"id\" => \"my-stored-script\",\n \"body\" => [\n \"script\" => [\n \"lang\" => \"painless\",\n \"source\" => \"Math.log(_score * 2) + params['my_modifier']\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"lang\":\"painless\",\"source\":\"Math.log(_score * 2) + params['\"'\"'my_modifier'\"'\"']\"}}' \"$ELASTICSEARCH_URL/_scripts/my-stored-script\"" + }, + { + "language": "Java", + "code": "client.putScript(p -> p\n .id(\"my-stored-script\")\n .script(s -> s\n .lang(\"painless\")\n .source(so -> so\n .scriptString(\"Math.log(_score * 2) + params['my_modifier']\")\n )\n )\n);\n" + } + ], + "specification/_global/reindex_rethrottle/examples/request/ReindexRethrottleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindexRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindexRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" + }, + { + "language": "Java", + "code": "client.reindexRethrottle(r -> r\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" + } + ], + "specification/_global/count/examples/request/CountRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.count(\n index=\"my-index-000001\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.count({\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.count(\n index: \"my-index-000001\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->count([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_count\"" + }, + { + "language": "Java", + "code": "client.count(c -> c\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" + } + ], + "specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.termvectors(\n index=\"imdb\",\n doc={\n \"plot\": \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"\n },\n term_statistics=True,\n field_statistics=True,\n positions=False,\n offsets=False,\n filter={\n \"max_num_terms\": 3,\n \"min_term_freq\": 1,\n \"min_doc_freq\": 1\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termvectors({\n index: \"imdb\",\n doc: {\n plot: \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\",\n },\n term_statistics: true,\n field_statistics: true,\n positions: false,\n offsets: false,\n filter: {\n max_num_terms: 3,\n min_term_freq: 1,\n min_doc_freq: 1,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.termvectors(\n index: \"imdb\",\n body: {\n \"doc\": {\n \"plot\": \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"\n },\n \"term_statistics\": true,\n \"field_statistics\": true,\n \"positions\": false,\n \"offsets\": false,\n \"filter\": {\n \"max_num_terms\": 3,\n \"min_term_freq\": 1,\n \"min_doc_freq\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termvectors([\n \"index\" => \"imdb\",\n \"body\" => [\n \"doc\" => [\n \"plot\" => \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\",\n ],\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n \"positions\" => false,\n \"offsets\" => false,\n \"filter\" => [\n \"max_num_terms\" => 3,\n \"min_term_freq\" => 1,\n \"min_doc_freq\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"plot\":\"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"},\"term_statistics\":true,\"field_statistics\":true,\"positions\":false,\"offsets\":false,\"filter\":{\"max_num_terms\":3,\"min_term_freq\":1,\"min_doc_freq\":1}}' \"$ELASTICSEARCH_URL/imdb/_termvectors\"" + }, + { + "language": "Java", + "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"plot\\\":\\\"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\\\"}\"))\n .fieldStatistics(true)\n .filter(f -> f\n .maxNumTerms(3)\n .minDocFreq(1)\n .minTermFreq(1)\n )\n .index(\"imdb\")\n .offsets(false)\n .positions(false)\n .termStatistics(true)\n);\n" + } + ], + "specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n doc={\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n fields=[\n \"fullname\"\n ],\n per_field_analyzer={\n \"fullname\": \"keyword\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n doc: {\n fullname: \"John Doe\",\n text: \"test test test\",\n },\n fields: [\"fullname\"],\n per_field_analyzer: {\n fullname: \"keyword\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.termvectors(\n index: \"my-index-000001\",\n body: {\n \"doc\": {\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n \"fields\": [\n \"fullname\"\n ],\n \"per_field_analyzer\": {\n \"fullname\": \"keyword\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"doc\" => [\n \"fullname\" => \"John Doe\",\n \"text\" => \"test test test\",\n ],\n \"fields\" => array(\n \"fullname\",\n ),\n \"per_field_analyzer\" => [\n \"fullname\" => \"keyword\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"fullname\":\"John Doe\",\"text\":\"test test test\"},\"fields\":[\"fullname\"],\"per_field_analyzer\":{\"fullname\":\"keyword\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors\"" + }, + { + "language": "Java", + "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"fullname\\\":\\\"John Doe\\\",\\\"text\\\":\\\"test test test\\\"}\"))\n .fields(\"fullname\")\n .index(\"my-index-000001\")\n .perFieldAnalyzer(\"fullname\", \"keyword\")\n);\n" + } + ], + "specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n doc={\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n doc: {\n fullname: \"John Doe\",\n text: \"test test test\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.termvectors(\n index: \"my-index-000001\",\n body: {\n \"doc\": {\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"doc\" => [\n \"fullname\" => \"John Doe\",\n \"text\" => \"test test test\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"fullname\":\"John Doe\",\"text\":\"test test test\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors\"" + }, + { + "language": "Java", + "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"fullname\\\":\\\"John Doe\\\",\\\"text\\\":\\\"test test test\\\"}\"))\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n id=\"1\",\n fields=[\n \"text\",\n \"some_field_without_term_vectors\"\n ],\n offsets=True,\n positions=True,\n term_statistics=True,\n field_statistics=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n id: 1,\n fields: [\"text\", \"some_field_without_term_vectors\"],\n offsets: true,\n positions: true,\n term_statistics: true,\n field_statistics: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.termvectors(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"fields\": [\n \"text\",\n \"some_field_without_term_vectors\"\n ],\n \"offsets\": true,\n \"positions\": true,\n \"term_statistics\": true,\n \"field_statistics\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"fields\" => array(\n \"text\",\n \"some_field_without_term_vectors\",\n ),\n \"offsets\" => true,\n \"positions\" => true,\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\",\"some_field_without_term_vectors\"],\"offsets\":true,\"positions\":true,\"term_statistics\":true,\"field_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" + }, + { + "language": "Java", + "code": "client.termvectors(t -> t\n .fieldStatistics(true)\n .fields(List.of(\"text\",\"some_field_without_term_vectors\"))\n .id(\"1\")\n .index(\"my-index-000001\")\n .offsets(true)\n .positions(true)\n .termStatistics(true)\n);\n" + } + ], + "specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n id=\"1\",\n fields=[\n \"text\"\n ],\n offsets=True,\n payloads=True,\n positions=True,\n term_statistics=True,\n field_statistics=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n id: 1,\n fields: [\"text\"],\n offsets: true,\n payloads: true,\n positions: true,\n term_statistics: true,\n field_statistics: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.termvectors(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"fields\": [\n \"text\"\n ],\n \"offsets\": true,\n \"payloads\": true,\n \"positions\": true,\n \"term_statistics\": true,\n \"field_statistics\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"fields\" => array(\n \"text\",\n ),\n \"offsets\" => true,\n \"payloads\" => true,\n \"positions\" => true,\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\"],\"offsets\":true,\"payloads\":true,\"positions\":true,\"term_statistics\":true,\"field_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" + }, + { + "language": "Java", + "code": "client.termvectors(t -> t\n .fieldStatistics(true)\n .fields(\"text\")\n .id(\"1\")\n .index(\"my-index-000001\")\n .offsets(true)\n .payloads(true)\n .positions(true)\n .termStatistics(true)\n);\n" + } + ], + "specification/_global/search_mvt/examples/request/SearchMvtRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_mvt(\n index=\"museums\",\n field=\"location\",\n zoom=\"13\",\n x=\"4207\",\n y=\"2692\",\n grid_agg=\"geotile\",\n grid_precision=2,\n fields=[\n \"name\",\n \"price\"\n ],\n query={\n \"term\": {\n \"included\": True\n }\n },\n aggs={\n \"min_price\": {\n \"min\": {\n \"field\": \"price\"\n }\n },\n \"max_price\": {\n \"max\": {\n \"field\": \"price\"\n }\n },\n \"avg_price\": {\n \"avg\": {\n \"field\": \"price\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchMvt({\n index: \"museums\",\n field: \"location\",\n zoom: 13,\n x: 4207,\n y: 2692,\n grid_agg: \"geotile\",\n grid_precision: 2,\n fields: [\"name\", \"price\"],\n query: {\n term: {\n included: true,\n },\n },\n aggs: {\n min_price: {\n min: {\n field: \"price\",\n },\n },\n max_price: {\n max: {\n field: \"price\",\n },\n },\n avg_price: {\n avg: {\n field: \"price\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_mvt(\n index: \"museums\",\n field: \"location\",\n zoom: \"13\",\n x: \"4207\",\n y: \"2692\",\n body: {\n \"grid_agg\": \"geotile\",\n \"grid_precision\": 2,\n \"fields\": [\n \"name\",\n \"price\"\n ],\n \"query\": {\n \"term\": {\n \"included\": true\n }\n },\n \"aggs\": {\n \"min_price\": {\n \"min\": {\n \"field\": \"price\"\n }\n },\n \"max_price\": {\n \"max\": {\n \"field\": \"price\"\n }\n },\n \"avg_price\": {\n \"avg\": {\n \"field\": \"price\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchMvt([\n \"index\" => \"museums\",\n \"field\" => \"location\",\n \"zoom\" => \"13\",\n \"x\" => \"4207\",\n \"y\" => \"2692\",\n \"body\" => [\n \"grid_agg\" => \"geotile\",\n \"grid_precision\" => 2,\n \"fields\" => array(\n \"name\",\n \"price\",\n ),\n \"query\" => [\n \"term\" => [\n \"included\" => true,\n ],\n ],\n \"aggs\" => [\n \"min_price\" => [\n \"min\" => [\n \"field\" => \"price\",\n ],\n ],\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"price\",\n ],\n ],\n \"avg_price\" => [\n \"avg\" => [\n \"field\" => \"price\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "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\"" + } + ], + "specification/_global/delete_by_query_rethrottle/examples/request/DeleteByQueryRethrottleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_by_query_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteByQueryRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_by_query_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteByQueryRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_delete_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" + }, + { + "language": "Java", + "code": "client.deleteByQueryRethrottle(d -> d\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" + } + ], + "specification/_global/get/examples/request/GetRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.get(\n index=\"my-index-000001\",\n id=\"1\",\n stored_fields=\"tags,counter\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.get({\n index: \"my-index-000001\",\n id: 1,\n stored_fields: \"tags,counter\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.get(\n index: \"my-index-000001\",\n id: \"1\",\n stored_fields: \"tags,counter\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->get([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"stored_fields\" => \"tags,counter\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/1?stored_fields=tags,counter\"" + } + ], + "specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.render_search_template(\n id=\"my-search-template\",\n params={\n \"query_string\": \"hello world\",\n \"from\": 20,\n \"size\": 10\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.renderSearchTemplate({\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 20,\n size: 10,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.render_search_template(\n body: {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 20,\n \"size\": 10\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->renderSearchTemplate([\n \"body\" => [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 20,\n \"size\" => 10,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":20,\"size\":10}}' \"$ELASTICSEARCH_URL/_render/template\"" + }, + { + "language": "Java", + "code": "client.renderSearchTemplate(r -> r\n .id(\"my-search-template\")\n .params(Map.of(\"size\", JsonData.fromJson(\"10\"),\"from\", JsonData.fromJson(\"20\"),\"query_string\", JsonData.fromJson(\"\\\"hello world\\\"\")))\n);\n" + } + ], + "specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.open_point_in_time(\n index=\"my-index-000001\",\n keep_alive=\"1m\",\n allow_partial_search_results=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.openPointInTime({\n index: \"my-index-000001\",\n keep_alive: \"1m\",\n allow_partial_search_results: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.open_point_in_time(\n index: \"my-index-000001\",\n keep_alive: \"1m\",\n allow_partial_search_results: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->openPointInTime([\n \"index\" => \"my-index-000001\",\n \"keep_alive\" => \"1m\",\n \"allow_partial_search_results\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_pit?keep_alive=1m&allow_partial_search_results=true\"" + }, + { + "language": "Java", + "code": "client.openPointInTime(o -> o\n .allowPartialSearchResults(true)\n .index(\"my-index-000001\")\n .keepAlive(k -> k\n .offset(1)\n )\n);\n" + } + ], + "specification/_global/search_shards/examples/request/SearchShardsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_shards(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchShards({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_shards(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchShards([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_search_shards\"" + }, + { + "language": "Java", + "code": "client.searchShards(s -> s\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_by_query(\n index=\"my-index-000001,my-index-000002\",\n query={\n \"match_all\": {}\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001,my-index-000002\",\n query: {\n match_all: {},\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_by_query(\n index: \"my-index-000001,my-index-000002\",\n body: {\n \"query\": {\n \"match_all\": {}\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001,my-index-000002\",\n \"body\" => [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match_all\":{}}}' \"$ELASTICSEARCH_URL/my-index-000001,my-index-000002/_delete_by_query\"" + }, + { + "language": "Java", + "code": "client.deleteByQuery(d -> d\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n .query(q -> q\n .matchAll(m -> m)\n )\n);\n" + } + ], + "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n max_docs=1,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n max_docs: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"max_docs\": 1\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"max_docs\" => 1,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}},\"max_docs\":1}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query\"" + }, + { + "language": "Java", + "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .maxDocs(1L)\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" + } + ], + "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n slice={\n \"id\": 0,\n \"max\": 2\n },\n query={\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n query: {\n range: {\n \"http.response.bytes\": {\n lt: 2000000,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"query\": {\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"query\" => [\n \"range\" => [\n \"http.response.bytes\" => [\n \"lt\" => 2000000,\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"query\":{\"range\":{\"http.response.bytes\":{\"lt\":2000000}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query\"" + }, + { + "language": "Java", + "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"http.response.bytes\")\n .lt(JsonData.fromJson(\"2000000\"))\n )\n )\n )\n .slice(s -> s\n .id(\"0\")\n .max(2)\n )\n);\n" + } + ], + "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n refresh=True,\n slices=\"5\",\n query={\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: 5,\n query: {\n range: {\n \"http.response.bytes\": {\n lt: 2000000,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: \"5\",\n body: {\n \"query\": {\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"refresh\" => \"true\",\n \"slices\" => \"5\",\n \"body\" => [\n \"query\" => [\n \"range\" => [\n \"http.response.bytes\" => [\n \"lt\" => 2000000,\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"range\":{\"http.response.bytes\":{\"lt\":2000000}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query?refresh&slices=5\"" + }, + { + "language": "Java", + "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"http.response.bytes\")\n .lt(JsonData.fromJson(\"2000000\"))\n )\n )\n )\n .refresh(true)\n .slices(s -> s\n .value(5)\n )\n);\n" + } + ], + "specification/_global/health_report/examples/request/HealthReportRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.health_report()" + }, + { + "language": "JavaScript", + "code": "const response = await client.healthReport();" + }, + { + "language": "Ruby", + "code": "response = client.health_report" + }, + { + "language": "PHP", + "code": "$resp = $client->healthReport();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_health_report\"" + }, + { + "language": "Java", + "code": "client.healthReport(h -> h);\n" + } + ], + "specification/_global/field_caps/examples/request/FieldCapabilitiesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.field_caps(\n index=\"my-index-*\",\n fields=\"rating\",\n index_filter={\n \"range\": {\n \"@timestamp\": {\n \"gte\": \"2018\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.fieldCaps({\n index: \"my-index-*\",\n fields: \"rating\",\n index_filter: {\n range: {\n \"@timestamp\": {\n gte: \"2018\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.field_caps(\n index: \"my-index-*\",\n fields: \"rating\",\n body: {\n \"index_filter\": {\n \"range\": {\n \"@timestamp\": {\n \"gte\": \"2018\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->fieldCaps([\n \"index\" => \"my-index-*\",\n \"fields\" => \"rating\",\n \"body\" => [\n \"index_filter\" => [\n \"range\" => [\n \"@timestamp\" => [\n \"gte\" => \"2018\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "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\"" + } + ], + "specification/_global/search/examples/request/SearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search(\n index=\"my-index-000001\",\n from=\"40\",\n size=\"20\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.search({\n index: \"my-index-000001\",\n from: 40,\n size: 20,\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search(\n index: \"my-index-000001\",\n from: \"40\",\n size: \"20\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->search([\n \"index\" => \"my-index-000001\",\n \"from\" => \"40\",\n \"size\" => \"20\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_search?from=40&size=20\"" + }, + { + "language": "Java", + "code": "client.search(s -> s\n .from(40)\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .size(20)\n,Void.class);\n" + } + ], + "specification/_global/search/examples/request/SearchRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.search(\n size=100,\n query={\n \"match\": {\n \"title\": \"elasticsearch\"\n }\n },\n pit={\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\": \"1m\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.search({\n size: 100,\n query: {\n match: {\n title: \"elasticsearch\",\n },\n },\n pit: {\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n keep_alive: \"1m\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search(\n body: {\n \"size\": 100,\n \"query\": {\n \"match\": {\n \"title\": \"elasticsearch\"\n }\n },\n \"pit\": {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\": \"1m\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->search([\n \"body\" => [\n \"size\" => 100,\n \"query\" => [\n \"match\" => [\n \"title\" => \"elasticsearch\",\n ],\n ],\n \"pit\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\" => \"1m\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"size\":100,\"query\":{\"match\":{\"title\":\"elasticsearch\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\"keep_alive\":\"1m\"}}' \"$ELASTICSEARCH_URL/_search\"" + }, + { + "language": "Java", + "code": "client.search(s -> s\n .pit(p -> p\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n .keepAlive(k -> k\n .time(\"1m\")\n )\n )\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"elasticsearch\"))\n )\n )\n .size(100)\n,Void.class);\n" + } + ], + "specification/_global/search/examples/request/SearchRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.search(\n slice={\n \"id\": 0,\n \"max\": 2\n },\n query={\n \"match\": {\n \"message\": \"foo\"\n }\n },\n pit={\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.search({\n slice: {\n id: 0,\n max: 2,\n },\n query: {\n match: {\n message: \"foo\",\n },\n },\n pit: {\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search(\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"query\": {\n \"match\": {\n \"message\": \"foo\"\n }\n },\n \"pit\": {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->search([\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"query\" => [\n \"match\" => [\n \"message\" => \"foo\",\n ],\n ],\n \"pit\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"query\":{\"match\":{\"message\":\"foo\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"}}' \"$ELASTICSEARCH_URL/_search\"" + }, + { + "language": "Java", + "code": "client.search(s -> s\n .pit(p -> p\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n )\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n,Void.class);\n" + } + ], + "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.mtermvectors(\n index=\"my-index-000001\",\n docs=[\n {\n \"_id\": \"2\",\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": True\n },\n {\n \"_id\": \"1\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mtermvectors({\n index: \"my-index-000001\",\n docs: [\n {\n _id: \"2\",\n fields: [\"message\"],\n term_statistics: true,\n },\n {\n _id: \"1\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mtermvectors(\n index: \"my-index-000001\",\n body: {\n \"docs\": [\n {\n \"_id\": \"2\",\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n },\n {\n \"_id\": \"1\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mtermvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"2\",\n \"fields\" => array(\n \"message\",\n ),\n \"term_statistics\" => true,\n ],\n [\n \"_id\" => \"1\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"2\",\"fields\":[\"message\"],\"term_statistics\":true},{\"_id\":\"1\"}]}' \"$ELASTICSEARCH_URL/my-index-000001/_mtermvectors\"" + }, + { + "language": "Java", + "code": "client.mtermvectors(m -> m\n .docs(List.of(MultiTermVectorsOperation.of(mu -> mu\n .id(\"2\")\n .fields(\"message\")\n .termStatistics(true)),MultiTermVectorsOperation.of(mu -> mu\n .id(\"1\"))))\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.mtermvectors(\n index=\"my-index-000001\",\n ids=[\n \"1\",\n \"2\"\n ],\n fields=[\n \"message\"\n ],\n term_statistics=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mtermvectors({\n index: \"my-index-000001\",\n ids: [\"1\", \"2\"],\n fields: [\"message\"],\n term_statistics: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.mtermvectors(\n index: \"my-index-000001\",\n body: {\n \"ids\": [\n \"1\",\n \"2\"\n ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mtermvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"ids\" => array(\n \"1\",\n \"2\",\n ),\n \"fields\" => array(\n \"message\",\n ),\n \"term_statistics\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"1\",\"2\"],\"fields\":[\"message\"],\"term_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_mtermvectors\"" + }, + { + "language": "Java", + "code": "client.mtermvectors(m -> m\n .ids(List.of(\"1\",\"2\"))\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.mtermvectors(\n docs=[\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"test test test\"\n }\n },\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"Another test ...\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mtermvectors({\n docs: [\n {\n _index: \"my-index-000001\",\n doc: {\n message: \"test test test\",\n },\n },\n {\n _index: \"my-index-000001\",\n doc: {\n message: \"Another test ...\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mtermvectors(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"test test test\"\n }\n },\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"Another test ...\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mtermvectors([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index-000001\",\n \"doc\" => [\n \"message\" => \"test test test\",\n ],\n ],\n [\n \"_index\" => \"my-index-000001\",\n \"doc\" => [\n \"message\" => \"Another test ...\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index-000001\",\"doc\":{\"message\":\"test test test\"}},{\"_index\":\"my-index-000001\",\"doc\":{\"message\":\"Another test ...\"}}]}' \"$ELASTICSEARCH_URL/_mtermvectors\"" + }, + { + "language": "Java", + "code": "client.mtermvectors(m -> m\n .docs(List.of(MultiTermVectorsOperation.of(mu -> mu\n .index(\"my-index-000001\")\n .doc(JsonData.fromJson(\"{\\\"message\\\":\\\"test test test\\\"}\"))),MultiTermVectorsOperation.of(mu -> mu\n .index(\"my-index-000001\")\n .doc(JsonData.fromJson(\"{\\\"message\\\":\\\"Another test ...\\\"}\")))))\n);\n" + } + ], + "specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.info()" + }, + { + "language": "JavaScript", + "code": "const response = await client.info();" + }, + { + "language": "Ruby", + "code": "response = client.info" + }, + { + "language": "PHP", + "code": "$resp = $client->info();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/\"" + }, + { + "language": "Java", + "code": "client.info();\n" + } + ], + "specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.clear_scroll(\n scroll_id=\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.clearScroll({\n scroll_id: \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.clear_scroll(\n body: {\n \"scroll_id\": \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->clearScroll([\n \"body\" => [\n \"scroll_id\" => \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scroll_id\":\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"}' \"$ELASTICSEARCH_URL/_search/scroll\"" + }, + { + "language": "Java", + "code": "client.clearScroll(c -> c\n .scrollId(\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\")\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample9.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n script={\n \"source\": \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n script: {\n source: 'ctx._source.tag = ctx._source.remove(\"flag\")',\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n },\n \"script\": {\n \"source\": \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n \"script\" => [\n \"source\" => \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"},\"script\":{\"source\":\"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.tag = ctx._source.remove(\"flag\")\")\n )\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"source\"\n },\n dest={\n \"index\": \"dest\",\n \"pipeline\": \"some_ingest_pipeline\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"source\",\n },\n dest: {\n index: \"dest\",\n pipeline: \"some_ingest_pipeline\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"source\"\n },\n \"dest\": {\n \"index\": \"dest\",\n \"pipeline\": \"some_ingest_pipeline\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"source\",\n ],\n \"dest\" => [\n \"index\" => \"dest\",\n \"pipeline\" => \"some_ingest_pipeline\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"source\"},\"dest\":{\"index\":\"dest\",\"pipeline\":\"some_ingest_pipeline\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"dest\")\n .pipeline(\"some_ingest_pipeline\")\n )\n .source(s -> s\n .index(\"source\")\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample11.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n max_docs=10,\n source={\n \"index\": \"my-index-000001\",\n \"query\": {\n \"function_score\": {\n \"random_score\": {},\n \"min_score\": 0.9\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n max_docs: 10,\n source: {\n index: \"my-index-000001\",\n query: {\n function_score: {\n random_score: {},\n min_score: 0.9,\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"max_docs\": 10,\n \"source\": {\n \"index\": \"my-index-000001\",\n \"query\": {\n \"function_score\": {\n \"random_score\": {},\n \"min_score\": 0.9\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"max_docs\" => 10,\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"function_score\" => [\n \"random_score\" => new ArrayObject([]),\n \"min_score\" => 0.9,\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_docs\":10,\"source\":{\"index\":\"my-index-000001\",\"query\":{\"function_score\":{\"random_score\":{},\"min_score\":0.9}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .maxDocs(10L)\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .functionScore(f -> f\n .minScore(0.9D)\n )\n )\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample10.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"metricbeat-*\"\n },\n dest={\n \"index\": \"metricbeat\"\n },\n script={\n \"lang\": \"painless\",\n \"source\": \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"metricbeat-*\",\n },\n dest: {\n index: \"metricbeat\",\n },\n script: {\n lang: \"painless\",\n source:\n \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"metricbeat-*\"\n },\n \"dest\": {\n \"index\": \"metricbeat\"\n },\n \"script\": {\n \"lang\": \"painless\",\n \"source\": \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"metricbeat-*\",\n ],\n \"dest\" => [\n \"index\" => \"metricbeat\",\n ],\n \"script\" => [\n \"lang\" => \"painless\",\n \"source\" => \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"metricbeat-*\"},\"dest\":{\"index\":\"metricbeat\"},\"script\":{\"lang\":\"painless\",\"source\":\"ctx._index = '\"'\"'metricbeat-'\"'\"' + (ctx._index.substring('\"'\"'metricbeat-'\"'\"'.length(), ctx._index.length())) + '\"'\"'-1'\"'\"'\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"metricbeat\")\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\")\n )\n .lang(\"painless\")\n )\n .source(so -> so\n .index(\"metricbeat-*\")\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"source\",\n \"query\": {\n \"match\": {\n \"company\": \"cat\"\n }\n }\n },\n dest={\n \"index\": \"dest\",\n \"routing\": \"=cat\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"source\",\n query: {\n match: {\n company: \"cat\",\n },\n },\n },\n dest: {\n index: \"dest\",\n routing: \"=cat\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"source\",\n \"query\": {\n \"match\": {\n \"company\": \"cat\"\n }\n }\n },\n \"dest\": {\n \"index\": \"dest\",\n \"routing\": \"=cat\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"source\",\n \"query\" => [\n \"match\" => [\n \"company\" => \"cat\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"dest\",\n \"routing\" => \"=cat\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"source\",\"query\":{\"match\":{\"company\":\"cat\"}}},\"dest\":{\"index\":\"dest\",\"routing\":\"=cat\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"dest\")\n .routing(\"=cat\")\n )\n .source(s -> s\n .index(\"source\")\n .query(q -> q\n .match(m -> m\n .field(\"company\")\n .query(FieldValue.of(\"cat\"))\n )\n )\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample8.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"_source\": [\n \"user.id\",\n \"_doc\"\n ]\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n _source: [\"user.id\", \"_doc\"],\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"_source\": [\n \"user.id\",\n \"_doc\"\n ]\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"_source\" => array(\n \"user.id\",\n \"_doc\",\n ),\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"_source\":[\"user.id\",\"_doc\"]},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .sourceFields(List.of(\"user.id\",\"_doc\"))\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n slices=\"5\",\n refresh=True,\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n slices: 5,\n refresh: \"true\",\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n slices: \"5\",\n refresh: \"true\",\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"slices\" => \"5\",\n \"refresh\" => \"true\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex?slices=5&refresh\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .refresh(true)\n .slices(s -> s\n .value(5)\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"slice\":{\"id\":0,\"max\":2}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": [\n \"my-index-000001\",\n \"my-index-000002\"\n ]\n },\n dest={\n \"index\": \"my-new-index-000002\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: [\"my-index-000001\", \"my-index-000002\"],\n },\n dest: {\n index: \"my-new-index-000002\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": [\n \"my-index-000001\",\n \"my-index-000002\"\n ]\n },\n \"dest\": {\n \"index\": \"my-new-index-000002\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => array(\n \"my-index-000001\",\n \"my-index-000002\",\n ),\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000002\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":[\"my-index-000001\",\"my-index-000002\"]},\"dest\":{\"index\":\"my-new-index-000002\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000002\")\n )\n .source(s -> s\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample13.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"remote\": {\n \"host\": \"http://otherhost:9200\",\n \"username\": \"user\",\n \"password\": \"pass\"\n },\n \"index\": \"my-index-000001\",\n \"query\": {\n \"match\": {\n \"test\": \"data\"\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n remote: {\n host: \"http://otherhost:9200\",\n username: \"user\",\n password: \"pass\",\n },\n index: \"my-index-000001\",\n query: {\n match: {\n test: \"data\",\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"remote\": {\n \"host\": \"http://otherhost:9200\",\n \"username\": \"user\",\n \"password\": \"pass\"\n },\n \"index\": \"my-index-000001\",\n \"query\": {\n \"match\": {\n \"test\": \"data\"\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"remote\" => [\n \"host\" => \"http://otherhost:9200\",\n \"username\" => \"user\",\n \"password\" => \"pass\",\n ],\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"match\" => [\n \"test\" => \"data\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"remote\":{\"host\":\"http://otherhost:9200\",\"username\":\"user\",\"password\":\"pass\"},\"index\":\"my-index-000001\",\"query\":{\"match\":{\"test\":\"data\"}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .match(m -> m\n .field(\"test\")\n .query(FieldValue.of(\"data\"))\n )\n )\n .remote(re -> re\n .host(\"http://otherhost:9200\")\n .username(\"user\")\n .password(\"pass\")\n )\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample7.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n max_docs=1,\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n max_docs: 1,\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"max_docs\": 1,\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"max_docs\" => 1,\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_docs\":1,\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .maxDocs(1L)\n .source(s -> s\n .index(\"my-index-000001\")\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"query\":{\"term\":{\"user.id\":\"kimchy\"}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n )\n);\n" + } + ], + "specification/_global/reindex/examples/request/ReindexRequestExample12.yaml": [ + { + "language": "Python", + "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\",\n \"version_type\": \"external\"\n },\n script={\n \"source\": \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\": \"painless\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n version_type: \"external\",\n },\n script: {\n source:\n \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n lang: \"painless\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\",\n \"version_type\": \"external\"\n },\n \"script\": {\n \"source\": \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\": \"painless\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n \"version_type\" => \"external\",\n ],\n \"script\" => [\n \"source\" => \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\" => \"painless\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\",\"version_type\":\"external\"},\"script\":{\"source\":\"if (ctx._source.foo == '\"'\"'bar'\"'\"') {ctx._version++; ctx._source.remove('\"'\"'foo'\"'\"')}\",\"lang\":\"painless\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + }, + { + "language": "Java", + "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n .versionType(VersionType.External)\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\")\n )\n .lang(\"painless\")\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" + } + ], + "specification/_global/index/examples/request/IndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.index(\n index=\"my-index-000001\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.index({\n index: \"my-index-000001\",\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.index(\n index: \"my-index-000001\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->index([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_doc/\"" + }, + { + "language": "Java", + "code": "client.index(i -> i\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" + } + ], + "specification/_global/index/examples/request/IndexRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.index(\n index=\"my-index-000001\",\n id=\"1\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.index({\n index: \"my-index-000001\",\n id: 1,\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.index(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->index([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_doc/1\"" + }, + { + "language": "Java", + "code": "client.index(i -> i\n .id(\"1\")\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" + } + ], + "specification/_global/msearch/examples/request/MsearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.msearch(\n index=\"my-index-000001\",\n searches=[\n {},\n {\n \"query\": {\n \"match\": {\n \"message\": \"this is a test\"\n }\n }\n },\n {\n \"index\": \"my-index-000002\"\n },\n {\n \"query\": {\n \"match_all\": {}\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.msearch({\n index: \"my-index-000001\",\n searches: [\n {},\n {\n query: {\n match: {\n message: \"this is a test\",\n },\n },\n },\n {\n index: \"my-index-000002\",\n },\n {\n query: {\n match_all: {},\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.msearch(\n index: \"my-index-000001\",\n body: [\n {},\n {\n \"query\": {\n \"match\": {\n \"message\": \"this is a test\"\n }\n }\n },\n {\n \"index\": \"my-index-000002\"\n },\n {\n \"query\": {\n \"match_all\": {}\n }\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->msearch([\n \"index\" => \"my-index-000001\",\n \"body\" => array(\n new ArrayObject([]),\n [\n \"query\" => [\n \"match\" => [\n \"message\" => \"this is a test\",\n ],\n ],\n ],\n [\n \"index\" => \"my-index-000002\",\n ],\n [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{},{\"query\":{\"match\":{\"message\":\"this is a test\"}}},{\"index\":\"my-index-000002\"},{\"query\":{\"match_all\":{}}}]' \"$ELASTICSEARCH_URL/my-index-000001/_msearch\"" + } + ], + "specification/_global/delete_script/examples/request/DeleteScriptRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.delete_script(\n id=\"my-search-template\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.deleteScript({\n id: \"my-search-template\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.delete_script(\n id: \"my-search-template\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->deleteScript([\n \"id\" => \"my-search-template\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" + }, + { + "language": "Java", + "code": "client.deleteScript(d -> d\n .id(\"my-search-template\")\n);\n" + } + ], + "specification/_global/mget/examples/request/MultiGetRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.mget(\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"_source\": False\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"_source\": [\n \"field3\",\n \"field4\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"3\",\n \"_source\": {\n \"include\": [\n \"user\"\n ],\n \"exclude\": [\n \"user.location\"\n ]\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mget({\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n _source: false,\n },\n {\n _index: \"test\",\n _id: \"2\",\n _source: [\"field3\", \"field4\"],\n },\n {\n _index: \"test\",\n _id: \"3\",\n _source: {\n include: [\"user\"],\n exclude: [\"user.location\"],\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mget(\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"_source\": false\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"_source\": [\n \"field3\",\n \"field4\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"3\",\n \"_source\": {\n \"include\": [\n \"user\"\n ],\n \"exclude\": [\n \"user.location\"\n ]\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mget([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"_source\" => false,\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n \"_source\" => array(\n \"field3\",\n \"field4\",\n ),\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"3\",\n \"_source\" => [\n \"include\" => array(\n \"user\",\n ),\n \"exclude\" => array(\n \"user.location\",\n ),\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"_source\":false},{\"_index\":\"test\",\"_id\":\"2\",\"_source\":[\"field3\",\"field4\"]},{\"_index\":\"test\",\"_id\":\"3\",\"_source\":{\"include\":[\"user\"],\"exclude\":[\"user.location\"]}}]}' \"$ELASTICSEARCH_URL/_mget\"" + } + ], + "specification/_global/mget/examples/request/MultiGetRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.mget(\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"stored_fields\": [\n \"field1\",\n \"field2\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"stored_fields\": [\n \"field3\",\n \"field4\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mget({\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n stored_fields: [\"field1\", \"field2\"],\n },\n {\n _index: \"test\",\n _id: \"2\",\n stored_fields: [\"field3\", \"field4\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mget(\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"stored_fields\": [\n \"field1\",\n \"field2\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"stored_fields\": [\n \"field3\",\n \"field4\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mget([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"stored_fields\" => array(\n \"field1\",\n \"field2\",\n ),\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n \"stored_fields\" => array(\n \"field3\",\n \"field4\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"stored_fields\":[\"field1\",\"field2\"]},{\"_index\":\"test\",\"_id\":\"2\",\"stored_fields\":[\"field3\",\"field4\"]}]}' \"$ELASTICSEARCH_URL/_mget\"" + }, + { + "language": "Java", + "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")\n .index(\"test\")\n .storedFields(List.of(\"field1\",\"field2\"))),MultiGetOperation.of(mu -> mu\n .id(\"2\")\n .index(\"test\")\n .storedFields(List.of(\"field3\",\"field4\")))))\n);\n" + } + ], + "specification/_global/mget/examples/request/MultiGetRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.mget(\n routing=\"key1\",\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"routing\": \"key2\"\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mget({\n routing: \"key1\",\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n routing: \"key2\",\n },\n {\n _index: \"test\",\n _id: \"2\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mget(\n routing: \"key1\",\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"routing\": \"key2\"\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mget([\n \"routing\" => \"key1\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"routing\" => \"key2\",\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"routing\":\"key2\"},{\"_index\":\"test\",\"_id\":\"2\"}]}' \"$ELASTICSEARCH_URL/_mget?routing=key1\"" + }, + { + "language": "Java", + "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")\n .index(\"test\")\n .routing(\"key2\")),MultiGetOperation.of(mu -> mu\n .id(\"2\")\n .index(\"test\"))))\n .routing(\"key1\")\n);\n" + } + ], + "specification/_global/mget/examples/request/MultiGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.mget(\n index=\"my-index-000001\",\n docs=[\n {\n \"_id\": \"1\"\n },\n {\n \"_id\": \"2\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.mget({\n index: \"my-index-000001\",\n docs: [\n {\n _id: \"1\",\n },\n {\n _id: \"2\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.mget(\n index: \"my-index-000001\",\n body: {\n \"docs\": [\n {\n \"_id\": \"1\"\n },\n {\n \"_id\": \"2\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->mget([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"1\",\n ],\n [\n \"_id\" => \"2\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"1\"},{\"_id\":\"2\"}]}' \"$ELASTICSEARCH_URL/my-index-000001/_mget\"" + }, + { + "language": "Java", + "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")),MultiGetOperation.of(mu -> mu\n .id(\"2\"))))\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/create/examples/request/CreateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.create(\n index=\"my-index-000001\",\n id=\"1\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.create({\n index: \"my-index-000001\",\n id: 1,\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.create(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->create([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_create/1\"" + }, + { + "language": "Java", + "code": "client.create(c -> c\n .id(\"1\")\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" + } + ], + "specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rank_eval(\n index=\"my-index-000001\",\n requests=[\n {\n \"id\": \"JFK query\",\n \"request\": {\n \"query\": {\n \"match_all\": {}\n }\n },\n \"ratings\": []\n }\n ],\n metric={\n \"precision\": {\n \"k\": 20,\n \"relevant_rating_threshold\": 1,\n \"ignore_unlabeled\": False\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rankEval({\n index: \"my-index-000001\",\n requests: [\n {\n id: \"JFK query\",\n request: {\n query: {\n match_all: {},\n },\n },\n ratings: [],\n },\n ],\n metric: {\n precision: {\n k: 20,\n relevant_rating_threshold: 1,\n ignore_unlabeled: false,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.rank_eval(\n index: \"my-index-000001\",\n body: {\n \"requests\": [\n {\n \"id\": \"JFK query\",\n \"request\": {\n \"query\": {\n \"match_all\": {}\n }\n },\n \"ratings\": []\n }\n ],\n \"metric\": {\n \"precision\": {\n \"k\": 20,\n \"relevant_rating_threshold\": 1,\n \"ignore_unlabeled\": false\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rankEval([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"requests\" => array(\n [\n \"id\" => \"JFK query\",\n \"request\" => [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n \"ratings\" => array(\n ),\n ],\n ),\n \"metric\" => [\n \"precision\" => [\n \"k\" => 20,\n \"relevant_rating_threshold\" => 1,\n \"ignore_unlabeled\" => false,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"requests\":[{\"id\":\"JFK query\",\"request\":{\"query\":{\"match_all\":{}}},\"ratings\":[]}],\"metric\":{\"precision\":{\"k\":20,\"relevant_rating_threshold\":1,\"ignore_unlabeled\":false}}}' \"$ELASTICSEARCH_URL/my-index-000001/_rank_eval\"" + }, + { + "language": "Java", + "code": "client.rankEval(r -> r\n .index(\"my-index-000001\")\n .metric(m -> m\n .precision(p -> p\n .ignoreUnlabeled(false)\n .relevantRatingThreshold(1)\n .k(20)\n )\n )\n .requests(re -> re\n .id(\"JFK query\")\n .request(req -> req\n .query(q -> q\n .matchAll(m -> m)\n )\n )\n )\n);\n" + } + ], + "specification/_global/exists_source/examples/request/ExistsSourceRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.exists_source(\n index=\"my-index-000001\",\n id=\"1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.existsSource({\n index: \"my-index-000001\",\n id: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.exists_source(\n index: \"my-index-000001\",\n id: \"1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->existsSource([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" + }, + { + "language": "curl", + "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_source/1\"" + }, + { + "language": "Java", + "code": "client.existsSource(e -> e\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.close_point_in_time(\n id=\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.closePointInTime({\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.close_point_in_time(\n body: {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->closePointInTime([\n \"body\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"}' \"$ELASTICSEARCH_URL/_pit\"" + }, + { + "language": "Java", + "code": "client.closePointInTime(c -> c\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n);\n" + } + ], + "specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.shutdown.put_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n type=\"restart\",\n reason=\"Demonstrating how the node shutdown API works\",\n allocation_delay=\"20m\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.shutdown.putNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n type: \"restart\",\n reason: \"Demonstrating how the node shutdown API works\",\n allocation_delay: \"20m\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.shutdown.put_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n body: {\n \"type\": \"restart\",\n \"reason\": \"Demonstrating how the node shutdown API works\",\n \"allocation_delay\": \"20m\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->shutdown()->putNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n \"body\" => [\n \"type\" => \"restart\",\n \"reason\" => \"Demonstrating how the node shutdown API works\",\n \"allocation_delay\" => \"20m\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"restart\",\"reason\":\"Demonstrating how the node shutdown API works\",\"allocation_delay\":\"20m\"}' \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" + }, + { + "language": "Java", + "code": "client.shutdown().putNode(p -> p\n .allocationDelay(\"20m\")\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n .reason(\"Demonstrating how the node shutdown API works\")\n .type(Type.Restart)\n);\n" + } + ], + "specification/shutdown/delete_node/examples/request/ShutdownDeleteNodeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.shutdown.delete_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.shutdown.deleteNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.shutdown.delete_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->shutdown()->deleteNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" + }, + { + "language": "Java", + "code": "client.shutdown().deleteNode(d -> d\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n);\n" + } + ], + "specification/shutdown/get_node/examples/request/ShutdownGetNodeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.shutdown.get_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.shutdown.getNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.shutdown.get_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->shutdown()->getNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" + }, + { + "language": "Java", + "code": "client.shutdown().getNode(g -> g\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n);\n" + } + ], + "specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.update_settings(\n index.auto_expand_replicas=\"0-4\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.updateSettings({\n \"index.auto_expand_replicas\": \"0-4\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.update_settings(\n body: {\n \"index.auto_expand_replicas\": \"0-4\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->updateSettings([\n \"body\" => [\n \"index.auto_expand_replicas\" => \"0-4\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index.auto_expand_replicas\":\"0-4\"}' \"$ELASTICSEARCH_URL/_watcher/settings\"" + }, + { + "language": "Java", + "code": "client.watcher().updateSettings(u -> u\n .indexAutoExpandReplicas(\"0-4\")\n);\n" + } + ], + "specification/watcher/activate_watch/examples/request/WatcherActivateWatchExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.activate_watch(\n watch_id=\"my_watch\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.activateWatch({\n watch_id: \"my_watch\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.activate_watch(\n watch_id: \"my_watch\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->activateWatch([\n \"watch_id\" => \"my_watch\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_activate\"" + }, + { + "language": "Java", + "code": "client.watcher().activateWatch(a -> a\n .watchId(\"my_watch\")\n);\n" + } + ], + "specification/watcher/get_settings/examples/request/WatcherGetSettingsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.get_settings()" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.getSettings();" + }, + { + "language": "Ruby", + "code": "response = client.watcher.get_settings" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->getSettings();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/settings\"" + }, + { + "language": "Java", + "code": "client.watcher().getSettings(g -> g);\n" + } + ], + "specification/watcher/deactivate_watch/examples/request/WatcherDeactivateWatchExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.deactivate_watch(\n watch_id=\"my_watch\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.deactivateWatch({\n watch_id: \"my_watch\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.deactivate_watch(\n watch_id: \"my_watch\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->deactivateWatch([\n \"watch_id\" => \"my_watch\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_deactivate\"" + }, + { + "language": "Java", + "code": "client.watcher().deactivateWatch(d -> d\n .watchId(\"my_watch\")\n);\n" + } + ], + "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.execute_watch(\n id=\"my_watch\",\n trigger_data={\n \"triggered_time\": \"now\",\n \"scheduled_time\": \"now\"\n },\n alternative_input={\n \"foo\": \"bar\"\n },\n ignore_condition=True,\n action_modes={\n \"my-action\": \"force_simulate\"\n },\n record_execution=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.executeWatch({\n id: \"my_watch\",\n trigger_data: {\n triggered_time: \"now\",\n scheduled_time: \"now\",\n },\n alternative_input: {\n foo: \"bar\",\n },\n ignore_condition: true,\n action_modes: {\n \"my-action\": \"force_simulate\",\n },\n record_execution: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.execute_watch(\n id: \"my_watch\",\n body: {\n \"trigger_data\": {\n \"triggered_time\": \"now\",\n \"scheduled_time\": \"now\"\n },\n \"alternative_input\": {\n \"foo\": \"bar\"\n },\n \"ignore_condition\": true,\n \"action_modes\": {\n \"my-action\": \"force_simulate\"\n },\n \"record_execution\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->executeWatch([\n \"id\" => \"my_watch\",\n \"body\" => [\n \"trigger_data\" => [\n \"triggered_time\" => \"now\",\n \"scheduled_time\" => \"now\",\n ],\n \"alternative_input\" => [\n \"foo\" => \"bar\",\n ],\n \"ignore_condition\" => true,\n \"action_modes\" => [\n \"my-action\" => \"force_simulate\",\n ],\n \"record_execution\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"trigger_data\":{\"triggered_time\":\"now\",\"scheduled_time\":\"now\"},\"alternative_input\":{\"foo\":\"bar\"},\"ignore_condition\":true,\"action_modes\":{\"my-action\":\"force_simulate\"},\"record_execution\":true}' \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute\"" + }, + { + "language": "Java", + "code": "client.watcher().executeWatch(e -> e\n .actionModes(\"my-action\", ActionExecutionMode.ForceSimulate)\n .alternativeInput(\"foo\", JsonData.fromJson(\"\\\"bar\\\"\"))\n .id(\"my_watch\")\n .ignoreCondition(true)\n .recordExecution(true)\n .triggerData(t -> t\n .scheduledTime(DateTime.of(\"now\"))\n .triggeredTime(DateTime.of(\"now\"))\n )\n);\n" + } + ], + "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.execute_watch(\n id=\"my_watch\",\n action_modes={\n \"action1\": \"force_simulate\",\n \"action2\": \"skip\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.executeWatch({\n id: \"my_watch\",\n action_modes: {\n action1: \"force_simulate\",\n action2: \"skip\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.execute_watch(\n id: \"my_watch\",\n body: {\n \"action_modes\": {\n \"action1\": \"force_simulate\",\n \"action2\": \"skip\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->executeWatch([\n \"id\" => \"my_watch\",\n \"body\" => [\n \"action_modes\" => [\n \"action1\" => \"force_simulate\",\n \"action2\" => \"skip\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"action_modes\":{\"action1\":\"force_simulate\",\"action2\":\"skip\"}}' \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute\"" + }, + { + "language": "Java", + "code": "client.watcher().executeWatch(e -> e\n .actionModes(Map.of(\"action1\", ActionExecutionMode.ForceSimulate,\"action2\", ActionExecutionMode.Skip))\n .id(\"my_watch\")\n);\n" + } + ], + "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.execute_watch(\n watch={\n \"trigger\": {\n \"schedule\": {\n \"interval\": \"10s\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logs\"\n ],\n \"body\": {\n \"query\": {\n \"match\": {\n \"message\": \"error\"\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"log_error\": {\n \"logging\": {\n \"text\": \"Found {{ctx.payload.hits.total}} errors in the logs\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.executeWatch({\n watch: {\n trigger: {\n schedule: {\n interval: \"10s\",\n },\n },\n input: {\n search: {\n request: {\n indices: [\"logs\"],\n body: {\n query: {\n match: {\n message: \"error\",\n },\n },\n },\n },\n },\n },\n condition: {\n compare: {\n \"ctx.payload.hits.total\": {\n gt: 0,\n },\n },\n },\n actions: {\n log_error: {\n logging: {\n text: \"Found {{ctx.payload.hits.total}} errors in the logs\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.execute_watch(\n body: {\n \"watch\": {\n \"trigger\": {\n \"schedule\": {\n \"interval\": \"10s\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logs\"\n ],\n \"body\": {\n \"query\": {\n \"match\": {\n \"message\": \"error\"\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"log_error\": {\n \"logging\": {\n \"text\": \"Found {{ctx.payload.hits.total}} errors in the logs\"\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->executeWatch([\n \"body\" => [\n \"watch\" => [\n \"trigger\" => [\n \"schedule\" => [\n \"interval\" => \"10s\",\n ],\n ],\n \"input\" => [\n \"search\" => [\n \"request\" => [\n \"indices\" => array(\n \"logs\",\n ),\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"error\",\n ],\n ],\n ],\n ],\n ],\n ],\n \"condition\" => [\n \"compare\" => [\n \"ctx.payload.hits.total\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"actions\" => [\n \"log_error\" => [\n \"logging\" => [\n \"text\" => \"Found {{ctx.payload.hits.total}} errors in the logs\",\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"watch\":{\"trigger\":{\"schedule\":{\"interval\":\"10s\"}},\"input\":{\"search\":{\"request\":{\"indices\":[\"logs\"],\"body\":{\"query\":{\"match\":{\"message\":\"error\"}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\"actions\":{\"log_error\":{\"logging\":{\"text\":\"Found {{ctx.payload.hits.total}} errors in the logs\"}}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/_execute\"" + }, + { + "language": "Java", + "code": "client.watcher().executeWatch(e -> e\n .watch(w -> w\n .actions(\"log_error\", a -> a\n .logging(l -> l\n .text(\"Found {{ctx.payload.hits.total}} errors in the logs\")\n )\n )\n .condition(c -> c\n .compare(NamedValue.of(\"ctx.payload.hits.total\",Pair.of(ConditionOp.Gt,FieldValue.of(0))))\n )\n .input(i -> i\n .search(s -> s\n .request(r -> r\n .body(b -> b\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"error\"))\n )\n )\n )\n .indices(\"logs\")\n )\n )\n )\n .trigger(t -> t\n .schedule(sc -> sc\n .interval(in -> in\n .time(\"10s\")\n )\n )\n )\n )\n);\n" + } + ], + "specification/watcher/start/examples/request/WatcherStartRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.start()" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.start();" + }, + { + "language": "Ruby", + "code": "response = client.watcher.start" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->start();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_start\"" + }, + { + "language": "Java", + "code": "client.watcher().start(s -> s);\n" + } + ], + "specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.query_watches()" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.queryWatches();" + }, + { + "language": "Ruby", + "code": "response = client.watcher.query_watches" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->queryWatches();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_query/watches\"" + }, + { + "language": "Java", + "code": "client.watcher().queryWatches();\n" + } + ], + "specification/watcher/stop/examples/request/WatcherStopRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.stop()" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.stop();" + }, + { + "language": "Ruby", + "code": "response = client.watcher.stop" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->stop();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_stop\"" + }, + { + "language": "Java", + "code": "client.watcher().stop(s -> s);\n" + } + ], + "specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.put_watch(\n id=\"my-watch\",\n trigger={\n \"schedule\": {\n \"cron\": \"0 0/1 * * * ?\"\n }\n },\n input={\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logstash*\"\n ],\n \"body\": {\n \"query\": {\n \"bool\": {\n \"must\": {\n \"match\": {\n \"response\": 404\n }\n },\n \"filter\": {\n \"range\": {\n \"@timestamp\": {\n \"from\": \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\": \"{{ctx.trigger.triggered_time}}\"\n }\n }\n }\n }\n }\n }\n }\n }\n },\n condition={\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n actions={\n \"email_admin\": {\n \"email\": {\n \"to\": \"admin@domain.host.com\",\n \"subject\": \"404 recently encountered\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.putWatch({\n id: \"my-watch\",\n trigger: {\n schedule: {\n cron: \"0 0/1 * * * ?\",\n },\n },\n input: {\n search: {\n request: {\n indices: [\"logstash*\"],\n body: {\n query: {\n bool: {\n must: {\n match: {\n response: 404,\n },\n },\n filter: {\n range: {\n \"@timestamp\": {\n from: \"{{ctx.trigger.scheduled_time}}||-5m\",\n to: \"{{ctx.trigger.triggered_time}}\",\n },\n },\n },\n },\n },\n },\n },\n },\n },\n condition: {\n compare: {\n \"ctx.payload.hits.total\": {\n gt: 0,\n },\n },\n },\n actions: {\n email_admin: {\n email: {\n to: \"admin@domain.host.com\",\n subject: \"404 recently encountered\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.put_watch(\n id: \"my-watch\",\n body: {\n \"trigger\": {\n \"schedule\": {\n \"cron\": \"0 0/1 * * * ?\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logstash*\"\n ],\n \"body\": {\n \"query\": {\n \"bool\": {\n \"must\": {\n \"match\": {\n \"response\": 404\n }\n },\n \"filter\": {\n \"range\": {\n \"@timestamp\": {\n \"from\": \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\": \"{{ctx.trigger.triggered_time}}\"\n }\n }\n }\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"email_admin\": {\n \"email\": {\n \"to\": \"admin@domain.host.com\",\n \"subject\": \"404 recently encountered\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->putWatch([\n \"id\" => \"my-watch\",\n \"body\" => [\n \"trigger\" => [\n \"schedule\" => [\n \"cron\" => \"0 0/1 * * * ?\",\n ],\n ],\n \"input\" => [\n \"search\" => [\n \"request\" => [\n \"indices\" => array(\n \"logstash*\",\n ),\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => [\n \"match\" => [\n \"response\" => 404,\n ],\n ],\n \"filter\" => [\n \"range\" => [\n \"@timestamp\" => [\n \"from\" => \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\" => \"{{ctx.trigger.triggered_time}}\",\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n \"condition\" => [\n \"compare\" => [\n \"ctx.payload.hits.total\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"actions\" => [\n \"email_admin\" => [\n \"email\" => [\n \"to\" => \"admin@domain.host.com\",\n \"subject\" => \"404 recently encountered\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"trigger\":{\"schedule\":{\"cron\":\"0 0/1 * * * ?\"}},\"input\":{\"search\":{\"request\":{\"indices\":[\"logstash*\"],\"body\":{\"query\":{\"bool\":{\"must\":{\"match\":{\"response\":404}},\"filter\":{\"range\":{\"@timestamp\":{\"from\":\"{{ctx.trigger.scheduled_time}}||-5m\",\"to\":\"{{ctx.trigger.triggered_time}}\"}}}}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\"actions\":{\"email_admin\":{\"email\":{\"to\":\"admin@domain.host.com\",\"subject\":\"404 recently encountered\"}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/my-watch\"" + }, + { + "language": "Java", + "code": "client.watcher().putWatch(p -> p\n .actions(\"email_admin\", a -> a\n .email(e -> e\n .subject(\"404 recently encountered\")\n .to(\"admin@domain.host.com\")\n )\n )\n .condition(c -> c\n .compare(NamedValue.of(\"ctx.payload.hits.total\",Pair.of(ConditionOp.Gt,FieldValue.of(0))))\n )\n .id(\"my-watch\")\n .input(i -> i\n .search(s -> s\n .request(r -> r\n .body(b -> b\n .query(q -> q\n .bool(bo -> bo\n .filter(f -> f\n .range(ra -> ra\n .untyped(u -> u\n .field(\"@timestamp\")\n )\n )\n )\n .must(m -> m\n .match(ma -> ma\n .field(\"response\")\n .query(FieldValue.of(404))\n )\n )\n )\n )\n )\n .indices(\"logstash*\")\n )\n )\n )\n .trigger(t -> t\n .schedule(sc -> sc\n .cron(\"0 0/1 * * * ?\")\n )\n )\n);\n" + } + ], + "specification/watcher/get_watch/examples/request/GetWatchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.get_watch(\n id=\"my_watch\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.getWatch({\n id: \"my_watch\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.get_watch(\n id: \"my_watch\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->getWatch([\n \"id\" => \"my_watch\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch\"" + }, + { + "language": "Java", + "code": "client.watcher().getWatch(g -> g\n .id(\"my_watch\")\n);\n" + } + ], + "specification/watcher/ack_watch/examples/request/WatcherAckWatchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.ack_watch(\n watch_id=\"my_watch\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.ackWatch({\n watch_id: \"my_watch\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.ack_watch(\n watch_id: \"my_watch\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->ackWatch([\n \"watch_id\" => \"my_watch\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_ack\"" + }, + { + "language": "Java", + "code": "client.watcher().ackWatch(a -> a\n .watchId(\"my_watch\")\n);\n" + } + ], + "specification/watcher/delete_watch/examples/request/DeleteWatchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.delete_watch(\n id=\"my_watch\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.deleteWatch({\n id: \"my_watch\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.watcher.delete_watch(\n id: \"my_watch\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->deleteWatch([\n \"id\" => \"my_watch\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch\"" + }, + { + "language": "Java", + "code": "client.watcher().deleteWatch(d -> d\n .id(\"my_watch\")\n);\n" + } + ], + "specification/watcher/stats/examples/request/WatcherStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.watcher.stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.watcher.stats();" + }, + { + "language": "Ruby", + "code": "response = client.watcher.stats" + }, + { + "language": "PHP", + "code": "$resp = $client->watcher()->stats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/stats\"" + }, + { + "language": "Java", + "code": "client.watcher().stats(s -> s);\n" + } + ], + "specification/license/post/examples/request/PostLicenseRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.post(\n licenses=[\n {\n \"uid\": \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\": \"basic\",\n \"issue_date_in_millis\": 1411948800000,\n \"expiry_date_in_millis\": 1914278399999,\n \"max_nodes\": 1,\n \"issued_to\": \"issuedTo\",\n \"issuer\": \"issuer\",\n \"signature\": \"xx\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.post({\n licenses: [\n {\n uid: \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n type: \"basic\",\n issue_date_in_millis: 1411948800000,\n expiry_date_in_millis: 1914278399999,\n max_nodes: 1,\n issued_to: \"issuedTo\",\n issuer: \"issuer\",\n signature: \"xx\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.license.post(\n body: {\n \"licenses\": [\n {\n \"uid\": \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\": \"basic\",\n \"issue_date_in_millis\": 1411948800000,\n \"expiry_date_in_millis\": 1914278399999,\n \"max_nodes\": 1,\n \"issued_to\": \"issuedTo\",\n \"issuer\": \"issuer\",\n \"signature\": \"xx\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->post([\n \"body\" => [\n \"licenses\" => array(\n [\n \"uid\" => \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\" => \"basic\",\n \"issue_date_in_millis\" => 1411948800000,\n \"expiry_date_in_millis\" => 1914278399999,\n \"max_nodes\" => 1,\n \"issued_to\" => \"issuedTo\",\n \"issuer\" => \"issuer\",\n \"signature\" => \"xx\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"licenses\":[{\"uid\":\"893361dc-9749-4997-93cb-802e3d7fa4xx\",\"type\":\"basic\",\"issue_date_in_millis\":1411948800000,\"expiry_date_in_millis\":1914278399999,\"max_nodes\":1,\"issued_to\":\"issuedTo\",\"issuer\":\"issuer\",\"signature\":\"xx\"}]}' \"$ELASTICSEARCH_URL/_license\"" + }, + { + "language": "Java", + "code": "client.license().post(p -> p\n .licenses(l -> l\n .expiryDateInMillis(1914278399999L)\n .issueDateInMillis(1411948800000L)\n .issuedTo(\"issuedTo\")\n .issuer(\"issuer\")\n .maxNodes(1L)\n .signature(\"xx\")\n .type(LicenseType.Basic)\n .uid(\"893361dc-9749-4997-93cb-802e3d7fa4xx\")\n )\n);\n" + } + ], + "specification/license/delete/examples/request/LicenseDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.delete()" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.delete();" + }, + { + "language": "Ruby", + "code": "response = client.license.delete" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->delete();" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license\"" + }, + { + "language": "Java", + "code": "client.license().delete(d -> d);\n" + } + ], + "specification/license/get/examples/request/GetLicenseRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.get()" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.get();" + }, + { + "language": "Ruby", + "code": "response = client.license.get" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->get();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license\"" + }, + { + "language": "Java", + "code": "client.license().get(g -> g);\n" + } + ], + "specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.get_trial_status()" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.getTrialStatus();" + }, + { + "language": "Ruby", + "code": "response = client.license.get_trial_status" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->getTrialStatus();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/trial_status\"" + }, + { + "language": "Java", + "code": "client.license().getTrialStatus();\n" + } + ], + "specification/license/post_start_trial/examples/request/StartTrialLicenseRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.post_start_trial(\n acknowledge=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.postStartTrial({\n acknowledge: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.license.post_start_trial(\n acknowledge: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->postStartTrial([\n \"acknowledge\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/start_trial?acknowledge=true\"" + }, + { + "language": "Java", + "code": "client.license().postStartTrial(p -> p\n .acknowledge(true)\n);\n" + } + ], + "specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.get_basic_status()" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.getBasicStatus();" + }, + { + "language": "Ruby", + "code": "response = client.license.get_basic_status" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->getBasicStatus();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/basic_status\"" + }, + { + "language": "Java", + "code": "client.license().getBasicStatus();\n" + } + ], + "specification/license/post_start_basic/examples/request/StartBasicLicenseRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.license.post_start_basic(\n acknowledge=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.license.postStartBasic({\n acknowledge: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.license.post_start_basic(\n acknowledge: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->license()->postStartBasic([\n \"acknowledge\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/start_basic?acknowledge=true\"" + }, + { + "language": "Java", + "code": "client.license().postStartBasic(p -> p\n .acknowledge(true)\n);\n" + } + ], + "specification/logstash/get_pipeline/examples/request/LogstashGetPipelineRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.logstash.get_pipeline(\n id=\"my_pipeline\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.logstash.getPipeline({\n id: \"my_pipeline\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.logstash.get_pipeline(\n id: \"my_pipeline\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->logstash()->getPipeline([\n \"id\" => \"my_pipeline\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" + }, + { + "language": "Java", + "code": "client.logstash().getPipeline(g -> g\n .id(\"my_pipeline\")\n);\n" + } + ], + "specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.logstash.put_pipeline(\n id=\"my_pipeline\",\n pipeline={\n \"description\": \"Sample pipeline for illustration purposes\",\n \"last_modified\": \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\": {\n \"type\": \"logstash_pipeline\",\n \"version\": 1\n },\n \"username\": \"elastic\",\n \"pipeline\": \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\": {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.logstash.putPipeline({\n id: \"my_pipeline\",\n pipeline: {\n description: \"Sample pipeline for illustration purposes\",\n last_modified: \"2021-01-02T02:50:51.250Z\",\n pipeline_metadata: {\n type: \"logstash_pipeline\",\n version: 1,\n },\n username: \"elastic\",\n pipeline: \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n pipeline_settings: {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.logstash.put_pipeline(\n id: \"my_pipeline\",\n body: {\n \"description\": \"Sample pipeline for illustration purposes\",\n \"last_modified\": \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\": {\n \"type\": \"logstash_pipeline\",\n \"version\": 1\n },\n \"username\": \"elastic\",\n \"pipeline\": \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\": {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->logstash()->putPipeline([\n \"id\" => \"my_pipeline\",\n \"body\" => [\n \"description\" => \"Sample pipeline for illustration purposes\",\n \"last_modified\" => \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\" => [\n \"type\" => \"logstash_pipeline\",\n \"version\" => 1,\n ],\n \"username\" => \"elastic\",\n \"pipeline\" => \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\" => [\n \"pipeline.workers\" => 1,\n \"pipeline.batch.size\" => 125,\n \"pipeline.batch.delay\" => 50,\n \"queue.type\" => \"memory\",\n \"queue.max_bytes\" => \"1gb\",\n \"queue.checkpoint.writes\" => 1024,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Sample pipeline for illustration purposes\",\"last_modified\":\"2021-01-02T02:50:51.250Z\",\"pipeline_metadata\":{\"type\":\"logstash_pipeline\",\"version\":1},\"username\":\"elastic\",\"pipeline\":\"input {}\\\\n filter { grok {} }\\\\n output {}\",\"pipeline_settings\":{\"pipeline.workers\":1,\"pipeline.batch.size\":125,\"pipeline.batch.delay\":50,\"queue.type\":\"memory\",\"queue.max_bytes\":\"1gb\",\"queue.checkpoint.writes\":1024}}' \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" + }, + { + "language": "Java", + "code": "client.logstash().putPipeline(p -> p\n .id(\"my_pipeline\")\n .pipeline(pi -> pi\n .description(\"Sample pipeline for illustration purposes\")\n .lastModified(DateTime.of(\"2021-01-02T02:50:51.250Z\"))\n .pipeline(\"input {}\\n filter { grok {} }\\n output {}\")\n .pipelineMetadata(pip -> pip\n .type(\"logstash_pipeline\")\n .version(\"1\")\n )\n .pipelineSettings(pip -> pip\n .pipelineWorkers(1)\n .pipelineBatchSize(125)\n .pipelineBatchDelay(50)\n .queueType(\"memory\")\n .queueMaxBytes(\"1gb\")\n .queueCheckpointWrites(1024)\n )\n .username(\"elastic\")\n )\n);\n" + } + ], + "specification/logstash/delete_pipeline/examples/request/LogstashDeletePipelineExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.logstash.delete_pipeline(\n id=\"my_pipeline\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.logstash.deletePipeline({\n id: \"my_pipeline\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.logstash.delete_pipeline(\n id: \"my_pipeline\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->logstash()->deletePipeline([\n \"id\" => \"my_pipeline\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" + }, + { + "language": "Java", + "code": "client.logstash().deletePipeline(d -> d\n .id(\"my_pipeline\")\n);\n" + } + ], + "specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_complete_logout(\n realm=\"saml1\",\n ids=[\n \"_1c368075e0b3...\"\n ],\n content=\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlCompleteLogout({\n realm: \"saml1\",\n ids: [\"_1c368075e0b3...\"],\n content: \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_complete_logout(\n body: {\n \"realm\": \"saml1\",\n \"ids\": [\n \"_1c368075e0b3...\"\n ],\n \"content\": \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlCompleteLogout([\n \"body\" => [\n \"realm\" => \"saml1\",\n \"ids\" => array(\n \"_1c368075e0b3...\",\n ),\n \"content\" => \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\",\"ids\":[\"_1c368075e0b3...\"],\"content\":\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\"}' \"$ELASTICSEARCH_URL/_security/saml/complete_logout\"" + }, + { + "language": "Java", + "code": "client.security().samlCompleteLogout(s -> s\n .content(\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\")\n .ids(\"_1c368075e0b3...\")\n .realm(\"saml1\")\n);\n" + } + ], + "specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_complete_logout(\n realm=\"saml1\",\n ids=[\n \"_1c368075e0b3...\"\n ],\n query_string=\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlCompleteLogout({\n realm: \"saml1\",\n ids: [\"_1c368075e0b3...\"],\n query_string:\n \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_complete_logout(\n body: {\n \"realm\": \"saml1\",\n \"ids\": [\n \"_1c368075e0b3...\"\n ],\n \"query_string\": \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlCompleteLogout([\n \"body\" => [\n \"realm\" => \"saml1\",\n \"ids\" => array(\n \"_1c368075e0b3...\",\n ),\n \"query_string\" => \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\",\"ids\":[\"_1c368075e0b3...\"],\"query_string\":\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\"}' \"$ELASTICSEARCH_URL/_security/saml/complete_logout\"" + }, + { + "language": "Java", + "code": "client.security().samlCompleteLogout(s -> s\n .ids(\"_1c368075e0b3...\")\n .queryString(\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\")\n .realm(\"saml1\")\n);\n" + } + ], + "specification/security/disable_user/examples/request/SecurityDisableUserExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.disable_user(\n username=\"jacknich\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.disableUser({\n username: \"jacknich\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.disable_user(\n username: \"jacknich\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->disableUser([\n \"username\" => \"jacknich\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich/_disable\"" + }, + { + "language": "Java", + "code": "client.security().disableUser(d -> d\n .username(\"jacknich\")\n);\n" + } + ], + "specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_settings(\n security={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n security-tokens={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n security-profile={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateSettings({\n security: {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n \"security-tokens\": {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n \"security-profile\": {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_settings(\n body: {\n \"security\": {\n \"index.auto_expand_replicas\": \"0-all\"\n },\n \"security-tokens\": {\n \"index.auto_expand_replicas\": \"0-all\"\n },\n \"security-profile\": {\n \"index.auto_expand_replicas\": \"0-all\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateSettings([\n \"body\" => [\n \"security\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n \"security-tokens\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n \"security-profile\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"security\":{\"index.auto_expand_replicas\":\"0-all\"},\"security-tokens\":{\"index.auto_expand_replicas\":\"0-all\"},\"security-profile\":{\"index.auto_expand_replicas\":\"0-all\"}}' \"$ELASTICSEARCH_URL/_security/settings\"" + }, + { + "language": "Java", + "code": "client.security().updateSettings(u -> u\n .security(s -> s)\n .securityProfile(s -> s)\n .securityTokens(s -> s)\n);\n" + } + ], + "specification/security/get_user_profile/examples/request/GetUserProfileRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"" + }, + { + "language": "Java", + "code": "client.security().getUserProfile(g -> g\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" + } + ], + "specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.create_api_key(\n name=\"my-api-key\",\n expiration=\"1d\",\n role_descriptors={\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n metadata={\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.createApiKey({\n name: \"my-api-key\",\n expiration: \"1d\",\n role_descriptors: {\n \"role-a\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-a*\"],\n privileges: [\"read\"],\n },\n ],\n },\n \"role-b\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-b*\"],\n privileges: [\"all\"],\n },\n ],\n },\n },\n metadata: {\n application: \"my-application\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.create_api_key(\n body: {\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->createApiKey([\n \"body\" => [\n \"name\" => \"my-api-key\",\n \"expiration\" => \"1d\",\n \"role_descriptors\" => [\n \"role-a\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-a*\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n ),\n ],\n \"role-b\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-b*\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"application\" => \"my-application\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-a*\"],\"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"privileges\":[\"all\"]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().createApiKey(c -> c\n .expiration(e -> e\n .time(\"1d\")\n )\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"application\", JsonData.fromJson(\"\\\"my-application\\\"\")))\n .name(\"my-api-key\")\n .roleDescriptors(Map.of(\"role-b\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-b*\")\n .privileges(\"all\")\n )),\"role-a\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-a*\")\n .privileges(\"read\")\n ))))\n);\n" + } + ], + "specification/security/get_privileges/examples/request/SecurityGetPrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_privileges(\n application=\"myapp\",\n name=\"read\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getPrivileges({\n application: \"myapp\",\n name: \"read\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_privileges(\n application: \"myapp\",\n name: \"read\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getPrivileges([\n \"application\" => \"myapp\",\n \"name\" => \"read\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/read\"" + }, + { + "language": "Java", + "code": "client.security().getPrivileges(g -> g\n .application(\"myapp\")\n .name(\"read\")\n);\n" + } + ], + "specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_cross_cluster_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n access={\n \"replication\": [\n {\n \"names\": [\n \"archive\"\n ]\n }\n ]\n },\n metadata={\n \"application\": \"replication\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateCrossClusterApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n access: {\n replication: [\n {\n names: [\"archive\"],\n },\n ],\n },\n metadata: {\n application: \"replication\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_cross_cluster_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"access\": {\n \"replication\": [\n {\n \"names\": [\n \"archive\"\n ]\n }\n ]\n },\n \"metadata\": {\n \"application\": \"replication\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateCrossClusterApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"access\" => [\n \"replication\" => array(\n [\n \"names\" => array(\n \"archive\",\n ),\n ],\n ),\n ],\n \"metadata\" => [\n \"application\" => \"replication\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"access\":{\"replication\":[{\"names\":[\"archive\"]}]},\"metadata\":{\"application\":\"replication\"}}' \"$ELASTICSEARCH_URL/_security/cross_cluster/api_key/VuaCfGcBCdbkQm-e5aOx\"" + }, + { + "language": "Java", + "code": "client.security().updateCrossClusterApiKey(u -> u\n .access(a -> a\n .replication(r -> r\n .names(\"archive\")\n )\n )\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n .metadata(\"application\", JsonData.fromJson(\"\\\"replication\\\"\"))\n);\n" + } + ], + "specification/security/get_settings/examples/request/SecurityGetSettingsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_settings()" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getSettings();" + }, + { + "language": "Ruby", + "code": "response = client.security.get_settings" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getSettings();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/settings\"" + }, + { + "language": "Java", + "code": "client.security().getSettings(g -> g);\n" + } + ], + "specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_builtin_privileges()" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getBuiltinPrivileges();" + }, + { + "language": "Ruby", + "code": "response = client.security.get_builtin_privileges" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getBuiltinPrivileges();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/_builtin\"" + }, + { + "language": "Java", + "code": "client.security().getBuiltinPrivileges();\n" + } + ], + "specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.has_privileges_user_profile(\n uids=[\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\"\n ],\n privileges={\n \"cluster\": [\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"create_doc\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.hasPrivilegesUserProfile({\n uids: [\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\",\n ],\n privileges: {\n cluster: [\"monitor\", \"create_snapshot\", \"manage_ml\"],\n index: [\n {\n names: [\"suppliers\", \"products\"],\n privileges: [\"create_doc\"],\n },\n {\n names: [\"inventory\"],\n privileges: [\"read\", \"write\"],\n },\n ],\n application: [\n {\n application: \"inventory_manager\",\n privileges: [\"read\", \"data:write/inventory\"],\n resources: [\"product/1852563\"],\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.has_privileges_user_profile(\n body: {\n \"uids\": [\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\"\n ],\n \"privileges\": {\n \"cluster\": [\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"create_doc\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->hasPrivilegesUserProfile([\n \"body\" => [\n \"uids\" => array(\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\",\n ),\n \"privileges\" => [\n \"cluster\" => array(\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\",\n ),\n \"index\" => array(\n [\n \"names\" => array(\n \"suppliers\",\n \"products\",\n ),\n \"privileges\" => array(\n \"create_doc\",\n ),\n ],\n [\n \"names\" => array(\n \"inventory\",\n ),\n \"privileges\" => array(\n \"read\",\n \"write\",\n ),\n ],\n ),\n \"application\" => array(\n [\n \"application\" => \"inventory_manager\",\n \"privileges\" => array(\n \"read\",\n \"data:write/inventory\",\n ),\n \"resources\" => array(\n \"product/1852563\",\n ),\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"uids\":[\"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\"u_does-not-exist_0\"],\"privileges\":{\"cluster\":[\"monitor\",\"create_snapshot\",\"manage_ml\"],\"index\":[{\"names\":[\"suppliers\",\"products\"],\"privileges\":[\"create_doc\"]},{\"names\":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"application\":[{\"application\":\"inventory_manager\",\"privileges\":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/1852563\"]}]}}' \"$ELASTICSEARCH_URL/_security/profile/_has_privileges\"" + }, + { + "language": "Java", + "code": "client.security().hasPrivilegesUserProfile(h -> h\n .privileges(p -> p\n .application(a -> a\n .application(\"inventory_manager\")\n .privileges(List.of(\"read\",\"data:write/inventory\"))\n .resources(\"product/1852563\")\n )\n .cluster(List.of(\"monitor\",\"create_snapshot\",\"manage_ml\"))\n .index(List.of(IndexPrivilegesCheck.of(i -> i\n .names(List.of(\"suppliers\",\"products\"))\n .privileges(\"create_doc\")),IndexPrivilegesCheck.of(i -> i\n .names(\"inventory\")\n .privileges(List.of(\"read\",\"write\")))))\n )\n .uids(List.of(\"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\"u_does-not-exist_0\"))\n);\n" + } + ], + "specification/security/clear_cached_roles/examples/request/SecurityClearCachedRolesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.clear_cached_roles(\n name=\"my_admin_role\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.clearCachedRoles({\n name: \"my_admin_role\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.clear_cached_roles(\n name: \"my_admin_role\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->clearCachedRoles([\n \"name\" => \"my_admin_role\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role/_clear_cache\"" + }, + { + "language": "Java", + "code": "client.security().clearCachedRoles(c -> c\n .name(\"my_admin_role\")\n);\n" + } + ], + "specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.authenticate()" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.authenticate();" + }, + { + "language": "Ruby", + "code": "response = client.security.authenticate" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->authenticate();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/_authenticate\"" + }, + { + "language": "Java", + "code": "client.security().authenticate();\n" + } + ], + "specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.activate_user_profile(\n grant_type=\"password\",\n username=\"jacknich\",\n password=\"l0ng-r4nd0m-p@ssw0rd\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.activateUserProfile({\n grant_type: \"password\",\n username: \"jacknich\",\n password: \"l0ng-r4nd0m-p@ssw0rd\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.activate_user_profile(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"jacknich\",\n \"password\": \"l0ng-r4nd0m-p@ssw0rd\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->activateUserProfile([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"jacknich\",\n \"password\" => \"l0ng-r4nd0m-p@ssw0rd\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"jacknich\",\"password\":\"l0ng-r4nd0m-p@ssw0rd\"}' \"$ELASTICSEARCH_URL/_security/profile/_activate\"" + }, + { + "language": "Java", + "code": "client.security().activateUserProfile(a -> a\n .grantType(GrantType.Password)\n .password(\"l0ng-r4nd0m-p@ssw0rd\")\n .username(\"jacknich\")\n);\n" + } + ], + "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.oidc_prepare_authentication(\n realm=\"oidc1\",\n state=\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n nonce=\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.oidcPrepareAuthentication({\n realm: \"oidc1\",\n state: \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n nonce: \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"realm\": \"oidc1\",\n \"state\": \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n \"nonce\": \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"oidc1\",\n \"state\" => \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n \"nonce\" => \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"oidc1\",\"state\":\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\"nonce\":\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" + }, + { + "language": "Java", + "code": "client.security().oidcPrepareAuthentication(o -> o\n .nonce(\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\")\n .realm(\"oidc1\")\n .state(\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\")\n);\n" + } + ], + "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.oidc_prepare_authentication(\n iss=\"http://127.0.0.1:8080\",\n login_hint=\"this_is_an_opaque_string\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.oidcPrepareAuthentication({\n iss: \"http://127.0.0.1:8080\",\n login_hint: \"this_is_an_opaque_string\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"iss\": \"http://127.0.0.1:8080\",\n \"login_hint\": \"this_is_an_opaque_string\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"iss\" => \"http://127.0.0.1:8080\",\n \"login_hint\" => \"this_is_an_opaque_string\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"iss\":\"http://127.0.0.1:8080\",\"login_hint\":\"this_is_an_opaque_string\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" + }, + { + "language": "Java", + "code": "client.security().oidcPrepareAuthentication(o -> o\n .iss(\"http://127.0.0.1:8080\")\n .loginHint(\"this_is_an_opaque_string\")\n);\n" + } + ], + "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.oidc_prepare_authentication(\n realm=\"oidc1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.oidcPrepareAuthentication({\n realm: \"oidc1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"realm\": \"oidc1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"oidc1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"oidc1\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" + }, + { + "language": "Java", + "code": "client.security().oidcPrepareAuthentication(o -> o\n .realm(\"oidc1\")\n);\n" + } + ], + "specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.has_privileges(\n cluster=[\n \"monitor\",\n \"manage\"\n ],\n index=[\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"read\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n application=[\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.hasPrivileges({\n cluster: [\"monitor\", \"manage\"],\n index: [\n {\n names: [\"suppliers\", \"products\"],\n privileges: [\"read\"],\n },\n {\n names: [\"inventory\"],\n privileges: [\"read\", \"write\"],\n },\n ],\n application: [\n {\n application: \"inventory_manager\",\n privileges: [\"read\", \"data:write/inventory\"],\n resources: [\"product/1852563\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.has_privileges(\n body: {\n \"cluster\": [\n \"monitor\",\n \"manage\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"read\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->hasPrivileges([\n \"body\" => [\n \"cluster\" => array(\n \"monitor\",\n \"manage\",\n ),\n \"index\" => array(\n [\n \"names\" => array(\n \"suppliers\",\n \"products\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n [\n \"names\" => array(\n \"inventory\",\n ),\n \"privileges\" => array(\n \"read\",\n \"write\",\n ),\n ],\n ),\n \"application\" => array(\n [\n \"application\" => \"inventory_manager\",\n \"privileges\" => array(\n \"read\",\n \"data:write/inventory\",\n ),\n \"resources\" => array(\n \"product/1852563\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cluster\":[\"monitor\",\"manage\"],\"index\":[{\"names\":[\"suppliers\",\"products\"],\"privileges\":[\"read\"]},{\"names\":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"application\":[{\"application\":\"inventory_manager\",\"privileges\":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/1852563\"]}]}' \"$ELASTICSEARCH_URL/_security/user/_has_privileges\"" + }, + { + "language": "Java", + "code": "client.security().hasPrivileges(h -> h\n .application(a -> a\n .application(\"inventory_manager\")\n .privileges(List.of(\"read\",\"data:write/inventory\"))\n .resources(\"product/1852563\")\n )\n .cluster(List.of(\"monitor\",\"manage\"))\n .index(List.of(IndexPrivilegesCheck.of(i -> i\n .names(List.of(\"suppliers\",\"products\"))\n .privileges(\"read\")),IndexPrivilegesCheck.of(i -> i\n .names(\"inventory\")\n .privileges(List.of(\"read\",\"write\")))))\n);\n" + } + ], + "specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.oidc_logout(\n token=\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n refresh_token=\"vLBPvmAB6KvwvJZr27cS\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.oidcLogout({\n token:\n \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n refresh_token: \"vLBPvmAB6KvwvJZr27cS\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.oidc_logout(\n body: {\n \"token\": \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n \"refresh_token\": \"vLBPvmAB6KvwvJZr27cS\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->oidcLogout([\n \"body\" => [\n \"token\" => \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n \"refresh_token\" => \"vLBPvmAB6KvwvJZr27cS\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\"refresh_token\":\"vLBPvmAB6KvwvJZr27cS\"}' \"$ELASTICSEARCH_URL/_security/oidc/logout\"" + }, + { + "language": "Java", + "code": "client.security().oidcLogout(o -> o\n .refreshToken(\"vLBPvmAB6KvwvJZr27cS\")\n .token(\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\")\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\"]}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .ids(\"VuaCfGcBCdbkQm-e5aOx\")\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n username=\"myuser\",\n realm_name=\"native1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n username: \"myuser\",\n realm_name: \"native1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"username\": \"myuser\",\n \"realm_name\": \"native1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"username\" => \"myuser\",\n \"realm_name\" => \"native1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\",\"realm_name\":\"native1\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .realmName(\"native1\")\n .username(\"myuser\")\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n owner=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\"],\n owner: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n \"owner\": \"true\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n \"owner\" => \"true\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\"],\"owner\":\"true\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .ids(\"VuaCfGcBCdbkQm-e5aOx\")\n .owner(true)\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n username=\"myuser\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n username: \"myuser\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"username\": \"myuser\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"username\" => \"myuser\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .username(\"myuser\")\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n realm_name=\"native1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n realm_name: \"native1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"realm_name\": \"native1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"realm_name\" => \"native1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm_name\":\"native1\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .realmName(\"native1\")\n);\n" + } + ], + "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_api_key(\n name=\"my-api-key\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateApiKey({\n name: \"my-api-key\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_api_key(\n body: {\n \"name\": \"my-api-key\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"name\" => \"my-api-key\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-api-key\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" + }, + { + "language": "Java", + "code": "client.security().invalidateApiKey(i -> i\n .name(\"my-api-key\")\n);\n" + } + ], + "specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.bulk_update_api_keys(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n role_descriptors={\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n metadata={\n \"environment\": {\n \"level\": 2,\n \"trusted\": True,\n \"tags\": [\n \"production\"\n ]\n }\n },\n expiration=\"30d\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.bulkUpdateApiKeys({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\", \"H3_AhoIBA9hmeQJdg7ij\"],\n role_descriptors: {\n \"role-a\": {\n indices: [\n {\n names: [\"*\"],\n privileges: [\"write\"],\n },\n ],\n },\n },\n metadata: {\n environment: {\n level: 2,\n trusted: true,\n tags: [\"production\"],\n },\n },\n expiration: \"30d\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.bulk_update_api_keys(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n \"role_descriptors\": {\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"environment\": {\n \"level\": 2,\n \"trusted\": true,\n \"tags\": [\n \"production\"\n ]\n }\n },\n \"expiration\": \"30d\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->bulkUpdateApiKeys([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\",\n ),\n \"role_descriptors\" => [\n \"role-a\" => [\n \"indices\" => array(\n [\n \"names\" => array(\n \"*\",\n ),\n \"privileges\" => array(\n \"write\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"environment\" => [\n \"level\" => 2,\n \"trusted\" => true,\n \"tags\" => array(\n \"production\",\n ),\n ],\n ],\n \"expiration\" => \"30d\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"],\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}},\"expiration\":\"30d\"}' \"$ELASTICSEARCH_URL/_security/api_key/_bulk_update\"" + }, + { + "language": "Java", + "code": "client.security().bulkUpdateApiKeys(b -> b\n .expiration(e -> e\n .time(\"30d\")\n )\n .ids(List.of(\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"))\n .metadata(\"environment\", JsonData.fromJson(\"{\\\"level\\\":2,\\\"trusted\\\":true,\\\"tags\\\":[\\\"production\\\"]}\"))\n .roleDescriptors(\"role-a\", r -> r\n .indices(i -> i\n .names(\"*\")\n .privileges(\"write\")\n )\n )\n);\n" + } + ], + "specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.bulk_update_api_keys(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n role_descriptors={},\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.bulkUpdateApiKeys({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\", \"H3_AhoIBA9hmeQJdg7ij\"],\n role_descriptors: {},\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.bulk_update_api_keys(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n \"role_descriptors\": {}\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->bulkUpdateApiKeys([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\",\n ),\n \"role_descriptors\" => new ArrayObject([]),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"],\"role_descriptors\":{}}' \"$ELASTICSEARCH_URL/_security/api_key/_bulk_update\"" + }, + { + "language": "Java", + "code": "client.security().bulkUpdateApiKeys(b -> b\n .ids(List.of(\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"))\n);\n" + } + ], + "specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.suggest_user_profiles(\n name=\"jack\",\n hint={\n \"uids\": [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n ],\n \"labels\": {\n \"direction\": [\n \"north\",\n \"east\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.suggestUserProfiles({\n name: \"jack\",\n hint: {\n uids: [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n ],\n labels: {\n direction: [\"north\", \"east\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.suggest_user_profiles(\n body: {\n \"name\": \"jack\",\n \"hint\": {\n \"uids\": [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n ],\n \"labels\": {\n \"direction\": [\n \"north\",\n \"east\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->suggestUserProfiles([\n \"body\" => [\n \"name\" => \"jack\",\n \"hint\" => [\n \"uids\" => array(\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n ),\n \"labels\" => [\n \"direction\" => array(\n \"north\",\n \"east\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"jack\",\"hint\":{\"uids\":[\"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"],\"labels\":{\"direction\":[\"north\",\"east\"]}}}' \"$ELASTICSEARCH_URL/_security/profile/_suggest\"" + }, + { + "language": "Java", + "code": "client.security().suggestUserProfiles(s -> s\n .hint(h -> h\n .uids(List.of(\"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"))\n .labels(\"direction\", List.of(\"north\",\"east\"))\n )\n .name(\"jack\")\n);\n" + } + ], + "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_api_keys(\n query={\n \"term\": {\n \"name\": {\n \"value\": \"application-key-1\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryApiKeys({\n query: {\n term: {\n name: {\n value: \"application-key-1\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_api_keys(\n body: {\n \"query\": {\n \"term\": {\n \"name\": {\n \"value\": \"application-key-1\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryApiKeys([\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"name\" => [\n \"value\" => \"application-key-1\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"name\":{\"value\":\"application-key-1\"}}}}' \"$ELASTICSEARCH_URL/_security/_query/api_key\"" + }, + { + "language": "Java", + "code": "client.security().queryApiKeys(q -> q\n .query(qu -> qu\n .term(t -> t\n .field(\"name\")\n .value(FieldValue.of(\"application-key-1\"))\n )\n )\n);\n" + } + ], + "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_api_keys(\n query={\n \"bool\": {\n \"must\": [\n {\n \"prefix\": {\n \"name\": \"app1-key-\"\n }\n },\n {\n \"term\": {\n \"invalidated\": \"false\"\n }\n }\n ],\n \"must_not\": [\n {\n \"term\": {\n \"name\": \"app1-key-01\"\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"username\": \"org-*-user\"\n }\n },\n {\n \"term\": {\n \"metadata.environment\": \"production\"\n }\n }\n ]\n }\n },\n from=20,\n size=10,\n sort=[\n {\n \"creation\": {\n \"order\": \"desc\",\n \"format\": \"date_time\"\n }\n },\n \"name\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryApiKeys({\n query: {\n bool: {\n must: [\n {\n prefix: {\n name: \"app1-key-\",\n },\n },\n {\n term: {\n invalidated: \"false\",\n },\n },\n ],\n must_not: [\n {\n term: {\n name: \"app1-key-01\",\n },\n },\n ],\n filter: [\n {\n wildcard: {\n username: \"org-*-user\",\n },\n },\n {\n term: {\n \"metadata.environment\": \"production\",\n },\n },\n ],\n },\n },\n from: 20,\n size: 10,\n sort: [\n {\n creation: {\n order: \"desc\",\n format: \"date_time\",\n },\n },\n \"name\",\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_api_keys(\n body: {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"prefix\": {\n \"name\": \"app1-key-\"\n }\n },\n {\n \"term\": {\n \"invalidated\": \"false\"\n }\n }\n ],\n \"must_not\": [\n {\n \"term\": {\n \"name\": \"app1-key-01\"\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"username\": \"org-*-user\"\n }\n },\n {\n \"term\": {\n \"metadata.environment\": \"production\"\n }\n }\n ]\n }\n },\n \"from\": 20,\n \"size\": 10,\n \"sort\": [\n {\n \"creation\": {\n \"order\": \"desc\",\n \"format\": \"date_time\"\n }\n },\n \"name\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryApiKeys([\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"prefix\" => [\n \"name\" => \"app1-key-\",\n ],\n ],\n [\n \"term\" => [\n \"invalidated\" => \"false\",\n ],\n ],\n ),\n \"must_not\" => array(\n [\n \"term\" => [\n \"name\" => \"app1-key-01\",\n ],\n ],\n ),\n \"filter\" => array(\n [\n \"wildcard\" => [\n \"username\" => \"org-*-user\",\n ],\n ],\n [\n \"term\" => [\n \"metadata.environment\" => \"production\",\n ],\n ],\n ),\n ],\n ],\n \"from\" => 20,\n \"size\" => 10,\n \"sort\" => array(\n [\n \"creation\" => [\n \"order\" => \"desc\",\n \"format\" => \"date_time\",\n ],\n ],\n \"name\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"bool\":{\"must\":[{\"prefix\":{\"name\":\"app1-key-\"}},{\"term\":{\"invalidated\":\"false\"}}],\"must_not\":[{\"term\":{\"name\":\"app1-key-01\"}}],\"filter\":[{\"wildcard\":{\"username\":\"org-*-user\"}},{\"term\":{\"metadata.environment\":\"production\"}}]}},\"from\":20,\"size\":10,\"sort\":[{\"creation\":{\"order\":\"desc\",\"format\":\"date_time\"}},\"name\"]}' \"$ELASTICSEARCH_URL/_security/_query/api_key\"" + }, + { + "language": "Java", + "code": "client.security().queryApiKeys(q -> q\n .from(20)\n .query(qu -> qu\n .bool(b -> b\n .filter(List.of(Query.of(que -> que\n .wildcard(w -> w\n .field(\"username\")\n .value(\"org-*-user\")\n )),Query.of(quer -> quer\n .term(t -> t\n .field(\"metadata.environment\")\n .value(FieldValue.of(\"production\"))\n ))))\n .must(List.of(Query.of(query -> query\n .prefix(p -> p\n .field(\"name\")\n .value(\"app1-key-\")\n )),Query.of(query1 -> query1\n .term(t -> t\n .field(\"invalidated\")\n .value(FieldValue.of(\"false\"))\n ))))\n .mustNot(m -> m\n .term(t -> t\n .field(\"name\")\n .value(FieldValue.of(\"app1-key-01\"))\n )\n )\n )\n )\n .size(10)\n .sort(List.of(SortOptions.of(s -> s\n .field(f -> f\n .field(\"creation\")\n .order(SortOrder.Desc)\n .format(\"date_time\")\n )),SortOptions.of(so -> so\n .field(f -> f\n .field(\"name\")\n ))))\n);\n" + } + ], + "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_api_keys(\n with_limited_by=True,\n query={\n \"ids\": {\n \"values\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryApiKeys({\n with_limited_by: \"true\",\n query: {\n ids: {\n values: [\"VuaCfGcBCdbkQm-e5aOx\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_api_keys(\n with_limited_by: \"true\",\n body: {\n \"query\": {\n \"ids\": {\n \"values\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryApiKeys([\n \"with_limited_by\" => \"true\",\n \"body\" => [\n \"query\" => [\n \"ids\" => [\n \"values\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"ids\":{\"values\":[\"VuaCfGcBCdbkQm-e5aOx\"]}}}' \"$ELASTICSEARCH_URL/_security/_query/api_key?with_limited_by=true\"" + }, + { + "language": "Java", + "code": "client.security().queryApiKeys(q -> q\n .query(qu -> qu\n .ids(i -> i\n .values(\"VuaCfGcBCdbkQm-e5aOx\")\n )\n )\n .withLimitedBy(true)\n);\n" + } + ], + "specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.create_cross_cluster_api_key(\n name=\"my-cross-cluster-api-key\",\n expiration=\"1d\",\n access={\n \"search\": [\n {\n \"names\": [\n \"logs*\"\n ]\n }\n ],\n \"replication\": [\n {\n \"names\": [\n \"archive*\"\n ]\n }\n ]\n },\n metadata={\n \"description\": \"phase one\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.createCrossClusterApiKey({\n name: \"my-cross-cluster-api-key\",\n expiration: \"1d\",\n access: {\n search: [\n {\n names: [\"logs*\"],\n },\n ],\n replication: [\n {\n names: [\"archive*\"],\n },\n ],\n },\n metadata: {\n description: \"phase one\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.create_cross_cluster_api_key(\n body: {\n \"name\": \"my-cross-cluster-api-key\",\n \"expiration\": \"1d\",\n \"access\": {\n \"search\": [\n {\n \"names\": [\n \"logs*\"\n ]\n }\n ],\n \"replication\": [\n {\n \"names\": [\n \"archive*\"\n ]\n }\n ]\n },\n \"metadata\": {\n \"description\": \"phase one\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->createCrossClusterApiKey([\n \"body\" => [\n \"name\" => \"my-cross-cluster-api-key\",\n \"expiration\" => \"1d\",\n \"access\" => [\n \"search\" => array(\n [\n \"names\" => array(\n \"logs*\",\n ),\n ],\n ),\n \"replication\" => array(\n [\n \"names\" => array(\n \"archive*\",\n ),\n ],\n ),\n ],\n \"metadata\" => [\n \"description\" => \"phase one\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-cross-cluster-api-key\",\"expiration\":\"1d\",\"access\":{\"search\":[{\"names\":[\"logs*\"]}],\"replication\":[{\"names\":[\"archive*\"]}]},\"metadata\":{\"description\":\"phase one\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/cross_cluster/api_key\"" + }, + { + "language": "Java", + "code": "client.security().createCrossClusterApiKey(c -> c\n .access(a -> a\n .replication(r -> r\n .names(\"archive*\")\n )\n .search(s -> s\n .names(\"logs*\")\n )\n )\n .expiration(e -> e\n .time(\"1d\")\n )\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"description\", JsonData.fromJson(\"\\\"phase one\\\"\")))\n .name(\"my-cross-cluster-api-key\")\n);\n" + } + ], + "specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_authenticate(\n content=\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n ids=[\n \"4fee3b046395c4e751011e97f8900b5273d56685\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlAuthenticate({\n content:\n \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n ids: [\"4fee3b046395c4e751011e97f8900b5273d56685\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_authenticate(\n body: {\n \"content\": \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n \"ids\": [\n \"4fee3b046395c4e751011e97f8900b5273d56685\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlAuthenticate([\n \"body\" => [\n \"content\" => \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n \"ids\" => array(\n \"4fee3b046395c4e751011e97f8900b5273d56685\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"content\":\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\"ids\":[\"4fee3b046395c4e751011e97f8900b5273d56685\"]}' \"$ELASTICSEARCH_URL/_security/saml/authenticate\"" + }, + { + "language": "Java", + "code": "client.security().samlAuthenticate(s -> s\n .content(\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\")\n .ids(\"4fee3b046395c4e751011e97f8900b5273d56685\")\n);\n" + } + ], + "specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.change_password(\n username=\"jacknich\",\n password=\"new-test-password\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.changePassword({\n username: \"jacknich\",\n password: \"new-test-password\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.change_password(\n username: \"jacknich\",\n body: {\n \"password\": \"new-test-password\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->changePassword([\n \"username\" => \"jacknich\",\n \"body\" => [\n \"password\" => \"new-test-password\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"password\":\"new-test-password\"}' \"$ELASTICSEARCH_URL/_security/user/jacknich/_password\"" + }, + { + "language": "Java", + "code": "client.security().changePassword(c -> c\n .password(\"new-test-password\")\n .username(\"jacknich\")\n);\n" + } + ], + "specification/security/get_service_credentials/examples/request/GetServiceCredentialsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_service_credentials(\n namespace=\"elastic\",\n service=\"fleet-server\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getServiceCredentials({\n namespace: \"elastic\",\n service: \"fleet-server\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_service_credentials(\n namespace: \"elastic\",\n service: \"fleet-server\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getServiceCredentials([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential\"" + }, + { + "language": "Java", + "code": "client.security().getServiceCredentials(g -> g\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" + } + ], + "specification/security/get_role_mapping/examples/request/SecurityGetRoleMappingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_role_mapping(\n name=\"mapping1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getRoleMapping({\n name: \"mapping1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_role_mapping(\n name: \"mapping1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getRoleMapping([\n \"name\" => \"mapping1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" + }, + { + "language": "Java", + "code": "client.security().getRoleMapping(g -> g\n .name(\"mapping1\")\n);\n" + } + ], + "specification/security/disable_user_profile/examples/request/SecurityDisableUserProfileExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.disable_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.disableUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.disable_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->disableUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0/_disable\"" + }, + { + "language": "Java", + "code": "client.security().disableUserProfile(d -> d\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" + } + ], + "specification/security/get_user_privileges/examples/request/SecurityGetUserPrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_user_privileges()" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getUserPrivileges();" + }, + { + "language": "Ruby", + "code": "response = client.security.get_user_privileges" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getUserPrivileges();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/_privileges\"" + }, + { + "language": "Java", + "code": "client.security().getUserPrivileges(g -> g);\n" + } + ], + "specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_role(\n query={\n \"match\": {\n \"description\": {\n \"query\": \"user access\"\n }\n }\n },\n size=1,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryRole({\n query: {\n match: {\n description: {\n query: \"user access\",\n },\n },\n },\n size: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_role(\n body: {\n \"query\": {\n \"match\": {\n \"description\": {\n \"query\": \"user access\"\n }\n }\n },\n \"size\": 1\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryRole([\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"description\" => [\n \"query\" => \"user access\",\n ],\n ],\n ],\n \"size\" => 1,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"description\":{\"query\":\"user access\"}}},\"size\":1}' \"$ELASTICSEARCH_URL/_security/_query/role\"" + }, + { + "language": "Java", + "code": "client.security().queryRole(q -> q\n .query(qu -> qu\n .match(m -> m\n .field(\"description\")\n .query(FieldValue.of(\"user access\"))\n )\n )\n .size(1)\n);\n" + } + ], + "specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_role(\n sort=[\n \"name\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryRole({\n sort: [\"name\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_role(\n body: {\n \"sort\": [\n \"name\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryRole([\n \"body\" => [\n \"sort\" => array(\n \"name\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":[\"name\"]}' \"$ELASTICSEARCH_URL/_security/_query/role\"" + }, + { + "language": "Java", + "code": "client.security().queryRole(q -> q\n .sort(s -> s\n .field(f -> f\n .field(\"name\")\n )\n )\n);\n" + } + ], + "specification/security/delete_privileges/examples/request/SecurityDeletePrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.delete_privileges(\n application=\"myapp\",\n name=\"read\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.deletePrivileges({\n application: \"myapp\",\n name: \"read\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.delete_privileges(\n application: \"myapp\",\n name: \"read\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->deletePrivileges([\n \"application\" => \"myapp\",\n \"name\" => \"read\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/read\"" + }, + { + "language": "Java", + "code": "client.security().deletePrivileges(d -> d\n .application(\"myapp\")\n .name(\"read\")\n);\n" + } + ], + "specification/security/clear_cached_privileges/examples/request/SecurityClearCachedPrivilegesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.clear_cached_privileges(\n application=\"myapp\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.clearCachedPrivileges({\n application: \"myapp\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.clear_cached_privileges(\n application: \"myapp\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->clearCachedPrivileges([\n \"application\" => \"myapp\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/_clear_cache\"" + }, + { + "language": "Java", + "code": "client.security().clearCachedPrivileges(c -> c\n .application(\"myapp\")\n);\n" + } + ], + "specification/security/create_service_token/examples/request/CreateServiceTokenRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.create_service_token(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.createServiceToken({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.create_service_token(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->createServiceToken([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token1\"" + }, + { + "language": "Java", + "code": "client.security().createServiceToken(c -> c\n .name(\"token1\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" + } + ], + "specification/security/delete_user/examples/request/SecurityDeleteUserRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.delete_user(\n username=\"jacknich\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.deleteUser({\n username: \"jacknich\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.delete_user(\n username: \"jacknich\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->deleteUser([\n \"username\" => \"jacknich\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich\"" + }, + { + "language": "Java", + "code": "client.security().deleteUser(d -> d\n .username(\"jacknich\")\n);\n" + } + ], + "specification/security/clear_cached_realms/examples/request/SecurityClearCachedRealmsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.clear_cached_realms(\n realms=\"default_file\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.clearCachedRealms({\n realms: \"default_file\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.clear_cached_realms(\n realms: \"default_file\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->clearCachedRealms([\n \"realms\" => \"default_file\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/realm/default_file/_clear_cache\"" + }, + { + "language": "Java", + "code": "client.security().clearCachedRealms(c -> c\n .realms(\"default_file\")\n);\n" + } + ], + "specification/security/get_user/examples/request/SecurityGetUserRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_user(\n username=\"jacknich\",\n with_profile_uid=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getUser({\n username: \"jacknich\",\n with_profile_uid: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_user(\n username: \"jacknich\",\n with_profile_uid: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getUser([\n \"username\" => \"jacknich\",\n \"with_profile_uid\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich?with_profile_uid=true\"" + }, + { + "language": "Java", + "code": "client.security().getUser(g -> g\n .username(\"jacknich\")\n .withProfileUid(true)\n);\n" + } + ], + "specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_user_profile_data(\n uid=\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n labels={\n \"direction\": \"east\"\n },\n data={\n \"app1\": {\n \"theme\": \"default\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateUserProfileData({\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n labels: {\n direction: \"east\",\n },\n data: {\n app1: {\n theme: \"default\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_user_profile_data(\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n body: {\n \"labels\": {\n \"direction\": \"east\"\n },\n \"data\": {\n \"app1\": {\n \"theme\": \"default\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateUserProfileData([\n \"uid\" => \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n \"body\" => [\n \"labels\" => [\n \"direction\" => \"east\",\n ],\n \"data\" => [\n \"app1\" => [\n \"theme\" => \"default\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"labels\":{\"direction\":\"east\"},\"data\":{\"app1\":{\"theme\":\"default\"}}}' \"$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data\"" + }, + { + "language": "Java", + "code": "client.security().updateUserProfileData(u -> u\n .data(\"app1\", JsonData.fromJson(\"{\\\"theme\\\":\\\"default\\\"}\"))\n .labels(\"direction\", JsonData.fromJson(\"\\\"east\\\"\"))\n .uid(\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\")\n);\n" + } + ], + "specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"POST\",\n \"/_security/delegate_pki\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"x509_certificate_chain\": [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_security/delegate_pki\",\n body: {\n x509_certificate_chain: [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\",\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"POST\",\n \"/_security/delegate_pki\",\n {},\n {\n \"x509_certificate_chain\": [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"\n ]\n },\n { \"Content-Type\": \"application/json\" },\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_security/delegate_pki\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"x509_certificate_chain\" => array(\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\",\n ),\n ]),\n));\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"x509_certificate_chain\":[\"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"]}' \"$ELASTICSEARCH_URL/_security/delegate_pki\"" + }, + { + "language": "Java", + "code": "client.security().delegatePki(d -> d\n .x509CertificateChain(\"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\")\n);\n" + } + ], + "specification/security/enable_user/examples/request/SecurityEnableUserExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.enable_user(\n username=\"logstash_system\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.enableUser({\n username: \"logstash_system\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.enable_user(\n username: \"logstash_system\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->enableUser([\n \"username\" => \"logstash_system\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/logstash_system/_enable\"" + }, + { + "language": "Java", + "code": "client.security().enableUser(e -> e\n .username(\"logstash_system\")\n);\n" + } + ], + "specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_user(\n username=\"jacknich\",\n password=\"l0ng-r4nd0m-p@ssw0rd\",\n roles=[\n \"admin\",\n \"other_role1\"\n ],\n full_name=\"Jack Nicholson\",\n email=\"jacknich@example.com\",\n metadata={\n \"intelligence\": 7\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putUser({\n username: \"jacknich\",\n password: \"l0ng-r4nd0m-p@ssw0rd\",\n roles: [\"admin\", \"other_role1\"],\n full_name: \"Jack Nicholson\",\n email: \"jacknich@example.com\",\n metadata: {\n intelligence: 7,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_user(\n username: \"jacknich\",\n body: {\n \"password\": \"l0ng-r4nd0m-p@ssw0rd\",\n \"roles\": [\n \"admin\",\n \"other_role1\"\n ],\n \"full_name\": \"Jack Nicholson\",\n \"email\": \"jacknich@example.com\",\n \"metadata\": {\n \"intelligence\": 7\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putUser([\n \"username\" => \"jacknich\",\n \"body\" => [\n \"password\" => \"l0ng-r4nd0m-p@ssw0rd\",\n \"roles\" => array(\n \"admin\",\n \"other_role1\",\n ),\n \"full_name\" => \"Jack Nicholson\",\n \"email\" => \"jacknich@example.com\",\n \"metadata\" => [\n \"intelligence\" => 7,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"password\":\"l0ng-r4nd0m-p@ssw0rd\",\"roles\":[\"admin\",\"other_role1\"],\"full_name\":\"Jack Nicholson\",\"email\":\"jacknich@example.com\",\"metadata\":{\"intelligence\":7}}' \"$ELASTICSEARCH_URL/_security/user/jacknich\"" + }, + { + "language": "Java", + "code": "client.security().putUser(p -> p\n .email(\"jacknich@example.com\")\n .fullName(\"Jack Nicholson\")\n .metadata(\"intelligence\", JsonData.fromJson(\"7\"))\n .password(\"l0ng-r4nd0m-p@ssw0rd\")\n .roles(List.of(\"admin\",\"other_role1\"))\n .username(\"jacknich\")\n);\n" + } + ], + "specification/security/clear_api_key_cache/examples/request/SecurityClearApiKeyCacheExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.clear_api_key_cache(\n ids=\"yVGMr3QByxdh1MSaicYx\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.clearApiKeyCache({\n ids: \"yVGMr3QByxdh1MSaicYx\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.clear_api_key_cache(\n ids: \"yVGMr3QByxdh1MSaicYx\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->clearApiKeyCache([\n \"ids\" => \"yVGMr3QByxdh1MSaicYx\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/api_key/yVGMr3QByxdh1MSaicYx/_clear_cache\"" + }, + { + "language": "Java", + "code": "client.security().clearApiKeyCache(c -> c\n .ids(\"yVGMr3QByxdh1MSaicYx\")\n);\n" + } + ], + "specification/security/get_api_key/examples/request/SecurityGetApiKeyRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_api_key(\n username=\"myuser\",\n realm_name=\"native1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getApiKey({\n username: \"myuser\",\n realm_name: \"native1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_api_key(\n username: \"myuser\",\n realm_name: \"native1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getApiKey([\n \"username\" => \"myuser\",\n \"realm_name\" => \"native1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/api_key?username=myuser&realm_name=native1\"" + }, + { + "language": "Java", + "code": "client.security().getApiKey(g -> g\n .realmName(\"native1\")\n .username(\"myuser\")\n);\n" + } + ], + "specification/security/clear_cached_service_tokens/examples/request/SecurityClearCachedServiceTokensExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.clear_cached_service_tokens(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.clearCachedServiceTokens({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.clear_cached_service_tokens(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->clearCachedServiceTokens([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token1/_clear_cache\"" + }, + { + "language": "Java", + "code": "client.security().clearCachedServiceTokens(c -> c\n .name(\"token1\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" + } + ], + "specification/security/enable_user_profile/examples/request/SecurityEnableUserProfileExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.enable_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.enableUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.enable_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->enableUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0/_enable\"" + }, + { + "language": "Java", + "code": "client.security().enableUserProfile(e -> e\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping7\",\n roles=[\n \"ldap-example-user\"\n ],\n enabled=True,\n rules={\n \"all\": [\n {\n \"field\": {\n \"dn\": \"*,ou=subtree,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping7\",\n roles: [\"ldap-example-user\"],\n enabled: true,\n rules: {\n all: [\n {\n field: {\n dn: \"*,ou=subtree,dc=example,dc=com\",\n },\n },\n {\n field: {\n \"realm.name\": \"ldap1\",\n },\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping7\",\n body: {\n \"roles\": [\n \"ldap-example-user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"all\": [\n {\n \"field\": {\n \"dn\": \"*,ou=subtree,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping7\",\n \"body\" => [\n \"roles\" => array(\n \"ldap-example-user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"all\" => array(\n [\n \"field\" => [\n \"dn\" => \"*,ou=subtree,dc=example,dc=com\",\n ],\n ],\n [\n \"field\" => [\n \"realm.name\" => \"ldap1\",\n ],\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"ldap-example-user\"],\"enabled\":true,\"rules\":{\"all\":[{\"field\":{\"dn\":\"*,ou=subtree,dc=example,dc=com\"}},{\"field\":{\"realm.name\":\"ldap1\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping7\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping7\")\n .roles(\"ldap-example-user\")\n .rules(r -> r\n .all(List.of(RoleMappingRule.of(ro -> ro\n .field(NamedValue.of(\"dn\",List.of(FieldValue.of(\"*,ou=subtree,dc=example,dc=com\"))\n ))), RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"ldap1\"))\n )))\n )\n )\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping6\",\n role_templates=[\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n rules={\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n enabled=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping6\",\n role_templates: [\n {\n template: {\n source: \"{{#tojson}}groups{{/tojson}}\",\n },\n format: \"json\",\n },\n ],\n rules: {\n field: {\n \"realm.name\": \"saml1\",\n },\n },\n enabled: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping6\",\n body: {\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n \"rules\": {\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n \"enabled\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping6\",\n \"body\" => [\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"{{#tojson}}groups{{/tojson}}\",\n ],\n \"format\" => \"json\",\n ],\n ),\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"saml1\",\n ],\n ],\n \"enabled\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping6\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping6\")\n .roleTemplates(r -> r\n .format(TemplateFormat.Json)\n .template(t -> t\n .source(s -> s\n .scriptString(\"{{#tojson}}groups{{/tojson}}\")\n )\n )\n )\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"saml1\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping1\",\n roles=[\n \"user\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"username\": \"*\"\n }\n },\n metadata={\n \"version\": 1\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping1\",\n roles: [\"user\"],\n enabled: true,\n rules: {\n field: {\n username: \"*\",\n },\n },\n metadata: {\n version: 1,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping1\",\n body: {\n \"roles\": [\n \"user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"username\": \"*\"\n }\n },\n \"metadata\": {\n \"version\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping1\",\n \"body\" => [\n \"roles\" => array(\n \"user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"username\" => \"*\",\n ],\n ],\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"user\"],\"enabled\":true,\"rules\":{\"field\":{\"username\":\"*\"}},\"metadata\":{\"version\":1}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .name(\"mapping1\")\n .roles(\"user\")\n .rules(r -> r\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"*\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping3\",\n roles=[\n \"ldap-user\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping3\",\n roles: [\"ldap-user\"],\n enabled: true,\n rules: {\n field: {\n \"realm.name\": \"ldap1\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping3\",\n body: {\n \"roles\": [\n \"ldap-user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping3\",\n \"body\" => [\n \"roles\" => array(\n \"ldap-user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"ldap1\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"ldap-user\"],\"enabled\":true,\"rules\":{\"field\":{\"realm.name\":\"ldap1\"}}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping3\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping3\")\n .roles(\"ldap-user\")\n .rules(r -> r\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"ldap1\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping2\",\n roles=[\n \"user\",\n \"admin\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"username\": [\n \"esadmin01\",\n \"esadmin02\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping2\",\n roles: [\"user\", \"admin\"],\n enabled: true,\n rules: {\n field: {\n username: [\"esadmin01\", \"esadmin02\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping2\",\n body: {\n \"roles\": [\n \"user\",\n \"admin\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"username\": [\n \"esadmin01\",\n \"esadmin02\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping2\",\n \"body\" => [\n \"roles\" => array(\n \"user\",\n \"admin\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"username\" => array(\n \"esadmin01\",\n \"esadmin02\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"user\",\"admin\"],\"enabled\":true,\"rules\":{\"field\":{\"username\":[\"esadmin01\",\"esadmin02\"]}}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping2\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping2\")\n .roles(List.of(\"user\",\"admin\"))\n .rules(r -> r\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"esadmin01\"),FieldValue.of(\"esadmin02\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping9\",\n rules={\n \"field\": {\n \"realm.name\": \"cloud-saml\"\n }\n },\n role_templates=[\n {\n \"template\": {\n \"source\": \"saml_user\"\n }\n },\n {\n \"template\": {\n \"source\": \"_user_{{username}}\"\n }\n }\n ],\n enabled=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping9\",\n rules: {\n field: {\n \"realm.name\": \"cloud-saml\",\n },\n },\n role_templates: [\n {\n template: {\n source: \"saml_user\",\n },\n },\n {\n template: {\n source: \"_user_{{username}}\",\n },\n },\n ],\n enabled: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping9\",\n body: {\n \"rules\": {\n \"field\": {\n \"realm.name\": \"cloud-saml\"\n }\n },\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"saml_user\"\n }\n },\n {\n \"template\": {\n \"source\": \"_user_{{username}}\"\n }\n }\n ],\n \"enabled\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping9\",\n \"body\" => [\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"cloud-saml\",\n ],\n ],\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"saml_user\",\n ],\n ],\n [\n \"template\" => [\n \"source\" => \"_user_{{username}}\",\n ],\n ],\n ),\n \"enabled\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":{\"field\":{\"realm.name\":\"cloud-saml\"}},\"role_templates\":[{\"template\":{\"source\":\"saml_user\"}},{\"template\":{\"source\":\"_user_{{username}}\"}}],\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping9\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping9\")\n .roleTemplates(List.of(RoleTemplate.of(r -> r\n .template(t -> t\n .source(s -> s\n .scriptString(\"saml_user\")\n )\n )),RoleTemplate.of(ro -> ro\n .template(t -> t\n .source(s -> s\n .scriptString(\"_user_{{username}}\")\n )\n ))))\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"cloud-saml\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping5\",\n role_templates=[\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n rules={\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n enabled=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping5\",\n role_templates: [\n {\n template: {\n source: \"{{#tojson}}groups{{/tojson}}\",\n },\n format: \"json\",\n },\n ],\n rules: {\n field: {\n \"realm.name\": \"saml1\",\n },\n },\n enabled: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping5\",\n body: {\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n \"rules\": {\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n \"enabled\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping5\",\n \"body\" => [\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"{{#tojson}}groups{{/tojson}}\",\n ],\n \"format\" => \"json\",\n ],\n ),\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"saml1\",\n ],\n ],\n \"enabled\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping5\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping5\")\n .roleTemplates(r -> r\n .format(TemplateFormat.Json)\n .template(t -> t\n .source(s -> s\n .scriptString(\"{{#tojson}}groups{{/tojson}}\")\n )\n )\n )\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"saml1\"))))\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping4\",\n roles=[\n \"superuser\"\n ],\n enabled=True,\n rules={\n \"any\": [\n {\n \"field\": {\n \"username\": \"esadmin\"\n }\n },\n {\n \"field\": {\n \"groups\": \"cn=admins,dc=example,dc=com\"\n }\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping4\",\n roles: [\"superuser\"],\n enabled: true,\n rules: {\n any: [\n {\n field: {\n username: \"esadmin\",\n },\n },\n {\n field: {\n groups: \"cn=admins,dc=example,dc=com\",\n },\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping4\",\n body: {\n \"roles\": [\n \"superuser\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"any\": [\n {\n \"field\": {\n \"username\": \"esadmin\"\n }\n },\n {\n \"field\": {\n \"groups\": \"cn=admins,dc=example,dc=com\"\n }\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping4\",\n \"body\" => [\n \"roles\" => array(\n \"superuser\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"any\" => array(\n [\n \"field\" => [\n \"username\" => \"esadmin\",\n ],\n ],\n [\n \"field\" => [\n \"groups\" => \"cn=admins,dc=example,dc=com\",\n ],\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"any\":[{\"field\":{\"username\":\"esadmin\"}},{\"field\":{\"groups\":\"cn=admins,dc=example,dc=com\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping4\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping4\")\n .roles(\"superuser\")\n .rules(r -> r\n .any(List.of(RoleMappingRule.of(ro -> ro\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"esadmin\"))\n ))), RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"groups\",List.of(FieldValue.of(\"cn=admins,dc=example,dc=com\"))\n )))\n )\n )\n )\n);\n" + } + ], + "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role_mapping(\n name=\"mapping8\",\n roles=[\n \"superuser\"\n ],\n enabled=True,\n rules={\n \"all\": [\n {\n \"any\": [\n {\n \"field\": {\n \"dn\": \"*,ou=admin,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"username\": [\n \"es-admin\",\n \"es-system\"\n ]\n }\n }\n ]\n },\n {\n \"field\": {\n \"groups\": \"cn=people,dc=example,dc=com\"\n }\n },\n {\n \"except\": {\n \"field\": {\n \"metadata.terminated_date\": None\n }\n }\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRoleMapping({\n name: \"mapping8\",\n roles: [\"superuser\"],\n enabled: true,\n rules: {\n all: [\n {\n any: [\n {\n field: {\n dn: \"*,ou=admin,dc=example,dc=com\",\n },\n },\n {\n field: {\n username: [\"es-admin\", \"es-system\"],\n },\n },\n ],\n },\n {\n field: {\n groups: \"cn=people,dc=example,dc=com\",\n },\n },\n {\n except: {\n field: {\n \"metadata.terminated_date\": null,\n },\n },\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role_mapping(\n name: \"mapping8\",\n body: {\n \"roles\": [\n \"superuser\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"all\": [\n {\n \"any\": [\n {\n \"field\": {\n \"dn\": \"*,ou=admin,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"username\": [\n \"es-admin\",\n \"es-system\"\n ]\n }\n }\n ]\n },\n {\n \"field\": {\n \"groups\": \"cn=people,dc=example,dc=com\"\n }\n },\n {\n \"except\": {\n \"field\": {\n \"metadata.terminated_date\": nil\n }\n }\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping8\",\n \"body\" => [\n \"roles\" => array(\n \"superuser\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"all\" => array(\n [\n \"any\" => array(\n [\n \"field\" => [\n \"dn\" => \"*,ou=admin,dc=example,dc=com\",\n ],\n ],\n [\n \"field\" => [\n \"username\" => array(\n \"es-admin\",\n \"es-system\",\n ),\n ],\n ],\n ),\n ],\n [\n \"field\" => [\n \"groups\" => \"cn=people,dc=example,dc=com\",\n ],\n ],\n [\n \"except\" => [\n \"field\" => [\n \"metadata.terminated_date\" => null,\n ],\n ],\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"all\":[{\"any\":[{\"field\":{\"dn\":\"*,ou=admin,dc=example,dc=com\"}},{\"field\":{\"username\":[\"es-admin\",\"es-system\"]}}]},{\"field\":{\"groups\":\"cn=people,dc=example,dc=com\"}},{\"except\":{\"field\":{\"metadata.terminated_date\":null}}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping8\"" + }, + { + "language": "Java", + "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping8\")\n .roles(\"superuser\")\n .rules(r -> r\n .all(List.of(RoleMappingRule.of(ro -> ro\n .any(List.of(RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"dn\", List.of(FieldValue.of(\"*,ou=admin,\" +\n \"dc=example,dc=com\"))\n ))\n ), RoleMappingRule.of(role -> role\n .field(NamedValue.of(\"username\", List.of(FieldValue.of(\"es-admin\"),\n FieldValue.of(\"es-system\"))\n )))), RoleMappingRule.of(roleM -> roleM\n .field(NamedValue.of(\"groups\", List.of(FieldValue.of(\"cn=people,\" +\n \"dc=example,dc=com\"))\n )), RoleMappingRule.of(roleMa -> roleMa\n .except(e -> e\n .field(NamedValue.of(\"metadata.terminated_date\",\n List.of(FieldValue.of(null))\n )\n ))))\n )\n )\n )\n )\n )\n);\n" + } + ], + "specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_prepare_authentication(\n realm=\"saml1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlPrepareAuthentication({\n realm: \"saml1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_prepare_authentication(\n body: {\n \"realm\": \"saml1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"saml1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/saml/prepare\"" + }, + { + "language": "Java", + "code": "client.security().samlPrepareAuthentication(s -> s\n .realm(\"saml1\")\n);\n" + } + ], + "specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_prepare_authentication(\n acs=\"https://kibana.org/api/security/saml/callback\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlPrepareAuthentication({\n acs: \"https://kibana.org/api/security/saml/callback\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_prepare_authentication(\n body: {\n \"acs\": \"https://kibana.org/api/security/saml/callback\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlPrepareAuthentication([\n \"body\" => [\n \"acs\" => \"https://kibana.org/api/security/saml/callback\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"acs\":\"https://kibana.org/api/security/saml/callback\"}' \"$ELASTICSEARCH_URL/_security/saml/prepare\"" + }, + { + "language": "Java", + "code": "client.security().samlPrepareAuthentication(s -> s\n .acs(\"https://kibana.org/api/security/saml/callback\")\n);\n" + } + ], + "specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_invalidate(\n query_string=\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n realm=\"saml1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlInvalidate({\n query_string:\n \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n realm: \"saml1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_invalidate(\n body: {\n \"query_string\": \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n \"realm\": \"saml1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlInvalidate([\n \"body\" => [\n \"query_string\" => \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n \"realm\" => \"saml1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query_string\":\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\"realm\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/saml/invalidate\"" + }, + { + "language": "Java", + "code": "client.security().samlInvalidate(s -> s\n .queryString(\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\")\n .realm(\"saml1\")\n);\n" + } + ], + "specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_token(\n grant_type=\"client_credentials\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getToken({\n grant_type: \"client_credentials\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_token(\n body: {\n \"grant_type\": \"client_credentials\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getToken([\n \"body\" => [\n \"grant_type\" => \"client_credentials\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"client_credentials\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().getToken(g -> g\n .grantType(AccessTokenGrantType.ClientCredentials)\n);\n" + } + ], + "specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_token(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getToken({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_token(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getToken([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().getToken(g -> g\n .grantType(AccessTokenGrantType.Password)\n .password(\"x-pack-test-password\")\n .username(\"test_admin\")\n);\n" + } + ], + "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.bulk_put_role(\n roles={\n \"my_admin_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.bulkPutRole({\n roles: {\n my_admin_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n my_user_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\"],\n privileges: [\"read\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.bulk_put_role(\n body: {\n \"roles\": {\n \"my_admin_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->bulkPutRole([\n \"body\" => [\n \"roles\" => [\n \"my_admin_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n \"my_user_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":{\"my_admin_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}},\"my_user_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\"],\"privileges\":[\"read\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" + }, + { + "language": "Java", + "code": "client.security().bulkPutRole(b -> b\n .roles(Map.of(\"my_admin_role\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\")),\"my_user_role\", RoleDescriptor.of(ro -> ro\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(\"index1\")\n .privileges(\"read\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\"))))\n);\n" + } + ], + "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role(\n name=\"only_remote_access_role\",\n remote_indices=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n remote_cluster=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRole({\n name: \"only_remote_access_role\",\n remote_indices: [\n {\n clusters: [\"my_remote\"],\n names: [\"logs*\"],\n privileges: [\"read\", \"read_cross_cluster\", \"view_index_metadata\"],\n },\n ],\n remote_cluster: [\n {\n clusters: [\"my_remote\"],\n privileges: [\"monitor_stats\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role(\n name: \"only_remote_access_role\",\n body: {\n \"remote_indices\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n \"remote_cluster\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRole([\n \"name\" => \"only_remote_access_role\",\n \"body\" => [\n \"remote_indices\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"names\" => array(\n \"logs*\",\n ),\n \"privileges\" => array(\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\",\n ),\n ],\n ),\n \"remote_cluster\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"privileges\" => array(\n \"monitor_stats\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"view_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" + }, + { + "language": "Java", + "code": "client.security().putRole(p -> p\n .name(\"only_remote_access_role\")\n .remoteCluster(r -> r\n .clusters(\"my_remote\")\n .privileges(RemoteClusterPrivilege.MonitorStats)\n )\n .remoteIndices(r -> r\n .clusters(\"my_remote\")\n .names(\"logs*\")\n .privileges(List.of(\"read\",\"read_cross_cluster\",\"view_index_metadata\"))\n )\n);\n" + } + ], + "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.bulk_put_role(\n roles={\n \"my_admin_role\": {\n \"cluster\": [\n \"bad_cluster_privilege\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.bulkPutRole({\n roles: {\n my_admin_role: {\n cluster: [\"bad_cluster_privilege\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n my_user_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\"],\n privileges: [\"read\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.bulk_put_role(\n body: {\n \"roles\": {\n \"my_admin_role\": {\n \"cluster\": [\n \"bad_cluster_privilege\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->bulkPutRole([\n \"body\" => [\n \"roles\" => [\n \"my_admin_role\" => [\n \"cluster\" => array(\n \"bad_cluster_privilege\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n \"my_user_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":{\"my_admin_role\":{\"cluster\":[\"bad_cluster_privilege\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}},\"my_user_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\"],\"privileges\":[\"read\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" + }, + { + "language": "Java", + "code": "client.security().bulkPutRole(b -> b\n .roles(Map.of(\"my_admin_role\", RoleDescriptor.of(r -> r\n .cluster(\"bad_cluster_privilege\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\")),\"my_user_role\", RoleDescriptor.of(ro -> ro\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(\"index1\")\n .privileges(\"read\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\"))))\n);\n" + } + ], + "specification/security/get_role/examples/request/SecurityGetRoleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_role(\n name=\"my_admin_role\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getRole({\n name: \"my_admin_role\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_role(\n name: \"my_admin_role\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getRole([\n \"name\" => \"my_admin_role\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" + }, + { + "language": "Java", + "code": "client.security().getRole(g -> g\n .name(\"my_admin_role\")\n);\n" + } + ], + "specification/security/delete_role/examples/request/SecurityDeleteRoleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.delete_role(\n name=\"my_admin_role\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.deleteRole({\n name: \"my_admin_role\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.delete_role(\n name: \"my_admin_role\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->deleteRole([\n \"name\" => \"my_admin_role\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" + }, + { + "language": "Java", + "code": "client.security().deleteRole(d -> d\n .name(\"my_admin_role\")\n);\n" + } + ], + "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_token(\n username=\"myuser\",\n realm_name=\"saml1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateToken({\n username: \"myuser\",\n realm_name: \"saml1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_token(\n body: {\n \"username\": \"myuser\",\n \"realm_name\": \"saml1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"username\" => \"myuser\",\n \"realm_name\" => \"saml1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\",\"realm_name\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().invalidateToken(i -> i\n .realmName(\"saml1\")\n .username(\"myuser\")\n);\n" + } + ], + "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_token(\n username=\"myuser\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateToken({\n username: \"myuser\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_token(\n body: {\n \"username\": \"myuser\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"username\" => \"myuser\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().invalidateToken(i -> i\n .username(\"myuser\")\n);\n" + } + ], + "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_token(\n realm_name=\"saml1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateToken({\n realm_name: \"saml1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_token(\n body: {\n \"realm_name\": \"saml1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"realm_name\" => \"saml1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm_name\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().invalidateToken(i -> i\n .realmName(\"saml1\")\n);\n" + } + ], + "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_token(\n refresh_token=\"vLBPvmAB6KvwvJZr27cS\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateToken({\n refresh_token: \"vLBPvmAB6KvwvJZr27cS\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_token(\n body: {\n \"refresh_token\": \"vLBPvmAB6KvwvJZr27cS\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"refresh_token\" => \"vLBPvmAB6KvwvJZr27cS\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"refresh_token\":\"vLBPvmAB6KvwvJZr27cS\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().invalidateToken(i -> i\n .refreshToken(\"vLBPvmAB6KvwvJZr27cS\")\n);\n" + } + ], + "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.invalidate_token(\n token=\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.invalidateToken({\n token:\n \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.invalidate_token(\n body: {\n \"token\": \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"token\" => \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" + }, + { + "language": "Java", + "code": "client.security().invalidateToken(i -> i\n .token(\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\")\n);\n" + } + ], + "specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_user(\n query={\n \"bool\": {\n \"must\": [\n {\n \"wildcard\": {\n \"email\": \"*example.com\"\n }\n },\n {\n \"term\": {\n \"enabled\": True\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"roles\": \"*other*\"\n }\n }\n ]\n }\n },\n from=1,\n size=2,\n sort=[\n {\n \"username\": {\n \"order\": \"desc\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryUser({\n query: {\n bool: {\n must: [\n {\n wildcard: {\n email: \"*example.com\",\n },\n },\n {\n term: {\n enabled: true,\n },\n },\n ],\n filter: [\n {\n wildcard: {\n roles: \"*other*\",\n },\n },\n ],\n },\n },\n from: 1,\n size: 2,\n sort: [\n {\n username: {\n order: \"desc\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_user(\n body: {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"wildcard\": {\n \"email\": \"*example.com\"\n }\n },\n {\n \"term\": {\n \"enabled\": true\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"roles\": \"*other*\"\n }\n }\n ]\n }\n },\n \"from\": 1,\n \"size\": 2,\n \"sort\": [\n {\n \"username\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryUser([\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"wildcard\" => [\n \"email\" => \"*example.com\",\n ],\n ],\n [\n \"term\" => [\n \"enabled\" => true,\n ],\n ],\n ),\n \"filter\" => array(\n [\n \"wildcard\" => [\n \"roles\" => \"*other*\",\n ],\n ],\n ),\n ],\n ],\n \"from\" => 1,\n \"size\" => 2,\n \"sort\" => array(\n [\n \"username\" => [\n \"order\" => \"desc\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"bool\":{\"must\":[{\"wildcard\":{\"email\":\"*example.com\"}},{\"term\":{\"enabled\":true}}],\"filter\":[{\"wildcard\":{\"roles\":\"*other*\"}}]}},\"from\":1,\"size\":2,\"sort\":[{\"username\":{\"order\":\"desc\"}}]}' \"$ELASTICSEARCH_URL/_security/_query/user\"" + }, + { + "language": "Java", + "code": "client.security().queryUser(q -> q\n .from(1)\n .query(qu -> qu\n .bool(b -> b\n .filter(f -> f\n .wildcard(w -> w\n .field(\"roles\")\n .value(\"*other*\")\n )\n )\n .must(List.of(Query.of(que -> que\n .wildcard(w -> w\n .field(\"email\")\n .value(\"*example.com\")\n )),Query.of(quer -> quer\n .term(t -> t\n .field(\"enabled\")\n .value(FieldValue.of(true))\n ))))\n )\n )\n .size(2)\n .sort(s -> s\n .field(fi -> fi\n .field(\"username\")\n .order(SortOrder.Desc)\n )\n )\n);\n" + } + ], + "specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.query_user(\n with_profile_uid=True,\n query={\n \"prefix\": {\n \"roles\": \"other\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.queryUser({\n with_profile_uid: \"true\",\n query: {\n prefix: {\n roles: \"other\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.query_user(\n with_profile_uid: \"true\",\n body: {\n \"query\": {\n \"prefix\": {\n \"roles\": \"other\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->queryUser([\n \"with_profile_uid\" => \"true\",\n \"body\" => [\n \"query\" => [\n \"prefix\" => [\n \"roles\" => \"other\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"prefix\":{\"roles\":\"other\"}}}' \"$ELASTICSEARCH_URL/_security/_query/user?with_profile_uid=true\"" + }, + { + "language": "Java", + "code": "client.security().queryUser(q -> q\n .query(qu -> qu\n .prefix(p -> p\n .field(\"roles\")\n .value(\"other\")\n )\n )\n .withProfileUid(true)\n);\n" + } + ], + "specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_user_profile_data(\n uid=\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateUserProfileData({\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_user_profile_data(\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateUserProfileData([\n \"uid\" => \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data\"" + }, + { + "language": "Java", + "code": "client.security().updateUserProfileData(u -> u\n .uid(\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\")\n);\n" + } + ], + "specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors={\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n metadata={\n \"environment\": {\n \"level\": 2,\n \"trusted\": True,\n \"tags\": [\n \"production\"\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors: {\n \"role-a\": {\n indices: [\n {\n names: [\"*\"],\n privileges: [\"write\"],\n },\n ],\n },\n },\n metadata: {\n environment: {\n level: 2,\n trusted: true,\n tags: [\"production\"],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"role_descriptors\": {\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"environment\": {\n \"level\": 2,\n \"trusted\": true,\n \"tags\": [\n \"production\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"role_descriptors\" => [\n \"role-a\" => [\n \"indices\" => array(\n [\n \"names\" => array(\n \"*\",\n ),\n \"privileges\" => array(\n \"write\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"environment\" => [\n \"level\" => 2,\n \"trusted\" => true,\n \"tags\" => array(\n \"production\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx\"" + }, + { + "language": "Java", + "code": "client.security().updateApiKey(u -> u\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n .metadata(\"environment\", JsonData.fromJson(\"{\\\"level\\\":2,\\\"trusted\\\":true,\\\"tags\\\":[\\\"production\\\"]}\"))\n .roleDescriptors(\"role-a\", r -> r\n .indices(i -> i\n .names(\"*\")\n .privileges(\"write\")\n )\n )\n);\n" + } + ], + "specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.update_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors={},\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.updateApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors: {},\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.update_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"role_descriptors\": {}\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->updateApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"role_descriptors\" => new ArrayObject([]),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_descriptors\":{}}' \"$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx\"" + }, + { + "language": "Java", + "code": "client.security().updateApiKey(u -> u\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n);\n" + } + ], + "specification/security/delete_service_token/examples/request/DeleteServiceTokenRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.delete_service_token(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token42\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.deleteServiceToken({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token42\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.delete_service_token(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token42\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->deleteServiceToken([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token42\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token42\"" + }, + { + "language": "Java", + "code": "client.security().deleteServiceToken(d -> d\n .name(\"token42\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" + } + ], + "specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.saml_logout(\n token=\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n refresh_token=\"mJdXLtmvTUSpoLwMvdBt_w\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.samlLogout({\n token: \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n refresh_token: \"mJdXLtmvTUSpoLwMvdBt_w\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.saml_logout(\n body: {\n \"token\": \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n \"refresh_token\": \"mJdXLtmvTUSpoLwMvdBt_w\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->samlLogout([\n \"body\" => [\n \"token\" => \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n \"refresh_token\" => \"mJdXLtmvTUSpoLwMvdBt_w\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\"refresh_token\":\"mJdXLtmvTUSpoLwMvdBt_w\"}' \"$ELASTICSEARCH_URL/_security/saml/logout\"" + }, + { + "language": "Java", + "code": "client.security().samlLogout(s -> s\n .refreshToken(\"mJdXLtmvTUSpoLwMvdBt_w\")\n .token(\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\")\n);\n" + } + ], + "specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.oidc_authenticate(\n redirect_uri=\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n state=\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n nonce=\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n realm=\"oidc1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.oidcAuthenticate({\n redirect_uri:\n \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n state: \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n nonce: \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n realm: \"oidc1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.oidc_authenticate(\n body: {\n \"redirect_uri\": \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"state\": \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"nonce\": \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n \"realm\": \"oidc1\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->oidcAuthenticate([\n \"body\" => [\n \"redirect_uri\" => \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"state\" => \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"nonce\" => \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n \"realm\" => \"oidc1\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"redirect_uri\":\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"state\":\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"nonce\":\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\"realm\":\"oidc1\"}' \"$ELASTICSEARCH_URL/_security/oidc/authenticate\"" + }, + { + "language": "Java", + "code": "client.security().oidcAuthenticate(o -> o\n .nonce(\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\")\n .realm(\"oidc1\")\n .redirectUri(\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\")\n .state(\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\")\n);\n" + } + ], + "specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.grant_api_key(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n run_as=\"test_user\",\n api_key={\n \"name\": \"another-api-key\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.grantApiKey({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n run_as: \"test_user\",\n api_key: {\n name: \"another-api-key\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.grant_api_key(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\",\n \"run_as\": \"test_user\",\n \"api_key\": {\n \"name\": \"another-api-key\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->grantApiKey([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n \"run_as\" => \"test_user\",\n \"api_key\" => [\n \"name\" => \"another-api-key\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\",\"run_as\":\"test_user\",\"api_key\":{\"name\":\"another-api-key\"}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" + }, + { + "language": "Java", + "code": "client.security().grantApiKey(g -> g\n .apiKey(a -> a\n .name(\"another-api-key\")\n )\n .grantType(ApiKeyGrantType.Password)\n .password(\"x-pack-test-password\")\n .runAs(\"test_user\")\n .username(\"test_admin\")\n);\n" + } + ], + "specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.grant_api_key(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n api_key={\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.grantApiKey({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n api_key: {\n name: \"my-api-key\",\n expiration: \"1d\",\n role_descriptors: {\n \"role-a\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-a*\"],\n privileges: [\"read\"],\n },\n ],\n },\n \"role-b\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-b*\"],\n privileges: [\"all\"],\n },\n ],\n },\n },\n metadata: {\n application: \"my-application\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.grant_api_key(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\",\n \"api_key\": {\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->grantApiKey([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n \"api_key\" => [\n \"name\" => \"my-api-key\",\n \"expiration\" => \"1d\",\n \"role_descriptors\" => [\n \"role-a\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-a*\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n ),\n ],\n \"role-b\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-b*\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"application\" => \"my-application\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\",\"api_key\":{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-a*\"],\"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"privileges\":[\"all\"]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" + }, + { + "language": "Java", + "code": "client.security().grantApiKey(g -> g\n .apiKey(a -> a\n .name(\"my-api-key\")\n .expiration(e -> e\n .time(\"1d\")\n )\n .roleDescriptors(Map.of(\"role-b\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-b*\")\n .privileges(\"all\")\n )),\"role-a\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-a*\")\n .privileges(\"read\")\n ))))\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"application\", JsonData.fromJson(\"\\\"my-application\\\"\")))\n )\n .grantType(ApiKeyGrantType.Password)\n .password(\"x-pack-test-password\")\n .username(\"test_admin\")\n);\n" + } + ], + "specification/security/get_service_accounts/examples/request/GetServiceAccountsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.get_service_accounts(\n namespace=\"elastic\",\n service=\"fleet-server\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.getServiceAccounts({\n namespace: \"elastic\",\n service: \"fleet-server\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.get_service_accounts(\n namespace: \"elastic\",\n service: \"fleet-server\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->getServiceAccounts([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server\"" + }, + { + "language": "Java", + "code": "client.security().getServiceAccounts(g -> g\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" + } + ], + "specification/security/delete_role_mapping/examples/request/SecurityDeleteRoleMappingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.delete_role_mapping(\n name=\"mapping1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.deleteRoleMapping({\n name: \"mapping1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.delete_role_mapping(\n name: \"mapping1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->deleteRoleMapping([\n \"name\" => \"mapping1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" + }, + { + "language": "Java", + "code": "client.security().deleteRoleMapping(d -> d\n .name(\"mapping1\")\n);\n" + } + ], + "specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role(\n name=\"only_remote_access_role\",\n remote_indices=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n remote_cluster=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRole({\n name: \"only_remote_access_role\",\n remote_indices: [\n {\n clusters: [\"my_remote\"],\n names: [\"logs*\"],\n privileges: [\"read\", \"read_cross_cluster\", \"view_index_metadata\"],\n },\n ],\n remote_cluster: [\n {\n clusters: [\"my_remote\"],\n privileges: [\"monitor_stats\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role(\n name: \"only_remote_access_role\",\n body: {\n \"remote_indices\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n \"remote_cluster\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRole([\n \"name\" => \"only_remote_access_role\",\n \"body\" => [\n \"remote_indices\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"names\" => array(\n \"logs*\",\n ),\n \"privileges\" => array(\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\",\n ),\n ],\n ),\n \"remote_cluster\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"privileges\" => array(\n \"monitor_stats\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"view_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" + }, + { + "language": "Java", + "code": "client.security().putRole(p -> p\n .name(\"only_remote_access_role\")\n .remoteCluster(r -> r\n .clusters(\"my_remote\")\n .privileges(RemoteClusterPrivilege.MonitorStats)\n )\n .remoteIndices(r -> r\n .clusters(\"my_remote\")\n .names(\"logs*\")\n .privileges(List.of(\"read\",\"read_cross_cluster\",\"view_index_metadata\"))\n )\n);\n" + } + ], + "specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role(\n name=\"cli_or_drivers_minimal\",\n cluster=[\n \"cluster:monitor/main\"\n ],\n indices=[\n {\n \"names\": [\n \"test\"\n ],\n \"privileges\": [\n \"read\",\n \"indices:admin/get\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRole({\n name: \"cli_or_drivers_minimal\",\n cluster: [\"cluster:monitor/main\"],\n indices: [\n {\n names: [\"test\"],\n privileges: [\"read\", \"indices:admin/get\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role(\n name: \"cli_or_drivers_minimal\",\n body: {\n \"cluster\": [\n \"cluster:monitor/main\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"test\"\n ],\n \"privileges\": [\n \"read\",\n \"indices:admin/get\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRole([\n \"name\" => \"cli_or_drivers_minimal\",\n \"body\" => [\n \"cluster\" => array(\n \"cluster:monitor/main\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"test\",\n ),\n \"privileges\" => array(\n \"read\",\n \"indices:admin/get\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cluster\":[\"cluster:monitor/main\"],\"indices\":[{\"names\":[\"test\"],\"privileges\":[\"read\",\"indices:admin/get\"]}]}' \"$ELASTICSEARCH_URL/_security/role/cli_or_drivers_minimal\"" + }, + { + "language": "Java", + "code": "client.security().putRole(p -> p\n .cluster(\"cluster:monitor/main\")\n .indices(i -> i\n .names(\"test\")\n .privileges(List.of(\"read\",\"indices:admin/get\"))\n )\n .name(\"cli_or_drivers_minimal\")\n);\n" + } + ], + "specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_role(\n name=\"my_admin_role\",\n description=\"Grants full access to all management features within the cluster.\",\n cluster=[\n \"all\"\n ],\n indices=[\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n applications=[\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n run_as=[\n \"other_user\"\n ],\n metadata={\n \"version\": 1\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putRole({\n name: \"my_admin_role\",\n description:\n \"Grants full access to all management features within the cluster.\",\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_role(\n name: \"my_admin_role\",\n body: {\n \"description\": \"Grants full access to all management features within the cluster.\",\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putRole([\n \"name\" => \"my_admin_role\",\n \"body\" => [\n \"description\" => \"Grants full access to all management features within the cluster.\",\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Grants full access to all management features within the cluster.\",\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}' \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" + }, + { + "language": "Java", + "code": "client.security().putRole(p -> p\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .cluster(\"all\")\n .description(\"Grants full access to all management features within the cluster.\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .name(\"my_admin_role\")\n .runAs(\"other_user\")\n);\n" + } + ], + "specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.bulk_delete_role(\n names=[\n \"my_admin_role\",\n \"my_user_role\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.bulkDeleteRole({\n names: [\"my_admin_role\", \"my_user_role\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.bulk_delete_role(\n body: {\n \"names\": [\n \"my_admin_role\",\n \"my_user_role\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->bulkDeleteRole([\n \"body\" => [\n \"names\" => array(\n \"my_admin_role\",\n \"my_user_role\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"names\":[\"my_admin_role\",\"my_user_role\"]}' \"$ELASTICSEARCH_URL/_security/role\"" + }, + { + "language": "Java", + "code": "client.security().bulkDeleteRole(b -> b\n .names(List.of(\"my_admin_role\",\"my_user_role\"))\n);\n" + } + ], + "specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_privileges(\n privileges={\n \"myapp\": {\n \"read\": {\n \"actions\": [\n \"data:read/*\",\n \"action:login\"\n ],\n \"metadata\": {\n \"description\": \"Read access to myapp\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putPrivileges({\n privileges: {\n myapp: {\n read: {\n actions: [\"data:read/*\", \"action:login\"],\n metadata: {\n description: \"Read access to myapp\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_privileges(\n body: {\n \"myapp\": {\n \"read\": {\n \"actions\": [\n \"data:read/*\",\n \"action:login\"\n ],\n \"metadata\": {\n \"description\": \"Read access to myapp\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putPrivileges([\n \"body\" => [\n \"myapp\" => [\n \"read\" => [\n \"actions\" => array(\n \"data:read/*\",\n \"action:login\",\n ),\n \"metadata\" => [\n \"description\" => \"Read access to myapp\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"myapp\":{\"read\":{\"actions\":[\"data:read/*\",\"action:login\"],\"metadata\":{\"description\":\"Read access to myapp\"}}}}' \"$ELASTICSEARCH_URL/_security/privilege\"" + }, + { + "language": "Java", + "code": "client.security().putPrivileges(p -> p\n .privileges(\"myapp\", \"read\", pr -> pr\n .actions(List.of(\"data:read/*\",\"action:login\"))\n .metadata(\"description\", JsonData.fromJson(\"\\\"Read access to myapp\\\"\"))\n )\n);\n" + } + ], + "specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.security.put_privileges(\n privileges={\n \"app01\": {\n \"read\": {\n \"actions\": [\n \"action:login\",\n \"data:read/*\"\n ]\n },\n \"write\": {\n \"actions\": [\n \"action:login\",\n \"data:write/*\"\n ]\n }\n },\n \"app02\": {\n \"all\": {\n \"actions\": [\n \"*\"\n ]\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.putPrivileges({\n privileges: {\n app01: {\n read: {\n actions: [\"action:login\", \"data:read/*\"],\n },\n write: {\n actions: [\"action:login\", \"data:write/*\"],\n },\n },\n app02: {\n all: {\n actions: [\"*\"],\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.security.put_privileges(\n body: {\n \"app01\": {\n \"read\": {\n \"actions\": [\n \"action:login\",\n \"data:read/*\"\n ]\n },\n \"write\": {\n \"actions\": [\n \"action:login\",\n \"data:write/*\"\n ]\n }\n },\n \"app02\": {\n \"all\": {\n \"actions\": [\n \"*\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->putPrivileges([\n \"body\" => [\n \"app01\" => [\n \"read\" => [\n \"actions\" => array(\n \"action:login\",\n \"data:read/*\",\n ),\n ],\n \"write\" => [\n \"actions\" => array(\n \"action:login\",\n \"data:write/*\",\n ),\n ],\n ],\n \"app02\" => [\n \"all\" => [\n \"actions\" => array(\n \"*\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"app01\":{\"read\":{\"actions\":[\"action:login\",\"data:read/*\"]},\"write\":{\"actions\":[\"action:login\",\"data:write/*\"]}},\"app02\":{\"all\":{\"actions\":[\"*\"]}}}' \"$ELASTICSEARCH_URL/_security/privilege\"" + }, + { + "language": "Java", + "code": "client.security().putPrivileges(p -> p\n .privileges(Map.of(\"app02\", \"all\", pr -> pr\n .actions(\"*\"),\"app01\", Map.of(\"read\", Actions.of(a -> a\n .actions(List.of(\"action:login\",\"data:read/*\"))),\"write\", Actions.of(a -> a\n .actions(List.of(\"action:login\",\"data:write/*\"))))))\n);\n" + } + ], + "specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.security.enroll_kibana()" + }, + { + "language": "JavaScript", + "code": "const response = await client.security.enrollKibana();" + }, + { + "language": "Ruby", + "code": "response = client.security.enroll_kibana" + }, + { + "language": "PHP", + "code": "$resp = $client->security()->enrollKibana();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/enroll/kibana\"" + }, + { + "language": "Java", + "code": "client.security().enrollKibana();\n" + } + ], + "specification/nodes/usage/examples/request/NodesUsageExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.nodes.usage()" + }, + { + "language": "JavaScript", + "code": "const response = await client.nodes.usage();" + }, + { + "language": "Ruby", + "code": "response = client.nodes.usage" + }, + { + "language": "PHP", + "code": "$resp = $client->nodes()->usage();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/usage\"" + }, + { + "language": "Java", + "code": "client.nodes().usage(u -> u);\n" + } + ], + "specification/nodes/info/examples/request/NodesInfoExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.nodes.info(\n node_id=\"_all\",\n metric=\"jvm\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.nodes.info({\n node_id: \"_all\",\n metric: \"jvm\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.nodes.info(\n node_id: \"_all\",\n metric: \"jvm\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->nodes()->info([\n \"node_id\" => \"_all\",\n \"metric\" => \"jvm\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/_all/jvm\"" + }, + { + "language": "Java", + "code": "client.nodes().info(i -> i\n .metric(\"jvm\")\n .nodeId(\"_all\")\n);\n" + } + ], + "specification/nodes/hot_threads/examples/request/NodesHotThreadsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.nodes.hot_threads()" + }, + { + "language": "JavaScript", + "code": "const response = await client.nodes.hotThreads();" + }, + { + "language": "Ruby", + "code": "response = client.nodes.hot_threads" + }, + { + "language": "PHP", + "code": "$resp = $client->nodes()->hotThreads();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/hot_threads\"" + }, + { + "language": "Java", + "code": "client.nodes().hotThreads(h -> h);\n" + } + ], + "specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.nodes.reload_secure_settings(\n secure_settings_password=\"keystore-password\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.nodes.reloadSecureSettings({\n secure_settings_password: \"keystore-password\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.nodes.reload_secure_settings(\n body: {\n \"secure_settings_password\": \"keystore-password\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->nodes()->reloadSecureSettings([\n \"body\" => [\n \"secure_settings_password\" => \"keystore-password\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"secure_settings_password\":\"keystore-password\"}' \"$ELASTICSEARCH_URL/_nodes/reload_secure_settings\"" + }, + { + "language": "Java", + "code": "client.nodes().reloadSecureSettings(r -> r\n .secureSettingsPassword(\"keystore-password\")\n);\n" + } + ], + "specification/nodes/stats/examples/request/NodesStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.nodes.stats(\n metric=\"process\",\n filter_path=\"**.max_file_descriptors\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.nodes.stats({\n metric: \"process\",\n filter_path: \"**.max_file_descriptors\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.nodes.stats(\n metric: \"process\",\n filter_path: \"**.max_file_descriptors\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->nodes()->stats([\n \"metric\" => \"process\",\n \"filter_path\" => \"**.max_file_descriptors\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/stats/process?filter_path=**.max_file_descriptors\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/ingest/get_pipeline/examples/request/IngestGetPipelineExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.get_pipeline(\n id=\"my-pipeline-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.getPipeline({\n id: \"my-pipeline-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.get_pipeline(\n id: \"my-pipeline-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->getPipeline([\n \"id\" => \"my-pipeline-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" + }, + { + "language": "Java", + "code": "client.ingest().getPipeline(g -> g\n .id(\"my-pipeline-id\")\n);\n" + } + ], + "specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.put_pipeline(\n id=\"my-pipeline-id\",\n description=\"My optional pipeline description\",\n processors=[\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.putPipeline({\n id: \"my-pipeline-id\",\n description: \"My optional pipeline description\",\n processors: [\n {\n set: {\n description: \"My optional processor description\",\n field: \"my-keyword-field\",\n value: \"foo\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.put_pipeline(\n id: \"my-pipeline-id\",\n body: {\n \"description\": \"My optional pipeline description\",\n \"processors\": [\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->putPipeline([\n \"id\" => \"my-pipeline-id\",\n \"body\" => [\n \"description\" => \"My optional pipeline description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"description\" => \"My optional processor description\",\n \"field\" => \"my-keyword-field\",\n \"value\" => \"foo\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"My optional pipeline description\",\"processors\":[{\"set\":{\"description\":\"My optional processor description\",\"field\":\"my-keyword-field\",\"value\":\"foo\"}}]}' \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" + }, + { + "language": "Java", + "code": "client.ingest().putPipeline(p -> p\n .description(\"My optional pipeline description\")\n .id(\"my-pipeline-id\")\n .processors(pr -> pr\n .set(s -> s\n .field(\"my-keyword-field\")\n .value(JsonData.fromJson(\"\\\"foo\\\"\"))\n .description(\"My optional processor description\")\n )\n )\n);\n" + } + ], + "specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.put_pipeline(\n id=\"my-pipeline-id\",\n description=\"My optional pipeline description\",\n processors=[\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n meta={\n \"reason\": \"set my-keyword-field to foo\",\n \"serialization\": {\n \"class\": \"MyPipeline\",\n \"id\": 10\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.putPipeline({\n id: \"my-pipeline-id\",\n description: \"My optional pipeline description\",\n processors: [\n {\n set: {\n description: \"My optional processor description\",\n field: \"my-keyword-field\",\n value: \"foo\",\n },\n },\n ],\n meta: {\n reason: \"set my-keyword-field to foo\",\n serialization: {\n class: \"MyPipeline\",\n id: 10,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.put_pipeline(\n id: \"my-pipeline-id\",\n body: {\n \"description\": \"My optional pipeline description\",\n \"processors\": [\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n \"_meta\": {\n \"reason\": \"set my-keyword-field to foo\",\n \"serialization\": {\n \"class\": \"MyPipeline\",\n \"id\": 10\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->putPipeline([\n \"id\" => \"my-pipeline-id\",\n \"body\" => [\n \"description\" => \"My optional pipeline description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"description\" => \"My optional processor description\",\n \"field\" => \"my-keyword-field\",\n \"value\" => \"foo\",\n ],\n ],\n ),\n \"_meta\" => [\n \"reason\" => \"set my-keyword-field to foo\",\n \"serialization\" => [\n \"class\" => \"MyPipeline\",\n \"id\" => 10,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"My optional pipeline description\",\"processors\":[{\"set\":{\"description\":\"My optional processor description\",\"field\":\"my-keyword-field\",\"value\":\"foo\"}}],\"_meta\":{\"reason\":\"set my-keyword-field to foo\",\"serialization\":{\"class\":\"MyPipeline\",\"id\":10}}}' \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" + }, + { + "language": "Java", + "code": "client.ingest().putPipeline(p -> p\n .meta(Map.of(\"serialization\", JsonData.fromJson(\"{\\\"class\\\":\\\"MyPipeline\\\",\\\"id\\\":10}\"),\"reason\", JsonData.fromJson(\"\\\"set my-keyword-field to foo\\\"\")))\n .description(\"My optional pipeline description\")\n .id(\"my-pipeline-id\")\n .processors(pr -> pr\n .set(s -> s\n .field(\"my-keyword-field\")\n .value(JsonData.fromJson(\"\\\"foo\\\"\"))\n .description(\"My optional processor description\")\n )\n )\n);\n" + } + ], + "specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.simulate(\n pipeline={\n \"description\": \"_description\",\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field2\",\n \"value\": \"_value\"\n }\n }\n ]\n },\n docs=[\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.simulate({\n pipeline: {\n description: \"_description\",\n processors: [\n {\n set: {\n field: \"field2\",\n value: \"_value\",\n },\n },\n ],\n },\n docs: [\n {\n _index: \"index\",\n _id: \"id\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _index: \"index\",\n _id: \"id\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.simulate(\n body: {\n \"pipeline\": {\n \"description\": \"_description\",\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field2\",\n \"value\": \"_value\"\n }\n }\n ]\n },\n \"docs\": [\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->simulate([\n \"body\" => [\n \"pipeline\" => [\n \"description\" => \"_description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"field\" => \"field2\",\n \"value\" => \"_value\",\n ],\n ],\n ),\n ],\n \"docs\" => array(\n [\n \"_index\" => \"index\",\n \"_id\" => \"id\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_index\" => \"index\",\n \"_id\" => \"id\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"pipeline\":{\"description\":\"_description\",\"processors\":[{\"set\":{\"field\":\"field2\",\"value\":\"_value\"}}]},\"docs\":[{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/pipeline/_simulate\"" + }, + { + "language": "Java", + "code": "client.ingest().simulate(s -> s\n .docs(List.of(Document.of(d -> d\n .id(\"id\")\n .index(\"index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"id\")\n .index(\"index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .pipeline(p -> p\n .description(\"_description\")\n .processors(pr -> pr\n .set(se -> se\n .field(\"field2\")\n .value(JsonData.fromJson(\"\\\"_value\\\"\"))\n )\n )\n )\n);\n" + } + ], + "specification/ingest/delete_pipeline/examples/request/IngestDeletePipelineExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.delete_pipeline(\n id=\"my-pipeline-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.deletePipeline({\n id: \"my-pipeline-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.delete_pipeline(\n id: \"my-pipeline-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->deletePipeline([\n \"id\" => \"my-pipeline-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" + }, + { + "language": "Java", + "code": "client.ingest().deletePipeline(d -> d\n .id(\"my-pipeline-id\")\n);\n" + } + ], + "specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.geo_ip_stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.geoIpStats();" + }, + { + "language": "Ruby", + "code": "response = client.ingest.geo_ip_stats" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->geoIpStats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/geoip/stats\"" + }, + { + "language": "Java", + "code": "client.ingest().geoIpStats();\n" + } + ], + "specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.put_ip_location_database(\n id=\"my-database-1\",\n configuration={\n \"name\": \"GeoIP2-Domain\",\n \"maxmind\": {\n \"account_id\": \"1234567\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.putIpLocationDatabase({\n id: \"my-database-1\",\n configuration: {\n name: \"GeoIP2-Domain\",\n maxmind: {\n account_id: \"1234567\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.put_ip_location_database(\n id: \"my-database-1\",\n body: {\n \"name\": \"GeoIP2-Domain\",\n \"maxmind\": {\n \"account_id\": \"1234567\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->putIpLocationDatabase([\n \"id\" => \"my-database-1\",\n \"body\" => [\n \"name\" => \"GeoIP2-Domain\",\n \"maxmind\" => [\n \"account_id\" => \"1234567\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"GeoIP2-Domain\",\"maxmind\":{\"account_id\":\"1234567\"}}' \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-1\"" + }, + { + "language": "Java", + "code": "client.ingest().putIpLocationDatabase(p -> p\n .id(\"my-database-1\")\n .configuration(c -> c\n .maxmind(m -> m\n .accountId(\"1234567\")\n )\n .name(\"GeoIP2-Domain\")\n )\n);\n" + } + ], + "specification/ingest/delete_ip_location_database/examples/request/IngestDeleteIpLocationDatabaseExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.delete_ip_location_database(\n id=\"my-database-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.deleteIpLocationDatabase({\n id: \"my-database-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.delete_ip_location_database(\n id: \"my-database-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->deleteIpLocationDatabase([\n \"id\" => \"my-database-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-id\"" + }, + { + "language": "Java", + "code": "client.ingest().deleteIpLocationDatabase(d -> d\n .id(\"my-database-id\")\n);\n" + } + ], + "specification/ingest/get_ip_location_database/examples/request/IngestGetIpLocationDatabaseExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.get_ip_location_database(\n id=\"my-database-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.getIpLocationDatabase({\n id: \"my-database-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ingest.get_ip_location_database(\n id: \"my-database-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->getIpLocationDatabase([\n \"id\" => \"my-database-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-id\"" + }, + { + "language": "Java", + "code": "client.ingest().getIpLocationDatabase(g -> g\n .id(\"my-database-id\")\n);\n" + } + ], + "specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ingest.processor_grok()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ingest.processorGrok();" + }, + { + "language": "Ruby", + "code": "response = client.ingest.processor_grok" + }, + { + "language": "PHP", + "code": "$resp = $client->ingest()->processorGrok();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/processor/grok\"" + }, + { + "language": "Java", + "code": "client.ingest().processorGrok();\n" + } + ], + "specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n pipeline_substitutions={\n \"my-pipeline\": {\n \"processors\": [\n {\n \"uppercase\": {\n \"field\": \"foo\"\n }\n }\n ]\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _index: \"my-index\",\n _id: \"123\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _index: \"my-index\",\n _id: \"456\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n pipeline_substitutions: {\n \"my-pipeline\": {\n processors: [\n {\n uppercase: {\n field: \"foo\",\n },\n },\n ],\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n \"pipeline_substitutions\": {\n \"my-pipeline\": {\n \"processors\": [\n {\n \"uppercase\": {\n \"field\": \"foo\"\n }\n }\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"123\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"456\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n \"pipeline_substitutions\" => [\n \"my-pipeline\" => [\n \"processors\" => array(\n [\n \"uppercase\" => [\n \"field\" => \"foo\",\n ],\n ],\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index\",\"_id\":\"123\",\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"my-index\",\"_id\":\"456\",\"_source\":{\"foo\":\"rab\"}}],\"pipeline_substitutions\":{\"my-pipeline\":{\"processors\":[{\"uppercase\":{\"field\":\"foo\"}}]}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + }, + { + "language": "Java", + "code": "client.simulate().ingest(i -> i\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .pipelineSubstitutions(\"my-pipeline\", p -> p\n .processors(pr -> pr\n .uppercase(u -> u\n .field(\"foo\")\n )\n )\n )\n);\n" + } + ], + "specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"foo\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"bar\": \"rab\"\n }\n }\n ],\n component_template_substitutions={\n \"my-mappings_template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n },\n \"bar\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _index: \"my-index\",\n _id: \"123\",\n _source: {\n foo: \"foo\",\n },\n },\n {\n _index: \"my-index\",\n _id: \"456\",\n _source: {\n bar: \"rab\",\n },\n },\n ],\n component_template_substitutions: {\n \"my-mappings_template\": {\n template: {\n mappings: {\n dynamic: \"strict\",\n properties: {\n foo: {\n type: \"keyword\",\n },\n bar: {\n type: \"keyword\",\n },\n },\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"foo\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"bar\": \"rab\"\n }\n }\n ],\n \"component_template_substitutions\": {\n \"my-mappings_template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n },\n \"bar\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"123\",\n \"_source\" => [\n \"foo\" => \"foo\",\n ],\n ],\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"456\",\n \"_source\" => [\n \"bar\" => \"rab\",\n ],\n ],\n ),\n \"component_template_substitutions\" => [\n \"my-mappings_template\" => [\n \"template\" => [\n \"mappings\" => [\n \"dynamic\" => \"strict\",\n \"properties\" => [\n \"foo\" => [\n \"type\" => \"keyword\",\n ],\n \"bar\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index\",\"_id\":\"123\",\"_source\":{\"foo\":\"foo\"}},{\"_index\":\"my-index\",\"_id\":\"456\",\"_source\":{\"bar\":\"rab\"}}],\"component_template_substitutions\":{\"my-mappings_template\":{\"template\":{\"mappings\":{\"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyword\"},\"bar\":{\"type\":\"keyword\"}}}}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + }, + { + "language": "Java", + "code": "client.simulate().ingest(i -> i\n .componentTemplateSubstitutions(\"my-mappings_template\", c -> c\n .template(t -> t\n .mappings(m -> m\n .dynamic(DynamicMapping.Strict)\n .properties(Map.of(\"bar\", Property.of(p -> p\n .keyword(k -> k\n )),\"foo\", Property.of(pr -> pr\n .keyword(k -> k\n ))))\n )\n )\n )\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"foo\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"bar\\\":\\\"rab\\\"}\")))))\n);\n" + } + ], + "specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n pipeline_substitutions={\n \"my-pipeline\": {\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field3\",\n \"value\": \"value3\"\n }\n }\n ]\n }\n },\n component_template_substitutions={\n \"my-component-template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": True,\n \"properties\": {\n \"field3\": {\n \"type\": \"keyword\"\n }\n }\n },\n \"settings\": {\n \"index\": {\n \"default_pipeline\": \"my-pipeline\"\n }\n }\n }\n }\n },\n index_template_substitutions={\n \"my-index-template\": {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"component_template_1\",\n \"component_template_2\"\n ]\n }\n },\n mapping_addition={\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _id: \"id\",\n _index: \"my-index\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _id: \"id\",\n _index: \"my-index\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n pipeline_substitutions: {\n \"my-pipeline\": {\n processors: [\n {\n set: {\n field: \"field3\",\n value: \"value3\",\n },\n },\n ],\n },\n },\n component_template_substitutions: {\n \"my-component-template\": {\n template: {\n mappings: {\n dynamic: true,\n properties: {\n field3: {\n type: \"keyword\",\n },\n },\n },\n settings: {\n index: {\n default_pipeline: \"my-pipeline\",\n },\n },\n },\n },\n },\n index_template_substitutions: {\n \"my-index-template\": {\n index_patterns: [\"my-index-*\"],\n composed_of: [\"component_template_1\", \"component_template_2\"],\n },\n },\n mapping_addition: {\n dynamic: \"strict\",\n properties: {\n foo: {\n type: \"keyword\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n \"pipeline_substitutions\": {\n \"my-pipeline\": {\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field3\",\n \"value\": \"value3\"\n }\n }\n ]\n }\n },\n \"component_template_substitutions\": {\n \"my-component-template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": true,\n \"properties\": {\n \"field3\": {\n \"type\": \"keyword\"\n }\n }\n },\n \"settings\": {\n \"index\": {\n \"default_pipeline\": \"my-pipeline\"\n }\n }\n }\n }\n },\n \"index_template_substitutions\": {\n \"my-index-template\": {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"component_template_1\",\n \"component_template_2\"\n ]\n }\n },\n \"mapping_addition\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"id\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_id\" => \"id\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n \"pipeline_substitutions\" => [\n \"my-pipeline\" => [\n \"processors\" => array(\n [\n \"set\" => [\n \"field\" => \"field3\",\n \"value\" => \"value3\",\n ],\n ],\n ),\n ],\n ],\n \"component_template_substitutions\" => [\n \"my-component-template\" => [\n \"template\" => [\n \"mappings\" => [\n \"dynamic\" => true,\n \"properties\" => [\n \"field3\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n \"settings\" => [\n \"index\" => [\n \"default_pipeline\" => \"my-pipeline\",\n ],\n ],\n ],\n ],\n ],\n \"index_template_substitutions\" => [\n \"my-index-template\" => [\n \"index_patterns\" => array(\n \"my-index-*\",\n ),\n \"composed_of\" => array(\n \"component_template_1\",\n \"component_template_2\",\n ),\n ],\n ],\n \"mapping_addition\" => [\n \"dynamic\" => \"strict\",\n \"properties\" => [\n \"foo\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"id\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"bar\"}},{\"_id\":\"id\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"rab\"}}],\"pipeline_substitutions\":{\"my-pipeline\":{\"processors\":[{\"set\":{\"field\":\"field3\",\"value\":\"value3\"}}]}},\"component_template_substitutions\":{\"my-component-template\":{\"template\":{\"mappings\":{\"dynamic\":true,\"properties\":{\"field3\":{\"type\":\"keyword\"}}},\"settings\":{\"index\":{\"default_pipeline\":\"my-pipeline\"}}}}},\"index_template_substitutions\":{\"my-index-template\":{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"component_template_1\",\"component_template_2\"]}},\"mapping_addition\":{\"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyword\"}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + }, + { + "language": "Java", + "code": "client.simulate().ingest(i -> i\n .componentTemplateSubstitutions(\"my-component-template\", c -> c\n .template(t -> t\n .settings(\"index\", s -> s\n .defaultPipeline(\"my-pipeline\")\n )\n .mappings(m -> m\n .dynamic(DynamicMapping.True)\n .properties(\"field3\", p -> p\n .keyword(k -> k)\n )\n )\n )\n )\n .docs(List.of(Document.of(d -> d\n .id(\"id\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"id\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .indexTemplateSubstitutions(\"my-index-template\", in -> in\n .indexPatterns(\"my-index-*\")\n .composedOf(List.of(\"component_template_1\",\"component_template_2\"))\n )\n .mappingAddition(m -> m\n .dynamic(DynamicMapping.Strict)\n .properties(\"foo\", p -> p\n .keyword(k -> k)\n )\n )\n .pipelineSubstitutions(\"my-pipeline\", p -> p\n .processors(pr -> pr\n .set(s -> s\n .field(\"field3\")\n .value(JsonData.fromJson(\"\\\"value3\\\"\"))\n )\n )\n )\n);\n" + } + ], + "specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_id\": \"123\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"456\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _id: \"123\",\n _index: \"my-index\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _id: \"456\",\n _index: \"my-index\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_id\": \"123\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"456\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"123\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_id\" => \"456\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"123\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"bar\"}},{\"_id\":\"456\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + }, + { + "language": "Java", + "code": "client.simulate().ingest(i -> i\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n);\n" + } + ], + "specification/slm/get_stats/examples/request/GetSnapshotLifecycleManagementStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.get_stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.getStats();" + }, + { + "language": "Ruby", + "code": "response = client.slm.get_stats" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->getStats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/stats\"" + }, + { + "language": "Java", + "code": "client.slm().getStats(g -> g);\n" + } + ], + "specification/slm/get_status/examples/request/GetSnapshotLifecycleManagementStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.get_status()" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.getStatus();" + }, + { + "language": "Ruby", + "code": "response = client.slm.get_status" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->getStatus();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/status\"" + }, + { + "language": "Java", + "code": "client.slm().getStatus(g -> g);\n" + } + ], + "specification/slm/delete_lifecycle/examples/request/SlmDeleteLifecycleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.delete_lifecycle(\n policy_id=\"daily-snapshots\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.deleteLifecycle({\n policy_id: \"daily-snapshots\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.slm.delete_lifecycle(\n policy_id: \"daily-snapshots\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->deleteLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots\"" + }, + { + "language": "Java", + "code": "client.slm().deleteLifecycle(d -> d\n .policyId(\"daily-snapshots\")\n);\n" + } + ], + "specification/slm/start/examples/request/StartSnapshotLifecycleManagementRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.start()" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.start();" + }, + { + "language": "Ruby", + "code": "response = client.slm.start" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->start();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/start\"" + }, + { + "language": "Java", + "code": "client.slm().start(s -> s);\n" + } + ], + "specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.get_lifecycle(\n policy_id=\"daily-snapshots\",\n human=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.getLifecycle({\n policy_id: \"daily-snapshots\",\n human: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.slm.get_lifecycle(\n policy_id: \"daily-snapshots\",\n human: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->getLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n \"human\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots?human\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.put_lifecycle(\n policy_id=\"daily-snapshots\",\n schedule=\"0 30 1 * * ?\",\n name=\"\",\n repository=\"my_repository\",\n config={\n \"indices\": [\n \"data-*\",\n \"important\"\n ],\n \"ignore_unavailable\": False,\n \"include_global_state\": False\n },\n retention={\n \"expire_after\": \"30d\",\n \"min_count\": 5,\n \"max_count\": 50\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.putLifecycle({\n policy_id: \"daily-snapshots\",\n schedule: \"0 30 1 * * ?\",\n name: \"\",\n repository: \"my_repository\",\n config: {\n indices: [\"data-*\", \"important\"],\n ignore_unavailable: false,\n include_global_state: false,\n },\n retention: {\n expire_after: \"30d\",\n min_count: 5,\n max_count: 50,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.slm.put_lifecycle(\n policy_id: \"daily-snapshots\",\n body: {\n \"schedule\": \"0 30 1 * * ?\",\n \"name\": \"\",\n \"repository\": \"my_repository\",\n \"config\": {\n \"indices\": [\n \"data-*\",\n \"important\"\n ],\n \"ignore_unavailable\": false,\n \"include_global_state\": false\n },\n \"retention\": {\n \"expire_after\": \"30d\",\n \"min_count\": 5,\n \"max_count\": 50\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->putLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n \"body\" => [\n \"schedule\" => \"0 30 1 * * ?\",\n \"name\" => \"\",\n \"repository\" => \"my_repository\",\n \"config\" => [\n \"indices\" => array(\n \"data-*\",\n \"important\",\n ),\n \"ignore_unavailable\" => false,\n \"include_global_state\" => false,\n ],\n \"retention\" => [\n \"expire_after\" => \"30d\",\n \"min_count\" => 5,\n \"max_count\" => 50,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"schedule\":\"0 30 1 * * ?\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\"important\"],\"ignore_unavailable\":false,\"include_global_state\":false},\"retention\":{\"expire_after\":\"30d\",\"min_count\":5,\"max_count\":50}}' \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots\"" + }, + { + "language": "Java", + "code": "client.slm().putLifecycle(p -> p\n .config(c -> c\n .ignoreUnavailable(false)\n .indices(List.of(\"data-*\",\"important\"))\n .includeGlobalState(false)\n )\n .name(\"\")\n .policyId(\"daily-snapshots\")\n .repository(\"my_repository\")\n .retention(r -> r\n .expireAfter(e -> e\n .time(\"30d\")\n )\n .maxCount(50)\n .minCount(5)\n )\n .schedule(\"0 30 1 * * ?\")\n);\n" + } + ], + "specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.put_lifecycle(\n policy_id=\"hourly-snapshots\",\n schedule=\"1h\",\n name=\"\",\n repository=\"my_repository\",\n config={\n \"indices\": [\n \"data-*\",\n \"important\"\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.putLifecycle({\n policy_id: \"hourly-snapshots\",\n schedule: \"1h\",\n name: \"\",\n repository: \"my_repository\",\n config: {\n indices: [\"data-*\", \"important\"],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.slm.put_lifecycle(\n policy_id: \"hourly-snapshots\",\n body: {\n \"schedule\": \"1h\",\n \"name\": \"\",\n \"repository\": \"my_repository\",\n \"config\": {\n \"indices\": [\n \"data-*\",\n \"important\"\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->putLifecycle([\n \"policy_id\" => \"hourly-snapshots\",\n \"body\" => [\n \"schedule\" => \"1h\",\n \"name\" => \"\",\n \"repository\" => \"my_repository\",\n \"config\" => [\n \"indices\" => array(\n \"data-*\",\n \"important\",\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"schedule\":\"1h\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\"important\"]}}' \"$ELASTICSEARCH_URL/_slm/policy/hourly-snapshots\"" + }, + { + "language": "Java", + "code": "client.slm().putLifecycle(p -> p\n .config(c -> c\n .indices(List.of(\"data-*\",\"important\"))\n )\n .name(\"\")\n .policyId(\"hourly-snapshots\")\n .repository(\"my_repository\")\n .schedule(\"1h\")\n);\n" + } + ], + "specification/slm/execute_retention/examples/request/SlmExecuteRetentionExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.execute_retention()" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.executeRetention();" + }, + { + "language": "Ruby", + "code": "response = client.slm.execute_retention" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->executeRetention();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/_execute_retention\"" + }, + { + "language": "Java", + "code": "client.slm().executeRetention(e -> e);\n" + } + ], + "specification/slm/execute_lifecycle/examples/request/ExecuteSnapshotLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.slm.execute_lifecycle(\n policy_id=\"daily-snapshots\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.slm.executeLifecycle({\n policy_id: \"daily-snapshots\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.slm.execute_lifecycle(\n policy_id: \"daily-snapshots\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->slm()->executeLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots/_execute\"" + }, + { + "language": "Java", + "code": "client.slm().executeLifecycle(e -> e\n .policyId(\"daily-snapshots\")\n);\n" + } + ], + "specification/features/reset_features/examples/request/FeaturesResetFeaturesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.features.reset_features()" + }, + { + "language": "JavaScript", + "code": "const response = await client.features.resetFeatures();" + }, + { + "language": "Ruby", + "code": "response = client.features.reset_features" + }, + { + "language": "PHP", + "code": "$resp = $client->features()->resetFeatures();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_features/_reset\"" + }, + { + "language": "Java", + "code": "client.features().resetFeatures(r -> r);\n" + } + ], + "specification/features/get_features/examples/request/FeaturesGetFeaturesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.features.get_features()" + }, + { + "language": "JavaScript", + "code": "const response = await client.features.getFeatures();" + }, + { + "language": "Ruby", + "code": "response = client.features.get_features" + }, + { + "language": "PHP", + "code": "$resp = $client->features()->getFeatures();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_features\"" + }, + { + "language": "Java", + "code": "client.features().getFeatures(g -> g);\n" + } + ], + "specification/graph/explore/examples/request/GraphExploreRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.graph.explore(\n index=\"clicklogs\",\n query={\n \"match\": {\n \"query.raw\": \"midi\"\n }\n },\n vertices=[\n {\n \"field\": \"product\"\n }\n ],\n connections={\n \"vertices\": [\n {\n \"field\": \"query.raw\"\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.graph.explore({\n index: \"clicklogs\",\n query: {\n match: {\n \"query.raw\": \"midi\",\n },\n },\n vertices: [\n {\n field: \"product\",\n },\n ],\n connections: {\n vertices: [\n {\n field: \"query.raw\",\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.graph.explore(\n index: \"clicklogs\",\n body: {\n \"query\": {\n \"match\": {\n \"query.raw\": \"midi\"\n }\n },\n \"vertices\": [\n {\n \"field\": \"product\"\n }\n ],\n \"connections\": {\n \"vertices\": [\n {\n \"field\": \"query.raw\"\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->graph()->explore([\n \"index\" => \"clicklogs\",\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"query.raw\" => \"midi\",\n ],\n ],\n \"vertices\" => array(\n [\n \"field\" => \"product\",\n ],\n ),\n \"connections\" => [\n \"vertices\" => array(\n [\n \"field\" => \"query.raw\",\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"query.raw\":\"midi\"}},\"vertices\":[{\"field\":\"product\"}],\"connections\":{\"vertices\":[{\"field\":\"query.raw\"}]}}' \"$ELASTICSEARCH_URL/clicklogs/_graph/explore\"" + }, + { + "language": "Java", + "code": "client.graph().explore(e -> e\n .connections(c -> c\n .vertices(v -> v\n .field(\"query.raw\")\n )\n )\n .index(\"clicklogs\")\n .query(q -> q\n .match(m -> m\n .field(\"query.raw\")\n .query(FieldValue.of(\"midi\"))\n )\n )\n .vertices(v -> v\n .field(\"product\")\n )\n);\n" + } + ], + "specification/synonyms/get_synonym_rule/examples/request/SynonymRuleGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.get_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.getSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.get_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->getSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" + }, + { + "language": "Java", + "code": "client.synonyms().getSynonymRule(g -> g\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n);\n" + } + ], + "specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.put_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n synonyms=\"hello, hi, howdy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.putSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n synonyms: \"hello, hi, howdy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.put_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n body: {\n \"synonyms\": \"hello, hi, howdy\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->putSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n \"body\" => [\n \"synonyms\" => \"hello, hi, howdy\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"synonyms\":\"hello, hi, howdy\"}' \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" + }, + { + "language": "Java", + "code": "client.synonyms().putSynonymRule(p -> p\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n .synonyms(\"hello, hi, howdy\")\n);\n" + } + ], + "specification/synonyms/delete_synonym_rule/examples/request/SynonymRuleDeleteRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.delete_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.deleteSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.delete_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->deleteSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" + }, + { + "language": "Java", + "code": "client.synonyms().deleteSynonymRule(d -> d\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n);\n" + } + ], + "specification/synonyms/delete_synonym/examples/request/SynonymsDeleteSynonymExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.delete_synonym(\n id=\"my-synonyms-set\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.deleteSynonym({\n id: \"my-synonyms-set\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.delete_synonym(\n id: \"my-synonyms-set\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->deleteSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" + }, + { + "language": "Java", + "code": "client.synonyms().deleteSynonym(d -> d\n .id(\"my-synonyms-set\")\n);\n" + } + ], + "specification/synonyms/get_synonym/examples/request/SynonymsGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.get_synonym(\n id=\"my-synonyms-set\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.getSynonym({\n id: \"my-synonyms-set\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.get_synonym(\n id: \"my-synonyms-set\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->getSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" + }, + { + "language": "Java", + "code": "client.synonyms().getSynonym(g -> g\n .id(\"my-synonyms-set\")\n);\n" + } + ], + "specification/synonyms/get_synonyms_sets/examples/request/SynonymsSetsGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.get_synonyms_sets()" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.getSynonymsSets();" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.get_synonyms_sets" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->getSynonymsSets();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms\"" + }, + { + "language": "Java", + "code": "client.synonyms().getSynonymsSets(g -> g);\n" + } + ], + "specification/synonyms/put_synonym/examples/request/SynonymsPutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.synonyms.put_synonym(\n id=\"my-synonyms-set\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.synonyms.putSynonym({\n id: \"my-synonyms-set\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.synonyms.put_synonym(\n id: \"my-synonyms-set\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->synonyms()->putSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" + } + ], + "specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.dangling_indices.list_dangling_indices()" + }, + { + "language": "JavaScript", + "code": "const response = await client.danglingIndices.listDanglingIndices();" + }, + { + "language": "Ruby", + "code": "response = client.dangling_indices.list_dangling_indices" + }, + { + "language": "PHP", + "code": "$resp = $client->danglingIndices()->listDanglingIndices();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling\"" + }, + { + "language": "Java", + "code": "client.danglingIndices().listDanglingIndices();\n" + } + ], + "specification/dangling_indices/delete_dangling_index/examples/request/DanglingIndicesDeleteDanglingIndexExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.dangling_indices.delete_dangling_index(\n index_uuid=\"\",\n accept_data_loss=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.danglingIndices.deleteDanglingIndex({\n index_uuid: \"\",\n accept_data_loss: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.dangling_indices.delete_dangling_index(\n index_uuid: \"\",\n accept_data_loss: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->danglingIndices()->deleteDanglingIndex([\n \"index_uuid\" => \"\",\n \"accept_data_loss\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling/?accept_data_loss=true\"" + }, + { + "language": "Java", + "code": "client.danglingIndices().deleteDanglingIndex(d -> d\n .acceptDataLoss(true)\n .indexUuid(\"\")\n);\n" + } + ], + "specification/dangling_indices/import_dangling_index/examples/request/ImportDanglingIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.dangling_indices.import_dangling_index(\n index_uuid=\"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.danglingIndices.importDanglingIndex({\n index_uuid: \"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.dangling_indices.import_dangling_index(\n index_uuid: \"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->danglingIndices()->importDanglingIndex([\n \"index_uuid\" => \"zmM4e0JtBkeUjiHD-MihPQ\",\n \"accept_data_loss\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling/zmM4e0JtBkeUjiHD-MihPQ?accept_data_loss=true\"" + }, + { + "language": "Java", + "code": "client.danglingIndices().importDanglingIndex(i -> i\n .acceptDataLoss(true)\n .indexUuid(\"zmM4e0JtBkeUjiHD-MihPQ\")\n);\n" + } + ], + "specification/ml/forecast/examples/request/MlForecastExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.forecast(\n job_id=\"low_request_rate\",\n duration=\"10d\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.forecast({\n job_id: \"low_request_rate\",\n duration: \"10d\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.forecast(\n job_id: \"low_request_rate\",\n body: {\n \"duration\": \"10d\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->forecast([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"duration\" => \"10d\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"duration\":\"10d\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_forecast\"" + }, + { + "language": "Java", + "code": "client.ml().forecast(f -> f\n .duration(d -> d\n .time(\"10d\")\n )\n .jobId(\"low_request_rate\")\n);\n" + } + ], + "specification/ml/stop_data_frame_analytics/examples/request/MlStopDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.stop_data_frame_analytics(\n id=\"loganalytics\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.stopDataFrameAnalytics({\n id: \"loganalytics\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.stop_data_frame_analytics(\n id: \"loganalytics\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->stopDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_stop\"" + }, + { + "language": "Java", + "code": "client.ml().stopDataFrameAnalytics(s -> s\n .id(\"loganalytics\")\n);\n" + } + ], + "specification/ml/delete_model_snapshot/examples/request/MlDeleteModelSnapshotExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_model_snapshot(\n job_id=\"farequote\",\n snapshot_id=\"1491948163\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteModelSnapshot({\n job_id: \"farequote\",\n snapshot_id: 1491948163,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_model_snapshot(\n job_id: \"farequote\",\n snapshot_id: \"1491948163\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteModelSnapshot([\n \"job_id\" => \"farequote\",\n \"snapshot_id\" => \"1491948163\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/farequote/model_snapshots/1491948163\"" + }, + { + "language": "Java", + "code": "client.ml().deleteModelSnapshot(d -> d\n .jobId(\"farequote\")\n .snapshotId(\"1491948163\")\n);\n" + } + ], + "specification/ml/get_datafeed_stats/examples/request/MlGetDatafeedStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_datafeed_stats(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getDatafeedStats({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_datafeed_stats(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getDatafeedStats([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_stats\"" + }, + { + "language": "Java", + "code": "client.ml().getDatafeedStats(g -> g\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" + } + ], + "specification/ml/delete_datafeed/examples/request/MlDeleteDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_datafeed(\n datafeed_id=\"datafeed-total-requests\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteDatafeed({\n datafeed_id: \"datafeed-total-requests\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_datafeed(\n datafeed_id: \"datafeed-total-requests\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteDatafeed([\n \"datafeed_id\" => \"datafeed-total-requests\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-total-requests\"" + }, + { + "language": "Java", + "code": "client.ml().deleteDatafeed(d -> d\n .datafeedId(\"datafeed-total-requests\")\n);\n" + } + ], + "specification/ml/delete_calendar_job/examples/request/MlDeleteCalendarJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_calendar_job(\n calendar_id=\"planned-outages\",\n job_id=\"total-requests\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteCalendarJob({\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_calendar_job(\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteCalendarJob([\n \"calendar_id\" => \"planned-outages\",\n \"job_id\" => \"total-requests\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/jobs/total-requests\"" + }, + { + "language": "Java", + "code": "client.ml().deleteCalendarJob(d -> d\n .calendarId(\"planned-outages\")\n .jobId(\"total-requests\")\n);\n" + } + ], + "specification/ml/get_datafeeds/examples/request/MlGetDatafeedsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_datafeeds(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getDatafeeds({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_datafeeds(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getDatafeeds([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales\"" + }, + { + "language": "Java", + "code": "client.ml().getDatafeeds(g -> g\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" + } + ], + "specification/ml/stop_trained_model_deployment/examples/request/MlStopTrainedModelDeploymentExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.stop_trained_model_deployment(\n model_id=\"my_model_for_search\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.stopTrainedModelDeployment({\n model_id: \"my_model_for_search\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.stop_trained_model_deployment(\n model_id: \"my_model_for_search\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->stopTrainedModelDeployment([\n \"model_id\" => \"my_model_for_search\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/my_model_for_search/deployment/_stop\"" + }, + { + "language": "Java", + "code": "client.ml().stopTrainedModelDeployment(s -> s\n .modelId(\"my_model_for_search\")\n);\n" + } + ], + "specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.stop_datafeed(\n datafeed_id=\"datafeed-low_request_rate\",\n timeout=\"30s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.stopDatafeed({\n datafeed_id: \"datafeed-low_request_rate\",\n timeout: \"30s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.stop_datafeed(\n datafeed_id: \"datafeed-low_request_rate\",\n body: {\n \"timeout\": \"30s\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->stopDatafeed([\n \"datafeed_id\" => \"datafeed-low_request_rate\",\n \"body\" => [\n \"timeout\" => \"30s\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_stop\"" + }, + { + "language": "Java", + "code": "client.ml().stopDatafeed(s -> s\n .datafeedId(\"datafeed-low_request_rate\")\n .timeout(t -> t\n .time(\"30s\")\n )\n);\n" + } + ], + "specification/ml/get_calendar_events/examples/request/MlGetCalendarEventsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_calendar_events(\n calendar_id=\"planned-outages\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getCalendarEvents({\n calendar_id: \"planned-outages\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_calendar_events(\n calendar_id: \"planned-outages\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getCalendarEvents([\n \"calendar_id\" => \"planned-outages\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events\"" + }, + { + "language": "Java", + "code": "client.ml().getCalendarEvents(g -> g\n .calendarId(\"planned-outages\")\n);\n" + } + ], + "specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.infer_trained_model(\n model_id=\"lang_ident_model_1\",\n docs=[\n {\n \"text\": \"The fool doth think he is wise, but the wise man knows himself to be a fool.\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.inferTrainedModel({\n model_id: \"lang_ident_model_1\",\n docs: [\n {\n text: \"The fool doth think he is wise, but the wise man knows himself to be a fool.\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.infer_trained_model(\n model_id: \"lang_ident_model_1\",\n body: {\n \"docs\": [\n {\n \"text\": \"The fool doth think he is wise, but the wise man knows himself to be a fool.\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->inferTrainedModel([\n \"model_id\" => \"lang_ident_model_1\",\n \"body\" => [\n \"docs\" => array(\n [\n \"text\" => \"The fool doth think he is wise, but the wise man knows himself to be a fool.\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"text\":\"The fool doth think he is wise, but the wise man knows himself to be a fool.\"}]}' \"$ELASTICSEARCH_URL/_ml/trained_models/lang_ident_model_1/_infer\"" + }, + { + "language": "Java", + "code": "client.ml().inferTrainedModel(i -> i\n .docs(Map.of(\"text\", JsonData.fromJson(\"\\\"The fool doth think he is wise, but the wise man knows himself to be a fool.\\\"\")))\n .modelId(\"lang_ident_model_1\")\n);\n" + } + ], + "specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_datafeed(\n datafeed_id=\"datafeed-test-job\",\n pretty=True,\n indices=[\n \"kibana_sample_data_logs\"\n ],\n query={\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n job_id=\"test-job\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putDatafeed({\n datafeed_id: \"datafeed-test-job\",\n pretty: \"true\",\n indices: [\"kibana_sample_data_logs\"],\n query: {\n bool: {\n must: [\n {\n match_all: {},\n },\n ],\n },\n },\n job_id: \"test-job\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_datafeed(\n datafeed_id: \"datafeed-test-job\",\n pretty: \"true\",\n body: {\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"job_id\": \"test-job\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putDatafeed([\n \"datafeed_id\" => \"datafeed-test-job\",\n \"pretty\" => \"true\",\n \"body\" => [\n \"indices\" => array(\n \"kibana_sample_data_logs\",\n ),\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"match_all\" => new ArrayObject([]),\n ],\n ),\n ],\n ],\n \"job_id\" => \"test-job\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":[\"kibana_sample_data_logs\"],\"query\":{\"bool\":{\"must\":[{\"match_all\":{}}]}},\"job_id\":\"test-job\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job?pretty\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_job(\n job_id=\"low_request_rate\",\n description=\"An updated job\",\n detectors={\n \"detector_index\": 0,\n \"description\": \"An updated detector description\"\n },\n groups=[\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\"\n ],\n model_plot_config={\n \"enabled\": True\n },\n renormalization_window_days=30,\n background_persist_interval=\"2h\",\n model_snapshot_retention_days=7,\n results_retention_days=60,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateJob({\n job_id: \"low_request_rate\",\n description: \"An updated job\",\n detectors: {\n detector_index: 0,\n description: \"An updated detector description\",\n },\n groups: [\"kibana_sample_data\", \"kibana_sample_web_logs\"],\n model_plot_config: {\n enabled: true,\n },\n renormalization_window_days: 30,\n background_persist_interval: \"2h\",\n model_snapshot_retention_days: 7,\n results_retention_days: 60,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_job(\n job_id: \"low_request_rate\",\n body: {\n \"description\": \"An updated job\",\n \"detectors\": {\n \"detector_index\": 0,\n \"description\": \"An updated detector description\"\n },\n \"groups\": [\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\"\n ],\n \"model_plot_config\": {\n \"enabled\": true\n },\n \"renormalization_window_days\": 30,\n \"background_persist_interval\": \"2h\",\n \"model_snapshot_retention_days\": 7,\n \"results_retention_days\": 60\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateJob([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"description\" => \"An updated job\",\n \"detectors\" => [\n \"detector_index\" => 0,\n \"description\" => \"An updated detector description\",\n ],\n \"groups\" => array(\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\",\n ),\n \"model_plot_config\" => [\n \"enabled\" => true,\n ],\n \"renormalization_window_days\" => 30,\n \"background_persist_interval\" => \"2h\",\n \"model_snapshot_retention_days\" => 7,\n \"results_retention_days\" => 60,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"An updated job\",\"detectors\":{\"detector_index\":0,\"description\":\"An updated detector description\"},\"groups\":[\"kibana_sample_data\",\"kibana_sample_web_logs\"],\"model_plot_config\":{\"enabled\":true},\"renormalization_window_days\":30,\"background_persist_interval\":\"2h\",\"model_snapshot_retention_days\":7,\"results_retention_days\":60}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateJob(u -> u\n .backgroundPersistInterval(b -> b\n .time(\"2h\")\n )\n .description(\"An updated job\")\n .detectors(d -> d\n .detectorIndex(0)\n .description(\"An updated detector description\")\n )\n .groups(List.of(\"kibana_sample_data\",\"kibana_sample_web_logs\"))\n .jobId(\"low_request_rate\")\n .modelPlotConfig(m -> m\n .enabled(true)\n )\n .modelSnapshotRetentionDays(7L)\n .renormalizationWindowDays(30L)\n .resultsRetentionDays(60L)\n);\n" + } + ], + "specification/ml/upgrade_job_snapshot/examples/request/MlUpgradeJobSnapshotExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.upgrade_job_snapshot(\n job_id=\"low_request_rate\",\n snapshot_id=\"1828371\",\n timeout=\"45m\",\n wait_for_completion=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.upgradeJobSnapshot({\n job_id: \"low_request_rate\",\n snapshot_id: 1828371,\n timeout: \"45m\",\n wait_for_completion: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.upgrade_job_snapshot(\n job_id: \"low_request_rate\",\n snapshot_id: \"1828371\",\n timeout: \"45m\",\n wait_for_completion: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->upgradeJobSnapshot([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"1828371\",\n \"timeout\" => \"45m\",\n \"wait_for_completion\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1828371/_upgrade?timeout=45m&wait_for_completion=true\"" + }, + { + "language": "Java", + "code": "client.ml().upgradeJobSnapshot(u -> u\n .jobId(\"low_request_rate\")\n .snapshotId(\"1828371\")\n .timeout(t -> t\n .offset(45)\n )\n .waitForCompletion(true)\n);\n" + } + ], + "specification/ml/get_jobs/examples/request/MlGetJobsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_jobs(\n job_id=\"high_sum_total_sales\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getJobs({\n job_id: \"high_sum_total_sales\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_jobs(\n job_id: \"high_sum_total_sales\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getJobs([\n \"job_id\" => \"high_sum_total_sales\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales\"" + }, + { + "language": "Java", + "code": "client.ml().getJobs(g -> g\n .jobId(\"high_sum_total_sales\")\n);\n" + } + ], + "specification/ml/get_model_snapshot_upgrade_stats/examples/request/MlGetModelSnapshotUpgradeStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_model_snapshot_upgrade_stats(\n job_id=\"low_request_rate\",\n snapshot_id=\"_all\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getModelSnapshotUpgradeStats({\n job_id: \"low_request_rate\",\n snapshot_id: \"_all\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_model_snapshot_upgrade_stats(\n job_id: \"low_request_rate\",\n snapshot_id: \"_all\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getModelSnapshotUpgradeStats([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"_all\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/_all/_upgrade/_stats\"" + }, + { + "language": "Java", + "code": "client.ml().getModelSnapshotUpgradeStats(g -> g\n .jobId(\"low_request_rate\")\n .snapshotId(\"_all\")\n);\n" + } + ], + "specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_model_snapshot(\n job_id=\"it_ops_new_logs\",\n snapshot_id=\"1491852978\",\n description=\"Snapshot 1\",\n retain=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateModelSnapshot({\n job_id: \"it_ops_new_logs\",\n snapshot_id: 1491852978,\n description: \"Snapshot 1\",\n retain: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_model_snapshot(\n job_id: \"it_ops_new_logs\",\n snapshot_id: \"1491852978\",\n body: {\n \"description\": \"Snapshot 1\",\n \"retain\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateModelSnapshot([\n \"job_id\" => \"it_ops_new_logs\",\n \"snapshot_id\" => \"1491852978\",\n \"body\" => [\n \"description\" => \"Snapshot 1\",\n \"retain\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Snapshot 1\",\"retain\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateModelSnapshot(u -> u\n .description(\"Snapshot 1\")\n .jobId(\"it_ops_new_logs\")\n .retain(true)\n .snapshotId(\"1491852978\")\n);\n" + } + ], + "specification/ml/put_calendar_job/examples/request/MlPutCalendarJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_calendar_job(\n calendar_id=\"planned-outages\",\n job_id=\"total-requests\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putCalendarJob({\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_calendar_job(\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putCalendarJob([\n \"calendar_id\" => \"planned-outages\",\n \"job_id\" => \"total-requests\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/jobs/total-requests\"" + }, + { + "language": "Java", + "code": "client.ml().putCalendarJob(p -> p\n .calendarId(\"planned-outages\")\n .jobId(\"total-requests\")\n);\n" + } + ], + "specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.estimate_model_memory(\n analysis_config={\n \"bucket_span\": \"5m\",\n \"detectors\": [\n {\n \"function\": \"sum\",\n \"field_name\": \"bytes\",\n \"by_field_name\": \"status\",\n \"partition_field_name\": \"app\"\n }\n ],\n \"influencers\": [\n \"source_ip\",\n \"dest_ip\"\n ]\n },\n overall_cardinality={\n \"status\": 10,\n \"app\": 50\n },\n max_bucket_cardinality={\n \"source_ip\": 300,\n \"dest_ip\": 30\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.estimateModelMemory({\n analysis_config: {\n bucket_span: \"5m\",\n detectors: [\n {\n function: \"sum\",\n field_name: \"bytes\",\n by_field_name: \"status\",\n partition_field_name: \"app\",\n },\n ],\n influencers: [\"source_ip\", \"dest_ip\"],\n },\n overall_cardinality: {\n status: 10,\n app: 50,\n },\n max_bucket_cardinality: {\n source_ip: 300,\n dest_ip: 30,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.estimate_model_memory(\n body: {\n \"analysis_config\": {\n \"bucket_span\": \"5m\",\n \"detectors\": [\n {\n \"function\": \"sum\",\n \"field_name\": \"bytes\",\n \"by_field_name\": \"status\",\n \"partition_field_name\": \"app\"\n }\n ],\n \"influencers\": [\n \"source_ip\",\n \"dest_ip\"\n ]\n },\n \"overall_cardinality\": {\n \"status\": 10,\n \"app\": 50\n },\n \"max_bucket_cardinality\": {\n \"source_ip\": 300,\n \"dest_ip\": 30\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->estimateModelMemory([\n \"body\" => [\n \"analysis_config\" => [\n \"bucket_span\" => \"5m\",\n \"detectors\" => array(\n [\n \"function\" => \"sum\",\n \"field_name\" => \"bytes\",\n \"by_field_name\" => \"status\",\n \"partition_field_name\" => \"app\",\n ],\n ),\n \"influencers\" => array(\n \"source_ip\",\n \"dest_ip\",\n ),\n ],\n \"overall_cardinality\" => [\n \"status\" => 10,\n \"app\" => 50,\n ],\n \"max_bucket_cardinality\" => [\n \"source_ip\" => 300,\n \"dest_ip\" => 30,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis_config\":{\"bucket_span\":\"5m\",\"detectors\":[{\"function\":\"sum\",\"field_name\":\"bytes\",\"by_field_name\":\"status\",\"partition_field_name\":\"app\"}],\"influencers\":[\"source_ip\",\"dest_ip\"]},\"overall_cardinality\":{\"status\":10,\"app\":50},\"max_bucket_cardinality\":{\"source_ip\":300,\"dest_ip\":30}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/_estimate_model_memory\"" + }, + { + "language": "Java", + "code": "client.ml().estimateModelMemory(e -> e\n .analysisConfig(a -> a\n .bucketSpan(b -> b\n .time(\"5m\")\n )\n .detectors(d -> d\n .byFieldName(\"status\")\n .fieldName(\"bytes\")\n .function(\"sum\")\n .partitionFieldName(\"app\")\n )\n .influencers(List.of(\"source_ip\",\"dest_ip\"))\n )\n .maxBucketCardinality(Map.of(\"dest_ip\", 30L,\"source_ip\", 300L))\n .overallCardinality(Map.of(\"app\", 50L,\"status\", 10L))\n);\n" + } + ], + "specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_categories(\n job_id=\"esxi_log\",\n page={\n \"size\": 1\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getCategories({\n job_id: \"esxi_log\",\n page: {\n size: 1,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_categories(\n job_id: \"esxi_log\",\n body: {\n \"page\": {\n \"size\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getCategories([\n \"job_id\" => \"esxi_log\",\n \"body\" => [\n \"page\" => [\n \"size\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"page\":{\"size\":1}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/esxi_log/results/categories\"" + }, + { + "language": "Java", + "code": "client.ml().getCategories(g -> g\n .jobId(\"esxi_log\")\n .page(p -> p\n .size(1)\n )\n);\n" + } + ], + "specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.post_calendar_events(\n calendar_id=\"planned-outages\",\n events=[\n {\n \"description\": \"event 1\",\n \"start_time\": 1513641600000,\n \"end_time\": 1513728000000\n },\n {\n \"description\": \"event 2\",\n \"start_time\": 1513814400000,\n \"end_time\": 1513900800000\n },\n {\n \"description\": \"event 3\",\n \"start_time\": 1514160000000,\n \"end_time\": 1514246400000\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.postCalendarEvents({\n calendar_id: \"planned-outages\",\n events: [\n {\n description: \"event 1\",\n start_time: 1513641600000,\n end_time: 1513728000000,\n },\n {\n description: \"event 2\",\n start_time: 1513814400000,\n end_time: 1513900800000,\n },\n {\n description: \"event 3\",\n start_time: 1514160000000,\n end_time: 1514246400000,\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.post_calendar_events(\n calendar_id: \"planned-outages\",\n body: {\n \"events\": [\n {\n \"description\": \"event 1\",\n \"start_time\": 1513641600000,\n \"end_time\": 1513728000000\n },\n {\n \"description\": \"event 2\",\n \"start_time\": 1513814400000,\n \"end_time\": 1513900800000\n },\n {\n \"description\": \"event 3\",\n \"start_time\": 1514160000000,\n \"end_time\": 1514246400000\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->postCalendarEvents([\n \"calendar_id\" => \"planned-outages\",\n \"body\" => [\n \"events\" => array(\n [\n \"description\" => \"event 1\",\n \"start_time\" => 1513641600000,\n \"end_time\" => 1513728000000,\n ],\n [\n \"description\" => \"event 2\",\n \"start_time\" => 1513814400000,\n \"end_time\" => 1513900800000,\n ],\n [\n \"description\" => \"event 3\",\n \"start_time\" => 1514160000000,\n \"end_time\" => 1514246400000,\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"events\":[{\"description\":\"event 1\",\"start_time\":1513641600000,\"end_time\":1513728000000},{\"description\":\"event 2\",\"start_time\":1513814400000,\"end_time\":1513900800000},{\"description\":\"event 3\",\"start_time\":1514160000000,\"end_time\":1514246400000}]}' \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events\"" + }, + { + "language": "Java", + "code": "client.ml().postCalendarEvents(p -> p\n .calendarId(\"planned-outages\")\n .events(List.of(CalendarEvent.of(c -> c\n .description(\"event 1\")\n .endTime(DateTime.ofEpochMilli(1513728000000L))\n .startTime(DateTime.ofEpochMilli(1513641600000L))),CalendarEvent.of(c -> c\n .description(\"event 2\")\n .endTime(DateTime.ofEpochMilli(1513900800000L))\n .startTime(DateTime.ofEpochMilli(1513814400000L))),CalendarEvent.of(c -> c\n .description(\"event 3\")\n .endTime(DateTime.ofEpochMilli(1514246400000L))\n .startTime(DateTime.ofEpochMilli(1514160000000L)))))\n);\n" + } + ], + "specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_datafeed(\n datafeed_id=\"datafeed-test-job\",\n query={\n \"term\": {\n \"geo.src\": \"US\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateDatafeed({\n datafeed_id: \"datafeed-test-job\",\n query: {\n term: {\n \"geo.src\": \"US\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_datafeed(\n datafeed_id: \"datafeed-test-job\",\n body: {\n \"query\": {\n \"term\": {\n \"geo.src\": \"US\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateDatafeed([\n \"datafeed_id\" => \"datafeed-test-job\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"geo.src\" => \"US\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"geo.src\":\"US\"}}}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateDatafeed(u -> u\n .datafeedId(\"datafeed-test-job\")\n .query(q -> q\n .term(t -> t\n .field(\"geo.src\")\n .value(FieldValue.of(\"US\"))\n )\n )\n);\n" + } + ], + "specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_job(\n job_id=\"job-01\",\n analysis_config={\n \"bucket_span\": \"15m\",\n \"detectors\": [\n {\n \"detector_description\": \"Sum of bytes\",\n \"function\": \"sum\",\n \"field_name\": \"bytes\"\n }\n ]\n },\n data_description={\n \"time_field\": \"timestamp\",\n \"time_format\": \"epoch_ms\"\n },\n analysis_limits={\n \"model_memory_limit\": \"11MB\"\n },\n model_plot_config={\n \"enabled\": True,\n \"annotations_enabled\": True\n },\n results_index_name=\"test-job1\",\n datafeed_config={\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"runtime_mappings\": {\n \"hour_of_day\": {\n \"type\": \"long\",\n \"script\": {\n \"source\": \"emit(doc['timestamp'].value.getHour());\"\n }\n }\n },\n \"datafeed_id\": \"datafeed-test-job1\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putJob({\n job_id: \"job-01\",\n analysis_config: {\n bucket_span: \"15m\",\n detectors: [\n {\n detector_description: \"Sum of bytes\",\n function: \"sum\",\n field_name: \"bytes\",\n },\n ],\n },\n data_description: {\n time_field: \"timestamp\",\n time_format: \"epoch_ms\",\n },\n analysis_limits: {\n model_memory_limit: \"11MB\",\n },\n model_plot_config: {\n enabled: true,\n annotations_enabled: true,\n },\n results_index_name: \"test-job1\",\n datafeed_config: {\n indices: [\"kibana_sample_data_logs\"],\n query: {\n bool: {\n must: [\n {\n match_all: {},\n },\n ],\n },\n },\n runtime_mappings: {\n hour_of_day: {\n type: \"long\",\n script: {\n source: \"emit(doc['timestamp'].value.getHour());\",\n },\n },\n },\n datafeed_id: \"datafeed-test-job1\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_job(\n job_id: \"job-01\",\n body: {\n \"analysis_config\": {\n \"bucket_span\": \"15m\",\n \"detectors\": [\n {\n \"detector_description\": \"Sum of bytes\",\n \"function\": \"sum\",\n \"field_name\": \"bytes\"\n }\n ]\n },\n \"data_description\": {\n \"time_field\": \"timestamp\",\n \"time_format\": \"epoch_ms\"\n },\n \"analysis_limits\": {\n \"model_memory_limit\": \"11MB\"\n },\n \"model_plot_config\": {\n \"enabled\": true,\n \"annotations_enabled\": true\n },\n \"results_index_name\": \"test-job1\",\n \"datafeed_config\": {\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"runtime_mappings\": {\n \"hour_of_day\": {\n \"type\": \"long\",\n \"script\": {\n \"source\": \"emit(doc['timestamp'].value.getHour());\"\n }\n }\n },\n \"datafeed_id\": \"datafeed-test-job1\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putJob([\n \"job_id\" => \"job-01\",\n \"body\" => [\n \"analysis_config\" => [\n \"bucket_span\" => \"15m\",\n \"detectors\" => array(\n [\n \"detector_description\" => \"Sum of bytes\",\n \"function\" => \"sum\",\n \"field_name\" => \"bytes\",\n ],\n ),\n ],\n \"data_description\" => [\n \"time_field\" => \"timestamp\",\n \"time_format\" => \"epoch_ms\",\n ],\n \"analysis_limits\" => [\n \"model_memory_limit\" => \"11MB\",\n ],\n \"model_plot_config\" => [\n \"enabled\" => true,\n \"annotations_enabled\" => true,\n ],\n \"results_index_name\" => \"test-job1\",\n \"datafeed_config\" => [\n \"indices\" => array(\n \"kibana_sample_data_logs\",\n ),\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"match_all\" => new ArrayObject([]),\n ],\n ),\n ],\n ],\n \"runtime_mappings\" => [\n \"hour_of_day\" => [\n \"type\" => \"long\",\n \"script\" => [\n \"source\" => \"emit(doc['timestamp'].value.getHour());\",\n ],\n ],\n ],\n \"datafeed_id\" => \"datafeed-test-job1\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis_config\":{\"bucket_span\":\"15m\",\"detectors\":[{\"detector_description\":\"Sum of bytes\",\"function\":\"sum\",\"field_name\":\"bytes\"}]},\"data_description\":{\"time_field\":\"timestamp\",\"time_format\":\"epoch_ms\"},\"analysis_limits\":{\"model_memory_limit\":\"11MB\"},\"model_plot_config\":{\"enabled\":true,\"annotations_enabled\":true},\"results_index_name\":\"test-job1\",\"datafeed_config\":{\"indices\":[\"kibana_sample_data_logs\"],\"query\":{\"bool\":{\"must\":[{\"match_all\":{}}]}},\"runtime_mappings\":{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['\"'\"'timestamp'\"'\"'].value.getHour());\"}}},\"datafeed_id\":\"datafeed-test-job1\"}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01\"" + }, + { + "language": "Java", + "code": "client.ml().putJob(p -> p\n .analysisConfig(a -> a\n .bucketSpan(b -> b\n .time(\"15m\")\n )\n .detectors(d -> d\n .detectorDescription(\"Sum of bytes\")\n .fieldName(\"bytes\")\n .function(\"sum\")\n )\n )\n .analysisLimits(an -> an\n .modelMemoryLimit(\"11MB\")\n )\n .dataDescription(d -> d\n .timeField(\"timestamp\")\n .timeFormat(\"epoch_ms\")\n )\n .datafeedConfig(d -> d\n .datafeedId(\"datafeed-test-job1\")\n .indices(\"kibana_sample_data_logs\")\n .query(q -> q\n .bool(b -> b\n .must(m -> m\n .matchAll(ma -> ma)\n )\n )\n )\n .runtimeMappings(\"hour_of_day\", r -> r\n .script(s -> s\n .source(so -> so\n .scriptString(\"emit(doc['timestamp'].value.getHour());\")\n )\n )\n .type(RuntimeFieldType.Long)\n )\n )\n .jobId(\"job-01\")\n .modelPlotConfig(m -> m\n .annotationsEnabled(true)\n .enabled(true)\n )\n .resultsIndexName(\"test-job1\")\n);\n" + } + ], + "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.evaluate_data_frame(\n index=\"house_price_predictions\",\n query={\n \"term\": {\n \"ml.is_training\": {\n \"value\": True\n }\n }\n },\n evaluation={\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {},\n \"huber\": {}\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.evaluateDataFrame({\n index: \"house_price_predictions\",\n query: {\n term: {\n \"ml.is_training\": {\n value: true,\n },\n },\n },\n evaluation: {\n regression: {\n actual_field: \"price\",\n predicted_field: \"ml.price_prediction\",\n metrics: {\n r_squared: {},\n mse: {},\n msle: {},\n huber: {},\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"term\": {\n \"ml.is_training\": {\n \"value\": true\n }\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {},\n \"huber\": {}\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"house_price_predictions\",\n \"query\" => [\n \"term\" => [\n \"ml.is_training\" => [\n \"value\" => true,\n ],\n ],\n ],\n \"evaluation\" => [\n \"regression\" => [\n \"actual_field\" => \"price\",\n \"predicted_field\" => \"ml.price_prediction\",\n \"metrics\" => [\n \"r_squared\" => new ArrayObject([]),\n \"mse\" => new ArrayObject([]),\n \"msle\" => new ArrayObject([]),\n \"huber\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"house_price_predictions\",\"query\":{\"term\":{\"ml.is_training\":{\"value\":true}}},\"evaluation\":{\"regression\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\":{},\"msle\":{},\"huber\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + }, + { + "language": "Java", + "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .regression(r -> r\n .actualField(\"price\")\n .predictedField(\"ml.price_prediction\")\n .metrics(m -> m\n .msle(ms -> ms)\n .huber(h -> h)\n )\n )\n )\n .index(\"house_price_predictions\")\n .query(q -> q\n .term(t -> t\n .field(\"ml.is_training\")\n .value(FieldValue.of(true))\n )\n )\n);\n" + } + ], + "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.evaluate_data_frame(\n index=\"house_price_predictions\",\n query={\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": False\n }\n }\n ]\n }\n },\n evaluation={\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.evaluateDataFrame({\n index: \"house_price_predictions\",\n query: {\n bool: {\n filter: [\n {\n term: {\n \"ml.is_training\": false,\n },\n },\n ],\n },\n },\n evaluation: {\n regression: {\n actual_field: \"price\",\n predicted_field: \"ml.price_prediction\",\n metrics: {\n r_squared: {},\n mse: {},\n msle: {\n offset: 10,\n },\n huber: {\n delta: 1.5,\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"house_price_predictions\",\n \"query\" => [\n \"bool\" => [\n \"filter\" => array(\n [\n \"term\" => [\n \"ml.is_training\" => false,\n ],\n ],\n ),\n ],\n ],\n \"evaluation\" => [\n \"regression\" => [\n \"actual_field\" => \"price\",\n \"predicted_field\" => \"ml.price_prediction\",\n \"metrics\" => [\n \"r_squared\" => new ArrayObject([]),\n \"mse\" => new ArrayObject([]),\n \"msle\" => [\n \"offset\" => 10,\n ],\n \"huber\" => [\n \"delta\" => 1.5,\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"house_price_predictions\",\"query\":{\"bool\":{\"filter\":[{\"term\":{\"ml.is_training\":false}}]}},\"evaluation\":{\"regression\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\":{},\"msle\":{\"offset\":10},\"huber\":{\"delta\":1.5}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + }, + { + "language": "Java", + "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .regression(r -> r\n .actualField(\"price\")\n .predictedField(\"ml.price_prediction\")\n .metrics(m -> m\n .msle(ms -> ms\n .offset(10.0D)\n )\n .huber(h -> h\n .delta(1.5D)\n )\n )\n )\n )\n .index(\"house_price_predictions\")\n .query(q -> q\n .bool(b -> b\n .filter(f -> f\n .term(t -> t\n .field(\"ml.is_training\")\n .value(FieldValue.of(false))\n )\n )\n )\n )\n);\n" + } + ], + "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.evaluate_data_frame(\n index=\"my_analytics_dest_index\",\n evaluation={\n \"outlier_detection\": {\n \"actual_field\": \"is_outlier\",\n \"predicted_probability_field\": \"ml.outlier_score\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.evaluateDataFrame({\n index: \"my_analytics_dest_index\",\n evaluation: {\n outlier_detection: {\n actual_field: \"is_outlier\",\n predicted_probability_field: \"ml.outlier_score\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"my_analytics_dest_index\",\n \"evaluation\": {\n \"outlier_detection\": {\n \"actual_field\": \"is_outlier\",\n \"predicted_probability_field\": \"ml.outlier_score\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"my_analytics_dest_index\",\n \"evaluation\" => [\n \"outlier_detection\" => [\n \"actual_field\" => \"is_outlier\",\n \"predicted_probability_field\" => \"ml.outlier_score\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_analytics_dest_index\",\"evaluation\":{\"outlier_detection\":{\"actual_field\":\"is_outlier\",\"predicted_probability_field\":\"ml.outlier_score\"}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + }, + { + "language": "Java", + "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .outlierDetection(o -> o\n .actualField(\"is_outlier\")\n .predictedProbabilityField(\"ml.outlier_score\")\n )\n )\n .index(\"my_analytics_dest_index\")\n);\n" + } + ], + "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.evaluate_data_frame(\n index=\"animal_classification\",\n evaluation={\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"metrics\": {\n \"auc_roc\": {\n \"class_name\": \"dog\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.evaluateDataFrame({\n index: \"animal_classification\",\n evaluation: {\n classification: {\n actual_field: \"animal_class\",\n metrics: {\n auc_roc: {\n class_name: \"dog\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"animal_classification\",\n \"evaluation\": {\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"metrics\": {\n \"auc_roc\": {\n \"class_name\": \"dog\"\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"animal_classification\",\n \"evaluation\" => [\n \"classification\" => [\n \"actual_field\" => \"animal_class\",\n \"metrics\" => [\n \"auc_roc\" => [\n \"class_name\" => \"dog\",\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"metrics\":{\"auc_roc\":{\"class_name\":\"dog\"}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + }, + { + "language": "Java", + "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .classification(c -> c\n .actualField(\"animal_class\")\n .metrics(m -> m\n .aucRoc(a -> a\n .className(\"dog\")\n )\n )\n )\n )\n .index(\"animal_classification\")\n);\n" + } + ], + "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.evaluate_data_frame(\n index=\"animal_classification\",\n evaluation={\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"predicted_field\": \"ml.animal_class_prediction\",\n \"metrics\": {\n \"multiclass_confusion_matrix\": {}\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.evaluateDataFrame({\n index: \"animal_classification\",\n evaluation: {\n classification: {\n actual_field: \"animal_class\",\n predicted_field: \"ml.animal_class_prediction\",\n metrics: {\n multiclass_confusion_matrix: {},\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"animal_classification\",\n \"evaluation\": {\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"predicted_field\": \"ml.animal_class_prediction\",\n \"metrics\": {\n \"multiclass_confusion_matrix\": {}\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"animal_classification\",\n \"evaluation\" => [\n \"classification\" => [\n \"actual_field\" => \"animal_class\",\n \"predicted_field\" => \"ml.animal_class_prediction\",\n \"metrics\" => [\n \"multiclass_confusion_matrix\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"predicted_field\":\"ml.animal_class_prediction\",\"metrics\":{\"multiclass_confusion_matrix\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + }, + { + "language": "Java", + "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .classification(c -> c\n .actualField(\"animal_class\")\n .predictedField(\"ml.animal_class_prediction\")\n .metrics(m -> m)\n )\n )\n .index(\"animal_classification\")\n);\n" + } + ], + "specification/ml/delete_forecast/examples/request/MlDeleteForecastExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_forecast(\n job_id=\"total-requests\",\n forecast_id=\"_all\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteForecast({\n job_id: \"total-requests\",\n forecast_id: \"_all\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_forecast(\n job_id: \"total-requests\",\n forecast_id: \"_all\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteForecast([\n \"job_id\" => \"total-requests\",\n \"forecast_id\" => \"_all\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests/_forecast/_all\"" + }, + { + "language": "Java", + "code": "client.ml().deleteForecast(d -> d\n .forecastId(\"_all\")\n .jobId(\"total-requests\")\n);\n" + } + ], + "specification/ml/get_trained_models/examples/request/MlGetTrainedModelsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_trained_models()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getTrainedModels();" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_trained_models" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getTrainedModels();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/\"" + }, + { + "language": "Java", + "code": "client.ml().getTrainedModels(g -> g);\n" + } + ], + "specification/ml/get_trained_models_stats/examples/request/MlGetTrainedModelsStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_trained_models_stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getTrainedModelsStats();" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_trained_models_stats" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getTrainedModelsStats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/_stats\"" + }, + { + "language": "Java", + "code": "client.ml().getTrainedModelsStats(g -> g);\n" + } + ], + "specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_influencers(\n job_id=\"high_sum_total_sales\",\n sort=\"influencer_score\",\n desc=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getInfluencers({\n job_id: \"high_sum_total_sales\",\n sort: \"influencer_score\",\n desc: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_influencers(\n job_id: \"high_sum_total_sales\",\n body: {\n \"sort\": \"influencer_score\",\n \"desc\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getInfluencers([\n \"job_id\" => \"high_sum_total_sales\",\n \"body\" => [\n \"sort\" => \"influencer_score\",\n \"desc\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":\"influencer_score\",\"desc\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/results/influencers\"" + }, + { + "language": "Java", + "code": "client.ml().getInfluencers(g -> g\n .jobId(\"high_sum_total_sales\")\n);\n" + } + ], + "specification/ml/reset_job/examples/request/MlResetJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.reset_job(\n job_id=\"total-requests\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.resetJob({\n job_id: \"total-requests\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.reset_job(\n job_id: \"total-requests\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->resetJob([\n \"job_id\" => \"total-requests\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests/_reset\"" + }, + { + "language": "Java", + "code": "client.ml().resetJob(r -> r\n .jobId(\"total-requests\")\n);\n" + } + ], + "specification/ml/get_data_frame_analytics_stats/examples/request/MlGetDataFrameAnalyticsStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_data_frame_analytics_stats(\n id=\"weblog-outliers\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getDataFrameAnalyticsStats({\n id: \"weblog-outliers\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_data_frame_analytics_stats(\n id: \"weblog-outliers\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getDataFrameAnalyticsStats([\n \"id\" => \"weblog-outliers\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/weblog-outliers/_stats\"" + }, + { + "language": "Java", + "code": "client.ml().getDataFrameAnalyticsStats(g -> g\n .id(\"weblog-outliers\")\n);\n" + } + ], + "specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_calendar(\n calendar_id=\"planned-outages\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putCalendar({\n calendar_id: \"planned-outages\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_calendar(\n calendar_id: \"planned-outages\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putCalendar([\n \"calendar_id\" => \"planned-outages\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" + }, + { + "language": "Java", + "code": "client.ml().putCalendar(p -> p\n .calendarId(\"planned-outages\")\n);\n" + } + ], + "specification/ml/delete_filter/examples/request/MlDeleteFilterExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_filter(\n filter_id=\"safe_domains\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteFilter({\n filter_id: \"safe_domains\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_filter(\n filter_id: \"safe_domains\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteFilter([\n \"filter_id\" => \"safe_domains\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" + }, + { + "language": "Java", + "code": "client.ml().deleteFilter(d -> d\n .filterId(\"safe_domains\")\n);\n" + } + ], + "specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_filter(\n filter_id=\"safe_domains\",\n description=\"Updated list of domains\",\n add_items=[\n \"*.myorg.com\"\n ],\n remove_items=[\n \"wikipedia.org\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateFilter({\n filter_id: \"safe_domains\",\n description: \"Updated list of domains\",\n add_items: [\"*.myorg.com\"],\n remove_items: [\"wikipedia.org\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_filter(\n filter_id: \"safe_domains\",\n body: {\n \"description\": \"Updated list of domains\",\n \"add_items\": [\n \"*.myorg.com\"\n ],\n \"remove_items\": [\n \"wikipedia.org\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateFilter([\n \"filter_id\" => \"safe_domains\",\n \"body\" => [\n \"description\" => \"Updated list of domains\",\n \"add_items\" => array(\n \"*.myorg.com\",\n ),\n \"remove_items\" => array(\n \"wikipedia.org\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Updated list of domains\",\"add_items\":[\"*.myorg.com\"],\"remove_items\":[\"wikipedia.org\"]}' \"$ELASTICSEARCH_URL/_ml/filters/safe_domains/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateFilter(u -> u\n .addItems(\"*.myorg.com\")\n .description(\"Updated list of domains\")\n .filterId(\"safe_domains\")\n .removeItems(\"wikipedia.org\")\n);\n" + } + ], + "specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_expired_data(\n timeout=\"1h\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteExpiredData({\n timeout: \"1h\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_expired_data(\n timeout: \"1h\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteExpiredData([\n \"timeout\" => \"1h\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/_delete_expired_data?timeout=1h\"" + }, + { + "language": "Java", + "code": "client.ml().deleteExpiredData(d -> d\n .timeout(t -> t\n .offset(1)\n )\n);\n" + } + ], + "specification/ml/clear_trained_model_deployment_cache/examples/request/MlClearTrainedModelDeploymentCacheExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.clear_trained_model_deployment_cache(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.clearTrainedModelDeploymentCache({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.clear_trained_model_deployment_cache(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->clearTrainedModelDeploymentCache([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/cache/_clear\"" + }, + { + "language": "Java", + "code": "client.ml().clearTrainedModelDeploymentCache(c -> c\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n);\n" + } + ], + "specification/ml/delete_calendar/examples/request/MlDeleteCalendarExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_calendar(\n calendar_id=\"planned-outages\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteCalendar({\n calendar_id: \"planned-outages\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_calendar(\n calendar_id: \"planned-outages\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteCalendar([\n \"calendar_id\" => \"planned-outages\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" + }, + { + "language": "Java", + "code": "client.ml().deleteCalendar(d -> d\n .calendarId(\"planned-outages\")\n);\n" + } + ], + "specification/ml/get_filters/examples/request/MlGetFiltersExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_filters(\n filter_id=\"safe_domains\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getFilters({\n filter_id: \"safe_domains\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_filters(\n filter_id: \"safe_domains\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getFilters([\n \"filter_id\" => \"safe_domains\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" + }, + { + "language": "Java", + "code": "client.ml().getFilters(g -> g\n .filterId(\"safe_domains\")\n);\n" + } + ], + "specification/ml/put_trained_model_alias/examples/request/MlPutTrainedModelAliasExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_trained_model_alias(\n model_id=\"flight-delay-prediction-1574775339910\",\n model_alias=\"flight_delay_model\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putTrainedModelAlias({\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_trained_model_alias(\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putTrainedModelAlias([\n \"model_id\" => \"flight-delay-prediction-1574775339910\",\n \"model_alias\" => \"flight_delay_model\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model\"" + }, + { + "language": "Java", + "code": "client.ml().putTrainedModelAlias(p -> p\n .modelAlias(\"flight_delay_model\")\n .modelId(\"flight-delay-prediction-1574775339910\")\n);\n" + } + ], + "specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_trained_model_deployment(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n number_of_allocations=4,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateTrainedModelDeployment({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n number_of_allocations: 4,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_trained_model_deployment(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n body: {\n \"number_of_allocations\": 4\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateTrainedModelDeployment([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"body\" => [\n \"number_of_allocations\" => 4,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"number_of_allocations\":4}' \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateTrainedModelDeployment(u -> u\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .numberOfAllocations(4)\n);\n" + } + ], + "specification/ml/info/examples/request/MlInfoExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.info()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.info();" + }, + { + "language": "Ruby", + "code": "response = client.ml.info" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->info();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/info\"" + }, + { + "language": "Java", + "code": "client.ml().info();\n" + } + ], + "specification/ml/delete_job/examples/request/MlDeleteJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_job(\n job_id=\"total-requests\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteJob({\n job_id: \"total-requests\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_job(\n job_id: \"total-requests\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteJob([\n \"job_id\" => \"total-requests\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests\"" + }, + { + "language": "Java", + "code": "client.ml().deleteJob(d -> d\n .jobId(\"total-requests\")\n);\n" + } + ], + "specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_buckets(\n job_id=\"low_request_rate\",\n anomaly_score=80,\n start=\"1454530200001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getBuckets({\n job_id: \"low_request_rate\",\n anomaly_score: 80,\n start: 1454530200001,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_buckets(\n job_id: \"low_request_rate\",\n body: {\n \"anomaly_score\": 80,\n \"start\": \"1454530200001\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getBuckets([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"anomaly_score\" => 80,\n \"start\" => \"1454530200001\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"anomaly_score\":80,\"start\":\"1454530200001\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/buckets\"" + }, + { + "language": "Java", + "code": "client.ml().getBuckets(g -> g\n .anomalyScore(80.0D)\n .jobId(\"low_request_rate\")\n .start(DateTime.of(\"1454530200001\"))\n);\n" + } + ], + "specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.start_trained_model_deployment(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for=\"started\",\n timeout=\"1m\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.startTrainedModelDeployment({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for: \"started\",\n timeout: \"1m\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.start_trained_model_deployment(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for: \"started\",\n timeout: \"1m\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->startTrainedModelDeployment([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"wait_for\" => \"started\",\n \"timeout\" => \"1m\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_start?wait_for=started&timeout=1m\"" + }, + { + "language": "Java", + "code": "client.ml().startTrainedModelDeployment(s -> s\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .timeout(t -> t\n .offset(1)\n )\n .waitFor(DeploymentAllocationState.Started)\n);\n" + } + ], + "specification/ml/delete_calendar_event/examples/request/MlDeleteCalendarEventExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_calendar_event(\n calendar_id=\"planned-outages\",\n event_id=\"LS8LJGEBMTCMA-qz49st\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteCalendarEvent({\n calendar_id: \"planned-outages\",\n event_id: \"LS8LJGEBMTCMA-qz49st\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_calendar_event(\n calendar_id: \"planned-outages\",\n event_id: \"LS8LJGEBMTCMA-qz49st\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteCalendarEvent([\n \"calendar_id\" => \"planned-outages\",\n \"event_id\" => \"LS8LJGEBMTCMA-qz49st\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events/LS8LJGEBMTCMA-qz49st\"" + }, + { + "language": "Java", + "code": "client.ml().deleteCalendarEvent(d -> d\n .calendarId(\"planned-outages\")\n .eventId(\"LS8LJGEBMTCMA-qz49st\")\n);\n" + } + ], + "specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_records(\n job_id=\"low_request_rate\",\n sort=\"record_score\",\n desc=True,\n start=\"1454944100000\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getRecords({\n job_id: \"low_request_rate\",\n sort: \"record_score\",\n desc: true,\n start: 1454944100000,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_records(\n job_id: \"low_request_rate\",\n body: {\n \"sort\": \"record_score\",\n \"desc\": true,\n \"start\": \"1454944100000\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getRecords([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"sort\" => \"record_score\",\n \"desc\" => true,\n \"start\" => \"1454944100000\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":\"record_score\",\"desc\":true,\"start\":\"1454944100000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/records\"" + }, + { + "language": "Java", + "code": "client.ml().getRecords(g -> g\n .desc(true)\n .jobId(\"low_request_rate\")\n .sort(\"record_score\")\n .start(DateTime.of(\"1454944100000\"))\n);\n" + } + ], + "specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_memory_stats(\n human=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getMemoryStats({\n human: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_memory_stats(\n human: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getMemoryStats([\n \"human\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/memory/_stats?human\"" + }, + { + "language": "Java", + "code": "\n" + } + ], + "specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.start_datafeed(\n datafeed_id=\"datafeed-low_request_rate\",\n start=\"2019-04-07T18:22:16Z\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.startDatafeed({\n datafeed_id: \"datafeed-low_request_rate\",\n start: \"2019-04-07T18:22:16Z\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.start_datafeed(\n datafeed_id: \"datafeed-low_request_rate\",\n body: {\n \"start\": \"2019-04-07T18:22:16Z\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->startDatafeed([\n \"datafeed_id\" => \"datafeed-low_request_rate\",\n \"body\" => [\n \"start\" => \"2019-04-07T18:22:16Z\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"start\":\"2019-04-07T18:22:16Z\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_start\"" + }, + { + "language": "Java", + "code": "client.ml().startDatafeed(s -> s\n .datafeedId(\"datafeed-low_request_rate\")\n .start(DateTime.of(\"2019-04-07T18:22:16Z\"))\n);\n" + } + ], + "specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.explain_data_frame_analytics(\n source={\n \"index\": \"houses_sold_last_10_yrs\"\n },\n analysis={\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.explainDataFrameAnalytics({\n source: {\n index: \"houses_sold_last_10_yrs\",\n },\n analysis: {\n regression: {\n dependent_variable: \"price\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.explain_data_frame_analytics(\n body: {\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->explainDataFrameAnalytics([\n \"body\" => [\n \"source\" => [\n \"index\" => \"houses_sold_last_10_yrs\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"price\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"houses_sold_last_10_yrs\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"price\"}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/_explain\"" + }, + { + "language": "Java", + "code": "client.ml().explainDataFrameAnalytics(e -> e\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"price\")\n )\n )\n .source(s -> s\n .index(\"houses_sold_last_10_yrs\")\n )\n);\n" + } + ], + "specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.flush_job(\n job_id=\"low_request_rate\",\n calc_interim=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.flushJob({\n job_id: \"low_request_rate\",\n calc_interim: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.flush_job(\n job_id: \"low_request_rate\",\n body: {\n \"calc_interim\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->flushJob([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"calc_interim\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"calc_interim\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_flush\"" + }, + { + "language": "Java", + "code": "client.ml().flushJob(f -> f\n .calcInterim(true)\n .jobId(\"low_request_rate\")\n);\n" + } + ], + "specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_model_snapshots(\n job_id=\"high_sum_total_sales\",\n start=\"1575402236000\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getModelSnapshots({\n job_id: \"high_sum_total_sales\",\n start: 1575402236000,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_model_snapshots(\n job_id: \"high_sum_total_sales\",\n body: {\n \"start\": \"1575402236000\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getModelSnapshots([\n \"job_id\" => \"high_sum_total_sales\",\n \"body\" => [\n \"start\" => \"1575402236000\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"start\":\"1575402236000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/model_snapshots\"" + }, + { + "language": "Java", + "code": "client.ml().getModelSnapshots(g -> g\n .jobId(\"high_sum_total_sales\")\n .start(DateTime.of(\"1575402236000\"))\n);\n" + } + ], + "specification/ml/set_upgrade_mode/examples/request/MlSetUpgradeModeExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.set_upgrade_mode(\n enabled=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.setUpgradeMode({\n enabled: \"true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.set_upgrade_mode(\n enabled: \"true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->setUpgradeMode([\n \"enabled\" => \"true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/set_upgrade_mode?enabled=true\"" + }, + { + "language": "Java", + "code": "client.ml().setUpgradeMode(s -> s\n .enabled(true)\n);\n" + } + ], + "specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.update_data_frame_analytics(\n id=\"loganalytics\",\n model_memory_limit=\"200mb\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.updateDataFrameAnalytics({\n id: \"loganalytics\",\n model_memory_limit: \"200mb\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.update_data_frame_analytics(\n id: \"loganalytics\",\n body: {\n \"model_memory_limit\": \"200mb\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->updateDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n \"body\" => [\n \"model_memory_limit\" => \"200mb\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"model_memory_limit\":\"200mb\"}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_update\"" + }, + { + "language": "Java", + "code": "client.ml().updateDataFrameAnalytics(u -> u\n .id(\"loganalytics\")\n .modelMemoryLimit(\"200mb\")\n);\n" + } + ], + "specification/ml/delete_trained_model/examples/request/MlDeleteTrainedModelExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_trained_model(\n model_id=\"regression-job-one-1574775307356\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteTrainedModel({\n model_id: \"regression-job-one-1574775307356\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_trained_model(\n model_id: \"regression-job-one-1574775307356\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteTrainedModel([\n \"model_id\" => \"regression-job-one-1574775307356\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/regression-job-one-1574775307356\"" + }, + { + "language": "Java", + "code": "client.ml().deleteTrainedModel(d -> d\n .modelId(\"regression-job-one-1574775307356\")\n);\n" + } + ], + "specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_overall_buckets(\n job_id=\"job-*\",\n overall_score=80,\n start=\"1403532000000\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getOverallBuckets({\n job_id: \"job-*\",\n overall_score: 80,\n start: 1403532000000,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_overall_buckets(\n job_id: \"job-*\",\n body: {\n \"overall_score\": 80,\n \"start\": \"1403532000000\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getOverallBuckets([\n \"job_id\" => \"job-*\",\n \"body\" => [\n \"overall_score\" => 80,\n \"start\" => \"1403532000000\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"overall_score\":80,\"start\":\"1403532000000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-*/results/overall_buckets\"" + }, + { + "language": "Java", + "code": "client.ml().getOverallBuckets(g -> g\n .jobId(\"job-*\")\n .overallScore(\"80\")\n .start(DateTime.of(\"1403532000000\"))\n);\n" + } + ], + "specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.preview_datafeed(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.previewDatafeed({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.preview_datafeed(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->previewDatafeed([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_preview\"" + }, + { + "language": "Java", + "code": "client.ml().previewDatafeed(p -> p\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" + } + ], + "specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_trained_model_vocabulary(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n vocabulary=[\n \"[PAD]\",\n \"[unused0]\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putTrainedModelVocabulary({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n vocabulary: [\"[PAD]\", \"[unused0]\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_trained_model_vocabulary(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n body: {\n \"vocabulary\": [\n \"[PAD]\",\n \"[unused0]\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putTrainedModelVocabulary([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"body\" => [\n \"vocabulary\" => array(\n \"[PAD]\",\n \"[unused0]\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"vocabulary\":[\"[PAD]\",\"[unused0]\"]}' \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary\"" + }, + { + "language": "Java", + "code": "client.ml().putTrainedModelVocabulary(p -> p\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .vocabulary(List.of(\"[PAD]\",\"[unused0]\"))\n);\n" + } + ], + "specification/ml/get_data_frame_analytics/examples/request/MlGetDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_data_frame_analytics(\n id=\"loganalytics\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getDataFrameAnalytics({\n id: \"loganalytics\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_data_frame_analytics(\n id: \"loganalytics\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics\"" + }, + { + "language": "Java", + "code": "client.ml().getDataFrameAnalytics(g -> g\n .id(\"loganalytics\")\n);\n" + } + ], + "specification/ml/delete_trained_model_alias/examples/request/MlDeleteTrainedModelAliasExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_trained_model_alias(\n model_id=\"flight-delay-prediction-1574775339910\",\n model_alias=\"flight_delay_model\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteTrainedModelAlias({\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_trained_model_alias(\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteTrainedModelAlias([\n \"model_id\" => \"flight-delay-prediction-1574775339910\",\n \"model_alias\" => \"flight_delay_model\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model\"" + }, + { + "language": "Java", + "code": "client.ml().deleteTrainedModelAlias(d -> d\n .modelAlias(\"flight_delay_model\")\n .modelId(\"flight-delay-prediction-1574775339910\")\n);\n" + } + ], + "specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.revert_model_snapshot(\n job_id=\"low_request_rate\",\n snapshot_id=\"1637092688\",\n delete_intervening_results=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.revertModelSnapshot({\n job_id: \"low_request_rate\",\n snapshot_id: 1637092688,\n delete_intervening_results: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.revert_model_snapshot(\n job_id: \"low_request_rate\",\n snapshot_id: \"1637092688\",\n body: {\n \"delete_intervening_results\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->revertModelSnapshot([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"1637092688\",\n \"body\" => [\n \"delete_intervening_results\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"delete_intervening_results\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1637092688/_revert\"" + }, + { + "language": "Java", + "code": "client.ml().revertModelSnapshot(r -> r\n .deleteInterveningResults(true)\n .jobId(\"low_request_rate\")\n .snapshotId(\"1637092688\")\n);\n" + } + ], + "specification/ml/close_job/examples/request/MlCloseJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.close_job(\n job_id=\"low_request_rate\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.closeJob({\n job_id: \"low_request_rate\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.close_job(\n job_id: \"low_request_rate\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->closeJob([\n \"job_id\" => \"low_request_rate\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_close\"" + }, + { + "language": "Java", + "code": "client.ml().closeJob(c -> c\n .jobId(\"low_request_rate\")\n);\n" + } + ], + "specification/ml/put_trained_model_definition_part/examples/request/MlPutTrainedModelDefinitionPartExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_trained_model_definition_part(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part=\"0\",\n definition=\"...\",\n total_definition_length=265632637,\n total_parts=64,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putTrainedModelDefinitionPart({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part: 0,\n definition: \"...\",\n total_definition_length: 265632637,\n total_parts: 64,\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_trained_model_definition_part(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part: \"0\",\n body: {\n \"definition\": \"...\",\n \"total_definition_length\": 265632637,\n \"total_parts\": 64\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putTrainedModelDefinitionPart([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"part\" => \"0\",\n \"body\" => [\n \"definition\" => \"...\",\n \"total_definition_length\" => 265632637,\n \"total_parts\" => 64,\n ],\n]);" + }, + { + "language": "curl", + "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\"" + } + ], + "specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_data_frame_analytics(\n id=\"model-flight-delays-pre\",\n source={\n \"index\": [\n \"kibana_sample_data_flights\"\n ],\n \"query\": {\n \"range\": {\n \"DistanceKilometers\": {\n \"gt\": 0\n }\n }\n },\n \"_source\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightDelay\",\n \"FlightDelayType\"\n ]\n }\n },\n dest={\n \"index\": \"df-flight-delays\",\n \"results_field\": \"ml-results\"\n },\n analysis={\n \"regression\": {\n \"dependent_variable\": \"FlightDelayMin\",\n \"training_percent\": 90\n }\n },\n analyzed_fields={\n \"includes\": [],\n \"excludes\": [\n \"FlightNum\"\n ]\n },\n model_memory_limit=\"100mb\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putDataFrameAnalytics({\n id: \"model-flight-delays-pre\",\n source: {\n index: [\"kibana_sample_data_flights\"],\n query: {\n range: {\n DistanceKilometers: {\n gt: 0,\n },\n },\n },\n _source: {\n includes: [],\n excludes: [\"FlightDelay\", \"FlightDelayType\"],\n },\n },\n dest: {\n index: \"df-flight-delays\",\n results_field: \"ml-results\",\n },\n analysis: {\n regression: {\n dependent_variable: \"FlightDelayMin\",\n training_percent: 90,\n },\n },\n analyzed_fields: {\n includes: [],\n excludes: [\"FlightNum\"],\n },\n model_memory_limit: \"100mb\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_data_frame_analytics(\n id: \"model-flight-delays-pre\",\n body: {\n \"source\": {\n \"index\": [\n \"kibana_sample_data_flights\"\n ],\n \"query\": {\n \"range\": {\n \"DistanceKilometers\": {\n \"gt\": 0\n }\n }\n },\n \"_source\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightDelay\",\n \"FlightDelayType\"\n ]\n }\n },\n \"dest\": {\n \"index\": \"df-flight-delays\",\n \"results_field\": \"ml-results\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"FlightDelayMin\",\n \"training_percent\": 90\n }\n },\n \"analyzed_fields\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightNum\"\n ]\n },\n \"model_memory_limit\": \"100mb\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putDataFrameAnalytics([\n \"id\" => \"model-flight-delays-pre\",\n \"body\" => [\n \"source\" => [\n \"index\" => array(\n \"kibana_sample_data_flights\",\n ),\n \"query\" => [\n \"range\" => [\n \"DistanceKilometers\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"_source\" => [\n \"includes\" => array(\n ),\n \"excludes\" => array(\n \"FlightDelay\",\n \"FlightDelayType\",\n ),\n ],\n ],\n \"dest\" => [\n \"index\" => \"df-flight-delays\",\n \"results_field\" => \"ml-results\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"FlightDelayMin\",\n \"training_percent\" => 90,\n ],\n ],\n \"analyzed_fields\" => [\n \"includes\" => array(\n ),\n \"excludes\" => array(\n \"FlightNum\",\n ),\n ],\n \"model_memory_limit\" => \"100mb\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":[\"kibana_sample_data_flights\"],\"query\":{\"range\":{\"DistanceKilometers\":{\"gt\":0}}},\"_source\":{\"includes\":[],\"excludes\":[\"FlightDelay\",\"FlightDelayType\"]}},\"dest\":{\"index\":\"df-flight-delays\",\"results_field\":\"ml-results\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"FlightDelayMin\",\"training_percent\":90}},\"analyzed_fields\":{\"includes\":[],\"excludes\":[\"FlightNum\"]},\"model_memory_limit\":\"100mb\"}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/model-flight-delays-pre\"" + }, + { + "language": "Java", + "code": "client.ml().putDataFrameAnalytics(p -> p\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"FlightDelayMin\")\n .trainingPercent(\"90\")\n )\n )\n .analyzedFields(an -> an\n .excludes(\"FlightNum\")\n )\n .dest(d -> d\n .index(\"df-flight-delays\")\n .resultsField(\"ml-results\")\n )\n .id(\"model-flight-delays-pre\")\n .modelMemoryLimit(\"100mb\")\n .source(s -> s\n .index(\"kibana_sample_data_flights\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"DistanceKilometers\")\n .gt(JsonData.fromJson(\"0\"))\n )\n )\n )\n .source(so -> so\n .excludes(List.of(\"FlightDelay\",\"FlightDelayType\"))\n )\n )\n);\n" + } + ], + "specification/ml/delete_data_frame_analytics/examples/request/MlDeleteDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.delete_data_frame_analytics(\n id=\"loganalytics\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.deleteDataFrameAnalytics({\n id: \"loganalytics\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.delete_data_frame_analytics(\n id: \"loganalytics\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->deleteDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics\"" + }, + { + "language": "Java", + "code": "client.ml().deleteDataFrameAnalytics(d -> d\n .id(\"loganalytics\")\n);\n" + } + ], + "specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.preview_data_frame_analytics(\n config={\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.previewDataFrameAnalytics({\n config: {\n source: {\n index: \"houses_sold_last_10_yrs\",\n },\n analysis: {\n regression: {\n dependent_variable: \"price\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.preview_data_frame_analytics(\n body: {\n \"config\": {\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->previewDataFrameAnalytics([\n \"body\" => [\n \"config\" => [\n \"source\" => [\n \"index\" => \"houses_sold_last_10_yrs\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"price\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"config\":{\"source\":{\"index\":\"houses_sold_last_10_yrs\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"price\"}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/_preview\"" + }, + { + "language": "Java", + "code": "client.ml().previewDataFrameAnalytics(p -> p\n .config(c -> c\n .source(s -> s\n .index(\"houses_sold_last_10_yrs\")\n )\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"price\")\n )\n )\n )\n);\n" + } + ], + "specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.put_filter(\n filter_id=\"safe_domains\",\n description=\"A list of safe domains\",\n items=[\n \"*.google.com\",\n \"wikipedia.org\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.putFilter({\n filter_id: \"safe_domains\",\n description: \"A list of safe domains\",\n items: [\"*.google.com\", \"wikipedia.org\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.put_filter(\n filter_id: \"safe_domains\",\n body: {\n \"description\": \"A list of safe domains\",\n \"items\": [\n \"*.google.com\",\n \"wikipedia.org\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->putFilter([\n \"filter_id\" => \"safe_domains\",\n \"body\" => [\n \"description\" => \"A list of safe domains\",\n \"items\" => array(\n \"*.google.com\",\n \"wikipedia.org\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"A list of safe domains\",\"items\":[\"*.google.com\",\"wikipedia.org\"]}' \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" + }, + { + "language": "Java", + "code": "client.ml().putFilter(p -> p\n .description(\"A list of safe domains\")\n .filterId(\"safe_domains\")\n .items(List.of(\"*.google.com\",\"wikipedia.org\"))\n);\n" + } + ], + "specification/ml/start_data_frame_analytics/examples/request/MlStartDataFrameAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.start_data_frame_analytics(\n id=\"loganalytics\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.startDataFrameAnalytics({\n id: \"loganalytics\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.start_data_frame_analytics(\n id: \"loganalytics\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->startDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_start\"" + }, + { + "language": "Java", + "code": "client.ml().startDataFrameAnalytics(s -> s\n .id(\"loganalytics\")\n);\n" + } + ], + "specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_calendars(\n calendar_id=\"planned-outages\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getCalendars({\n calendar_id: \"planned-outages\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_calendars(\n calendar_id: \"planned-outages\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getCalendars([\n \"calendar_id\" => \"planned-outages\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" + }, + { + "language": "Java", + "code": "client.ml().getCalendars(g -> g\n .calendarId(\"planned-outages\")\n);\n" + } + ], + "specification/ml/get_job_stats/examples/request/MlGetJobStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.get_job_stats(\n job_id=\"low_request_rate\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.getJobStats({\n job_id: \"low_request_rate\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.get_job_stats(\n job_id: \"low_request_rate\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->getJobStats([\n \"job_id\" => \"low_request_rate\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_stats\"" + }, + { + "language": "Java", + "code": "client.ml().getJobStats(g -> g\n .jobId(\"low_request_rate\")\n);\n" + } + ], + "specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ml.open_job(\n job_id=\"job-01\",\n timeout=\"35m\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ml.openJob({\n job_id: \"job-01\",\n timeout: \"35m\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ml.open_job(\n job_id: \"job-01\",\n body: {\n \"timeout\": \"35m\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ml()->openJob([\n \"job_id\" => \"job-01\",\n \"body\" => [\n \"timeout\" => \"35m\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"timeout\":\"35m\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01/_open\"" + }, + { + "language": "Java", + "code": "client.ml().openJob(o -> o\n .jobId(\"job-01\")\n .timeout(t -> t\n .time(\"35m\")\n )\n);\n" + } + ], + "specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.text_structure.test_grok_pattern(\n grok_pattern=\"Hello %{WORD:first_name} %{WORD:last_name}\",\n text=[\n \"Hello John Doe\",\n \"this does not match\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.textStructure.testGrokPattern({\n grok_pattern: \"Hello %{WORD:first_name} %{WORD:last_name}\",\n text: [\"Hello John Doe\", \"this does not match\"],\n});" + }, + { + "language": "Ruby", + "code": "response = client.text_structure.test_grok_pattern(\n body: {\n \"grok_pattern\": \"Hello %{WORD:first_name} %{WORD:last_name}\",\n \"text\": [\n \"Hello John Doe\",\n \"this does not match\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->textStructure()->testGrokPattern([\n \"body\" => [\n \"grok_pattern\" => \"Hello %{WORD:first_name} %{WORD:last_name}\",\n \"text\" => array(\n \"Hello John Doe\",\n \"this does not match\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grok_pattern\":\"Hello %{WORD:first_name} %{WORD:last_name}\",\"text\":[\"Hello John Doe\",\"this does not match\"]}' \"$ELASTICSEARCH_URL/_text_structure/test_grok_pattern\"" + }, + { + "language": "Java", + "code": "client.textStructure().testGrokPattern(t -> t\n .grokPattern(\"Hello %{WORD:first_name} %{WORD:last_name}\")\n .text(List.of(\"Hello John Doe\",\"this does not match\"))\n);\n" + } + ], + "specification/text_structure/find_structure/examples/request/FindStructureRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.text_structure.find_structure(\n text_files=[\n {\n \"name\": \"Leviathan Wakes\",\n \"author\": \"James S.A. Corey\",\n \"release_date\": \"2011-06-02\",\n \"page_count\": 561\n },\n {\n \"name\": \"Hyperion\",\n \"author\": \"Dan Simmons\",\n \"release_date\": \"1989-05-26\",\n \"page_count\": 482\n },\n {\n \"name\": \"Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1965-06-01\",\n \"page_count\": 604\n },\n {\n \"name\": \"Dune Messiah\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1969-10-15\",\n \"page_count\": 331\n },\n {\n \"name\": \"Children of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1976-04-21\",\n \"page_count\": 408\n },\n {\n \"name\": \"God Emperor of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1981-05-28\",\n \"page_count\": 454\n },\n {\n \"name\": \"Consider Phlebas\",\n \"author\": \"Iain M. Banks\",\n \"release_date\": \"1987-04-23\",\n \"page_count\": 471\n },\n {\n \"name\": \"Pandora's Star\",\n \"author\": \"Peter F. Hamilton\",\n \"release_date\": \"2004-03-02\",\n \"page_count\": 768\n },\n {\n \"name\": \"Revelation Space\",\n \"author\": \"Alastair Reynolds\",\n \"release_date\": \"2000-03-15\",\n \"page_count\": 585\n },\n {\n \"name\": \"A Fire Upon the Deep\",\n \"author\": \"Vernor Vinge\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 613\n },\n {\n \"name\": \"Ender's Game\",\n \"author\": \"Orson Scott Card\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 324\n },\n {\n \"name\": \"1984\",\n \"author\": \"George Orwell\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 328\n },\n {\n \"name\": \"Fahrenheit 451\",\n \"author\": \"Ray Bradbury\",\n \"release_date\": \"1953-10-15\",\n \"page_count\": 227\n },\n {\n \"name\": \"Brave New World\",\n \"author\": \"Aldous Huxley\",\n \"release_date\": \"1932-06-01\",\n \"page_count\": 268\n },\n {\n \"name\": \"Foundation\",\n \"author\": \"Isaac Asimov\",\n \"release_date\": \"1951-06-01\",\n \"page_count\": 224\n },\n {\n \"name\": \"The Giver\",\n \"author\": \"Lois Lowry\",\n \"release_date\": \"1993-04-26\",\n \"page_count\": 208\n },\n {\n \"name\": \"Slaughterhouse-Five\",\n \"author\": \"Kurt Vonnegut\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 275\n },\n {\n \"name\": \"The Hitchhiker's Guide to the Galaxy\",\n \"author\": \"Douglas Adams\",\n \"release_date\": \"1979-10-12\",\n \"page_count\": 180\n },\n {\n \"name\": \"Snow Crash\",\n \"author\": \"Neal Stephenson\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 470\n },\n {\n \"name\": \"Neuromancer\",\n \"author\": \"William Gibson\",\n \"release_date\": \"1984-07-01\",\n \"page_count\": 271\n },\n {\n \"name\": \"The Handmaid's Tale\",\n \"author\": \"Margaret Atwood\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 311\n },\n {\n \"name\": \"Starship Troopers\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1959-12-01\",\n \"page_count\": 335\n },\n {\n \"name\": \"The Left Hand of Darkness\",\n \"author\": \"Ursula K. Le Guin\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 304\n },\n {\n \"name\": \"The Moon is a Harsh Mistress\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1966-04-01\",\n \"page_count\": 288\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.textStructure.findStructure({\n text_files: [\n {\n name: \"Leviathan Wakes\",\n author: \"James S.A. Corey\",\n release_date: \"2011-06-02\",\n page_count: 561,\n },\n {\n name: \"Hyperion\",\n author: \"Dan Simmons\",\n release_date: \"1989-05-26\",\n page_count: 482,\n },\n {\n name: \"Dune\",\n author: \"Frank Herbert\",\n release_date: \"1965-06-01\",\n page_count: 604,\n },\n {\n name: \"Dune Messiah\",\n author: \"Frank Herbert\",\n release_date: \"1969-10-15\",\n page_count: 331,\n },\n {\n name: \"Children of Dune\",\n author: \"Frank Herbert\",\n release_date: \"1976-04-21\",\n page_count: 408,\n },\n {\n name: \"God Emperor of Dune\",\n author: \"Frank Herbert\",\n release_date: \"1981-05-28\",\n page_count: 454,\n },\n {\n name: \"Consider Phlebas\",\n author: \"Iain M. Banks\",\n release_date: \"1987-04-23\",\n page_count: 471,\n },\n {\n name: \"Pandora's Star\",\n author: \"Peter F. Hamilton\",\n release_date: \"2004-03-02\",\n page_count: 768,\n },\n {\n name: \"Revelation Space\",\n author: \"Alastair Reynolds\",\n release_date: \"2000-03-15\",\n page_count: 585,\n },\n {\n name: \"A Fire Upon the Deep\",\n author: \"Vernor Vinge\",\n release_date: \"1992-06-01\",\n page_count: 613,\n },\n {\n name: \"Ender's Game\",\n author: \"Orson Scott Card\",\n release_date: \"1985-06-01\",\n page_count: 324,\n },\n {\n name: \"1984\",\n author: \"George Orwell\",\n release_date: \"1985-06-01\",\n page_count: 328,\n },\n {\n name: \"Fahrenheit 451\",\n author: \"Ray Bradbury\",\n release_date: \"1953-10-15\",\n page_count: 227,\n },\n {\n name: \"Brave New World\",\n author: \"Aldous Huxley\",\n release_date: \"1932-06-01\",\n page_count: 268,\n },\n {\n name: \"Foundation\",\n author: \"Isaac Asimov\",\n release_date: \"1951-06-01\",\n page_count: 224,\n },\n {\n name: \"The Giver\",\n author: \"Lois Lowry\",\n release_date: \"1993-04-26\",\n page_count: 208,\n },\n {\n name: \"Slaughterhouse-Five\",\n author: \"Kurt Vonnegut\",\n release_date: \"1969-06-01\",\n page_count: 275,\n },\n {\n name: \"The Hitchhiker's Guide to the Galaxy\",\n author: \"Douglas Adams\",\n release_date: \"1979-10-12\",\n page_count: 180,\n },\n {\n name: \"Snow Crash\",\n author: \"Neal Stephenson\",\n release_date: \"1992-06-01\",\n page_count: 470,\n },\n {\n name: \"Neuromancer\",\n author: \"William Gibson\",\n release_date: \"1984-07-01\",\n page_count: 271,\n },\n {\n name: \"The Handmaid's Tale\",\n author: \"Margaret Atwood\",\n release_date: \"1985-06-01\",\n page_count: 311,\n },\n {\n name: \"Starship Troopers\",\n author: \"Robert A. Heinlein\",\n release_date: \"1959-12-01\",\n page_count: 335,\n },\n {\n name: \"The Left Hand of Darkness\",\n author: \"Ursula K. Le Guin\",\n release_date: \"1969-06-01\",\n page_count: 304,\n },\n {\n name: \"The Moon is a Harsh Mistress\",\n author: \"Robert A. Heinlein\",\n release_date: \"1966-04-01\",\n page_count: 288,\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.text_structure.find_structure(\n body: [\n {\n \"name\": \"Leviathan Wakes\",\n \"author\": \"James S.A. Corey\",\n \"release_date\": \"2011-06-02\",\n \"page_count\": 561\n },\n {\n \"name\": \"Hyperion\",\n \"author\": \"Dan Simmons\",\n \"release_date\": \"1989-05-26\",\n \"page_count\": 482\n },\n {\n \"name\": \"Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1965-06-01\",\n \"page_count\": 604\n },\n {\n \"name\": \"Dune Messiah\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1969-10-15\",\n \"page_count\": 331\n },\n {\n \"name\": \"Children of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1976-04-21\",\n \"page_count\": 408\n },\n {\n \"name\": \"God Emperor of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1981-05-28\",\n \"page_count\": 454\n },\n {\n \"name\": \"Consider Phlebas\",\n \"author\": \"Iain M. Banks\",\n \"release_date\": \"1987-04-23\",\n \"page_count\": 471\n },\n {\n \"name\": \"Pandora's Star\",\n \"author\": \"Peter F. Hamilton\",\n \"release_date\": \"2004-03-02\",\n \"page_count\": 768\n },\n {\n \"name\": \"Revelation Space\",\n \"author\": \"Alastair Reynolds\",\n \"release_date\": \"2000-03-15\",\n \"page_count\": 585\n },\n {\n \"name\": \"A Fire Upon the Deep\",\n \"author\": \"Vernor Vinge\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 613\n },\n {\n \"name\": \"Ender's Game\",\n \"author\": \"Orson Scott Card\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 324\n },\n {\n \"name\": \"1984\",\n \"author\": \"George Orwell\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 328\n },\n {\n \"name\": \"Fahrenheit 451\",\n \"author\": \"Ray Bradbury\",\n \"release_date\": \"1953-10-15\",\n \"page_count\": 227\n },\n {\n \"name\": \"Brave New World\",\n \"author\": \"Aldous Huxley\",\n \"release_date\": \"1932-06-01\",\n \"page_count\": 268\n },\n {\n \"name\": \"Foundation\",\n \"author\": \"Isaac Asimov\",\n \"release_date\": \"1951-06-01\",\n \"page_count\": 224\n },\n {\n \"name\": \"The Giver\",\n \"author\": \"Lois Lowry\",\n \"release_date\": \"1993-04-26\",\n \"page_count\": 208\n },\n {\n \"name\": \"Slaughterhouse-Five\",\n \"author\": \"Kurt Vonnegut\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 275\n },\n {\n \"name\": \"The Hitchhiker's Guide to the Galaxy\",\n \"author\": \"Douglas Adams\",\n \"release_date\": \"1979-10-12\",\n \"page_count\": 180\n },\n {\n \"name\": \"Snow Crash\",\n \"author\": \"Neal Stephenson\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 470\n },\n {\n \"name\": \"Neuromancer\",\n \"author\": \"William Gibson\",\n \"release_date\": \"1984-07-01\",\n \"page_count\": 271\n },\n {\n \"name\": \"The Handmaid's Tale\",\n \"author\": \"Margaret Atwood\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 311\n },\n {\n \"name\": \"Starship Troopers\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1959-12-01\",\n \"page_count\": 335\n },\n {\n \"name\": \"The Left Hand of Darkness\",\n \"author\": \"Ursula K. Le Guin\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 304\n },\n {\n \"name\": \"The Moon is a Harsh Mistress\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1966-04-01\",\n \"page_count\": 288\n }\n ]\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->textStructure()->findStructure([\n \"body\" => array(\n [\n \"name\" => \"Leviathan Wakes\",\n \"author\" => \"James S.A. Corey\",\n \"release_date\" => \"2011-06-02\",\n \"page_count\" => 561,\n ],\n [\n \"name\" => \"Hyperion\",\n \"author\" => \"Dan Simmons\",\n \"release_date\" => \"1989-05-26\",\n \"page_count\" => 482,\n ],\n [\n \"name\" => \"Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1965-06-01\",\n \"page_count\" => 604,\n ],\n [\n \"name\" => \"Dune Messiah\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1969-10-15\",\n \"page_count\" => 331,\n ],\n [\n \"name\" => \"Children of Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1976-04-21\",\n \"page_count\" => 408,\n ],\n [\n \"name\" => \"God Emperor of Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1981-05-28\",\n \"page_count\" => 454,\n ],\n [\n \"name\" => \"Consider Phlebas\",\n \"author\" => \"Iain M. Banks\",\n \"release_date\" => \"1987-04-23\",\n \"page_count\" => 471,\n ],\n [\n \"name\" => \"Pandora's Star\",\n \"author\" => \"Peter F. Hamilton\",\n \"release_date\" => \"2004-03-02\",\n \"page_count\" => 768,\n ],\n [\n \"name\" => \"Revelation Space\",\n \"author\" => \"Alastair Reynolds\",\n \"release_date\" => \"2000-03-15\",\n \"page_count\" => 585,\n ],\n [\n \"name\" => \"A Fire Upon the Deep\",\n \"author\" => \"Vernor Vinge\",\n \"release_date\" => \"1992-06-01\",\n \"page_count\" => 613,\n ],\n [\n \"name\" => \"Ender's Game\",\n \"author\" => \"Orson Scott Card\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 324,\n ],\n [\n \"name\" => \"1984\",\n \"author\" => \"George Orwell\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 328,\n ],\n [\n \"name\" => \"Fahrenheit 451\",\n \"author\" => \"Ray Bradbury\",\n \"release_date\" => \"1953-10-15\",\n \"page_count\" => 227,\n ],\n [\n \"name\" => \"Brave New World\",\n \"author\" => \"Aldous Huxley\",\n \"release_date\" => \"1932-06-01\",\n \"page_count\" => 268,\n ],\n [\n \"name\" => \"Foundation\",\n \"author\" => \"Isaac Asimov\",\n \"release_date\" => \"1951-06-01\",\n \"page_count\" => 224,\n ],\n [\n \"name\" => \"The Giver\",\n \"author\" => \"Lois Lowry\",\n \"release_date\" => \"1993-04-26\",\n \"page_count\" => 208,\n ],\n [\n \"name\" => \"Slaughterhouse-Five\",\n \"author\" => \"Kurt Vonnegut\",\n \"release_date\" => \"1969-06-01\",\n \"page_count\" => 275,\n ],\n [\n \"name\" => \"The Hitchhiker's Guide to the Galaxy\",\n \"author\" => \"Douglas Adams\",\n \"release_date\" => \"1979-10-12\",\n \"page_count\" => 180,\n ],\n [\n \"name\" => \"Snow Crash\",\n \"author\" => \"Neal Stephenson\",\n \"release_date\" => \"1992-06-01\",\n \"page_count\" => 470,\n ],\n [\n \"name\" => \"Neuromancer\",\n \"author\" => \"William Gibson\",\n \"release_date\" => \"1984-07-01\",\n \"page_count\" => 271,\n ],\n [\n \"name\" => \"The Handmaid's Tale\",\n \"author\" => \"Margaret Atwood\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 311,\n ],\n [\n \"name\" => \"Starship Troopers\",\n \"author\" => \"Robert A. Heinlein\",\n \"release_date\" => \"1959-12-01\",\n \"page_count\" => 335,\n ],\n [\n \"name\" => \"The Left Hand of Darkness\",\n \"author\" => \"Ursula K. Le Guin\",\n \"release_date\" => \"1969-06-01\",\n \"page_count\" => 304,\n ],\n [\n \"name\" => \"The Moon is a Harsh Mistress\",\n \"author\" => \"Robert A. Heinlein\",\n \"release_date\" => \"1966-04-01\",\n \"page_count\" => 288,\n ],\n ),\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"name\":\"Leviathan Wakes\",\"author\":\"James S.A. Corey\",\"release_date\":\"2011-06-02\",\"page_count\":561},{\"name\":\"Hyperion\",\"author\":\"Dan Simmons\",\"release_date\":\"1989-05-26\",\"page_count\":482},{\"name\":\"Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1965-06-01\",\"page_count\":604},{\"name\":\"Dune Messiah\",\"author\":\"Frank Herbert\",\"release_date\":\"1969-10-15\",\"page_count\":331},{\"name\":\"Children of Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1976-04-21\",\"page_count\":408},{\"name\":\"God Emperor of Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1981-05-28\",\"page_count\":454},{\"name\":\"Consider Phlebas\",\"author\":\"Iain M. Banks\",\"release_date\":\"1987-04-23\",\"page_count\":471},{\"name\":\"Pandora'\"'\"'s Star\",\"author\":\"Peter F. Hamilton\",\"release_date\":\"2004-03-02\",\"page_count\":768},{\"name\":\"Revelation Space\",\"author\":\"Alastair Reynolds\",\"release_date\":\"2000-03-15\",\"page_count\":585},{\"name\":\"A Fire Upon the Deep\",\"author\":\"Vernor Vinge\",\"release_date\":\"1992-06-01\",\"page_count\":613},{\"name\":\"Ender'\"'\"'s Game\",\"author\":\"Orson Scott Card\",\"release_date\":\"1985-06-01\",\"page_count\":324},{\"name\":\"1984\",\"author\":\"George Orwell\",\"release_date\":\"1985-06-01\",\"page_count\":328},{\"name\":\"Fahrenheit 451\",\"author\":\"Ray Bradbury\",\"release_date\":\"1953-10-15\",\"page_count\":227},{\"name\":\"Brave New World\",\"author\":\"Aldous Huxley\",\"release_date\":\"1932-06-01\",\"page_count\":268},{\"name\":\"Foundation\",\"author\":\"Isaac Asimov\",\"release_date\":\"1951-06-01\",\"page_count\":224},{\"name\":\"The Giver\",\"author\":\"Lois Lowry\",\"release_date\":\"1993-04-26\",\"page_count\":208},{\"name\":\"Slaughterhouse-Five\",\"author\":\"Kurt Vonnegut\",\"release_date\":\"1969-06-01\",\"page_count\":275},{\"name\":\"The Hitchhiker'\"'\"'s Guide to the Galaxy\",\"author\":\"Douglas Adams\",\"release_date\":\"1979-10-12\",\"page_count\":180},{\"name\":\"Snow Crash\",\"author\":\"Neal Stephenson\",\"release_date\":\"1992-06-01\",\"page_count\":470},{\"name\":\"Neuromancer\",\"author\":\"William Gibson\",\"release_date\":\"1984-07-01\",\"page_count\":271},{\"name\":\"The Handmaid'\"'\"'s Tale\",\"author\":\"Margaret Atwood\",\"release_date\":\"1985-06-01\",\"page_count\":311},{\"name\":\"Starship Troopers\",\"author\":\"Robert A. Heinlein\",\"release_date\":\"1959-12-01\",\"page_count\":335},{\"name\":\"The Left Hand of Darkness\",\"author\":\"Ursula K. Le Guin\",\"release_date\":\"1969-06-01\",\"page_count\":304},{\"name\":\"The Moon is a Harsh Mistress\",\"author\":\"Robert A. Heinlein\",\"release_date\":\"1966-04-01\",\"page_count\":288}]' \"$ELASTICSEARCH_URL/_text_structure/find_structure\"" + } + ], + "specification/text_structure/find_field_structure/examples/request/FindFieldStructureRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.text_structure.find_field_structure(\n index=\"test-logs\",\n field=\"message\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.textStructure.findFieldStructure({\n index: \"test-logs\",\n field: \"message\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.text_structure.find_field_structure(\n index: \"test-logs\",\n field: \"message\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->textStructure()->findFieldStructure([\n \"index\" => \"test-logs\",\n \"field\" => \"message\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_text_structure/find_field_structure?index=test-logs&field=message\"" + }, + { + "language": "Java", + "code": "client.textStructure().findFieldStructure(f -> f\n .field(\"message\")\n .index(\"test-logs\")\n);\n" + } + ], + "specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.text_structure.find_message_structure(\n messages=[\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.textStructure.findMessageStructure({\n messages: [\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\",\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.text_structure.find_message_structure(\n body: {\n \"messages\": [\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->textStructure()->findMessageStructure([\n \"body\" => [\n \"messages\" => array(\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\",\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[\"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"]}' \"$ELASTICSEARCH_URL/_text_structure/find_message_structure\"" + }, + { + "language": "Java", + "code": "client.textStructure().findMessageStructure(f -> f\n .messages(List.of(\"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"))\n);\n" + } + ], + "specification/rollup/get_rollup_index_caps/examples/request/GetRollupIndexCapabilitiesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.get_rollup_index_caps(\n index=\"sensor_rollup\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.getRollupIndexCaps({\n index: \"sensor_rollup\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.get_rollup_index_caps(\n index: \"sensor_rollup\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->getRollupIndexCaps([\n \"index\" => \"sensor_rollup\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/sensor_rollup/_rollup/data\"" + }, + { + "language": "Java", + "code": "client.rollup().getRollupIndexCaps(g -> g\n .index(\"sensor_rollup\")\n);\n" + } + ], + "specification/rollup/get_jobs/examples/request/GetRollupJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.get_jobs(\n id=\"sensor\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.getJobs({\n id: \"sensor\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.get_jobs(\n id: \"sensor\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->getJobs([\n \"id\" => \"sensor\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" + }, + { + "language": "Java", + "code": "client.rollup().getJobs(g -> g\n .id(\"sensor\")\n);\n" + } + ], + "specification/rollup/stop_job/examples/request/RollupStopJobExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.stop_job(\n id=\"sensor\",\n wait_for_completion=True,\n timeout=\"10s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.stopJob({\n id: \"sensor\",\n wait_for_completion: \"true\",\n timeout: \"10s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.stop_job(\n id: \"sensor\",\n wait_for_completion: \"true\",\n timeout: \"10s\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->stopJob([\n \"id\" => \"sensor\",\n \"wait_for_completion\" => \"true\",\n \"timeout\" => \"10s\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor/_stop?wait_for_completion=true&timeout=10s\"" + }, + { + "language": "Java", + "code": "client.rollup().stopJob(s -> s\n .id(\"sensor\")\n .timeout(t -> t\n .offset(10)\n )\n .waitForCompletion(true)\n);\n" + } + ], + "specification/rollup/get_rollup_caps/examples/request/GetRollupCapabilitiesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.get_rollup_caps(\n id=\"sensor-*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.getRollupCaps({\n id: \"sensor-*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.get_rollup_caps(\n id: \"sensor-*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->getRollupCaps([\n \"id\" => \"sensor-*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/data/sensor-*\"" + }, + { + "language": "Java", + "code": "client.rollup().getRollupCaps(g -> g\n .id(\"sensor-*\")\n);\n" + } + ], + "specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.rollup_search(\n index=\"sensor_rollup\",\n size=0,\n aggregations={\n \"max_temperature\": {\n \"max\": {\n \"field\": \"temperature\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.rollupSearch({\n index: \"sensor_rollup\",\n size: 0,\n aggregations: {\n max_temperature: {\n max: {\n field: \"temperature\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.rollup_search(\n index: \"sensor_rollup\",\n body: {\n \"size\": 0,\n \"aggregations\": {\n \"max_temperature\": {\n \"max\": {\n \"field\": \"temperature\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->rollupSearch([\n \"index\" => \"sensor_rollup\",\n \"body\" => [\n \"size\" => 0,\n \"aggregations\" => [\n \"max_temperature\" => [\n \"max\" => [\n \"field\" => \"temperature\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"size\":0,\"aggregations\":{\"max_temperature\":{\"max\":{\"field\":\"temperature\"}}}}' \"$ELASTICSEARCH_URL/sensor_rollup/_rollup_search\"" + }, + { + "language": "Java", + "code": "client.rollup().rollupSearch(r -> r\n .aggregations(\"max_temperature\", a -> a\n .max(m -> m\n .field(\"temperature\")\n )\n )\n .index(\"sensor_rollup\")\n .size(0)\n);\n" + } + ], + "specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.put_job(\n id=\"sensor\",\n index_pattern=\"sensor-*\",\n rollup_index=\"sensor_rollup\",\n cron=\"*/30 * * * * ?\",\n page_size=1000,\n groups={\n \"date_histogram\": {\n \"field\": \"timestamp\",\n \"fixed_interval\": \"1h\",\n \"delay\": \"7d\"\n },\n \"terms\": {\n \"fields\": [\n \"node\"\n ]\n }\n },\n metrics=[\n {\n \"field\": \"temperature\",\n \"metrics\": [\n \"min\",\n \"max\",\n \"sum\"\n ]\n },\n {\n \"field\": \"voltage\",\n \"metrics\": [\n \"avg\"\n ]\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.putJob({\n id: \"sensor\",\n index_pattern: \"sensor-*\",\n rollup_index: \"sensor_rollup\",\n cron: \"*/30 * * * * ?\",\n page_size: 1000,\n groups: {\n date_histogram: {\n field: \"timestamp\",\n fixed_interval: \"1h\",\n delay: \"7d\",\n },\n terms: {\n fields: [\"node\"],\n },\n },\n metrics: [\n {\n field: \"temperature\",\n metrics: [\"min\", \"max\", \"sum\"],\n },\n {\n field: \"voltage\",\n metrics: [\"avg\"],\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.put_job(\n id: \"sensor\",\n body: {\n \"index_pattern\": \"sensor-*\",\n \"rollup_index\": \"sensor_rollup\",\n \"cron\": \"*/30 * * * * ?\",\n \"page_size\": 1000,\n \"groups\": {\n \"date_histogram\": {\n \"field\": \"timestamp\",\n \"fixed_interval\": \"1h\",\n \"delay\": \"7d\"\n },\n \"terms\": {\n \"fields\": [\n \"node\"\n ]\n }\n },\n \"metrics\": [\n {\n \"field\": \"temperature\",\n \"metrics\": [\n \"min\",\n \"max\",\n \"sum\"\n ]\n },\n {\n \"field\": \"voltage\",\n \"metrics\": [\n \"avg\"\n ]\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->putJob([\n \"id\" => \"sensor\",\n \"body\" => [\n \"index_pattern\" => \"sensor-*\",\n \"rollup_index\" => \"sensor_rollup\",\n \"cron\" => \"*/30 * * * * ?\",\n \"page_size\" => 1000,\n \"groups\" => [\n \"date_histogram\" => [\n \"field\" => \"timestamp\",\n \"fixed_interval\" => \"1h\",\n \"delay\" => \"7d\",\n ],\n \"terms\" => [\n \"fields\" => array(\n \"node\",\n ),\n ],\n ],\n \"metrics\" => array(\n [\n \"field\" => \"temperature\",\n \"metrics\" => array(\n \"min\",\n \"max\",\n \"sum\",\n ),\n ],\n [\n \"field\" => \"voltage\",\n \"metrics\" => array(\n \"avg\",\n ),\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_pattern\":\"sensor-*\",\"rollup_index\":\"sensor_rollup\",\"cron\":\"*/30 * * * * ?\",\"page_size\":1000,\"groups\":{\"date_histogram\":{\"field\":\"timestamp\",\"fixed_interval\":\"1h\",\"delay\":\"7d\"},\"terms\":{\"fields\":[\"node\"]}},\"metrics\":[{\"field\":\"temperature\",\"metrics\":[\"min\",\"max\",\"sum\"]},{\"field\":\"voltage\",\"metrics\":[\"avg\"]}]}' \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" + }, + { + "language": "Java", + "code": "client.rollup().putJob(p -> p\n .cron(\"*/30 * * * * ?\")\n .groups(g -> g\n .dateHistogram(d -> d\n .delay(de -> de\n .time(\"7d\")\n )\n .field(\"timestamp\")\n .fixedInterval(f -> f\n .time(\"1h\")\n )\n )\n .terms(t -> t\n .fields(\"node\")\n )\n )\n .id(\"sensor\")\n .indexPattern(\"sensor-*\")\n .metrics(List.of(FieldMetric.of(f -> f\n .field(\"temperature\")\n .metrics(List.of(Metric.Min,Metric.Max,Metric.Sum))),FieldMetric.of(f -> f\n .field(\"voltage\")\n .metrics(Metric.Avg))))\n .pageSize(1000)\n .rollupIndex(\"sensor_rollup\")\n);\n" + } + ], + "specification/rollup/delete_job/examples/request/DeleteRollupJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.delete_job(\n id=\"sensor\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.deleteJob({\n id: \"sensor\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.delete_job(\n id: \"sensor\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->deleteJob([\n \"id\" => \"sensor\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" + }, + { + "language": "Java", + "code": "client.rollup().deleteJob(d -> d\n .id(\"sensor\")\n);\n" + } + ], + "specification/rollup/start_job/examples/request/StartRollupJobRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.rollup.start_job(\n id=\"sensor\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.rollup.startJob({\n id: \"sensor\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.rollup.start_job(\n id: \"sensor\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->rollup()->startJob([\n \"id\" => \"sensor\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor/_start\"" + }, + { + "language": "Java", + "code": "client.rollup().startJob(s -> s\n .id(\"sensor\")\n);\n" + } + ], + "specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_service_type(\n connector_id=\"my-connector\",\n service_type=\"sharepoint_online\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateServiceType({\n connector_id: \"my-connector\",\n service_type: \"sharepoint_online\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_service_type(\n connector_id: \"my-connector\",\n body: {\n \"service_type\": \"sharepoint_online\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateServiceType([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"service_type\" => \"sharepoint_online\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service_type\":\"sharepoint_online\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_service_type\"" + }, + { + "language": "Java", + "code": "client.connector().updateServiceType(u -> u\n .connectorId(\"my-connector\")\n .serviceType(\"sharepoint_online\")\n);\n" + } + ], + "specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_scheduling(\n connector_id=\"my-connector\",\n scheduling={\n \"full\": {\n \"enabled\": True,\n \"interval\": \"0 10 0 * * ?\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateScheduling({\n connector_id: \"my-connector\",\n scheduling: {\n full: {\n enabled: true,\n interval: \"0 10 0 * * ?\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_scheduling(\n connector_id: \"my-connector\",\n body: {\n \"scheduling\": {\n \"full\": {\n \"enabled\": true,\n \"interval\": \"0 10 0 * * ?\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateScheduling([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"scheduling\" => [\n \"full\" => [\n \"enabled\" => true,\n \"interval\" => \"0 10 0 * * ?\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scheduling\":{\"full\":{\"enabled\":true,\"interval\":\"0 10 0 * * ?\"}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_scheduling\"" + }, + { + "language": "Java", + "code": "client.connector().updateScheduling(u -> u\n .connectorId(\"my-connector\")\n .scheduling(s -> s\n .full(f -> f\n .enabled(true)\n .interval(\"0 10 0 * * ?\")\n )\n )\n);\n" + } + ], + "specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_scheduling(\n connector_id=\"my-connector\",\n scheduling={\n \"access_control\": {\n \"enabled\": True,\n \"interval\": \"0 10 0 * * ?\"\n },\n \"full\": {\n \"enabled\": True,\n \"interval\": \"0 20 0 * * ?\"\n },\n \"incremental\": {\n \"enabled\": False,\n \"interval\": \"0 30 0 * * ?\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateScheduling({\n connector_id: \"my-connector\",\n scheduling: {\n access_control: {\n enabled: true,\n interval: \"0 10 0 * * ?\",\n },\n full: {\n enabled: true,\n interval: \"0 20 0 * * ?\",\n },\n incremental: {\n enabled: false,\n interval: \"0 30 0 * * ?\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_scheduling(\n connector_id: \"my-connector\",\n body: {\n \"scheduling\": {\n \"access_control\": {\n \"enabled\": true,\n \"interval\": \"0 10 0 * * ?\"\n },\n \"full\": {\n \"enabled\": true,\n \"interval\": \"0 20 0 * * ?\"\n },\n \"incremental\": {\n \"enabled\": false,\n \"interval\": \"0 30 0 * * ?\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateScheduling([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"scheduling\" => [\n \"access_control\" => [\n \"enabled\" => true,\n \"interval\" => \"0 10 0 * * ?\",\n ],\n \"full\" => [\n \"enabled\" => true,\n \"interval\" => \"0 20 0 * * ?\",\n ],\n \"incremental\" => [\n \"enabled\" => false,\n \"interval\" => \"0 30 0 * * ?\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scheduling\":{\"access_control\":{\"enabled\":true,\"interval\":\"0 10 0 * * ?\"},\"full\":{\"enabled\":true,\"interval\":\"0 20 0 * * ?\"},\"incremental\":{\"enabled\":false,\"interval\":\"0 30 0 * * ?\"}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_scheduling\"" + }, + { + "language": "Java", + "code": "client.connector().updateScheduling(u -> u\n .connectorId(\"my-connector\")\n .scheduling(s -> s\n .accessControl(a -> a\n .enabled(true)\n .interval(\"0 10 0 * * ?\")\n )\n .full(f -> f\n .enabled(true)\n .interval(\"0 20 0 * * ?\")\n )\n .incremental(i -> i\n .enabled(false)\n .interval(\"0 30 0 * * ?\")\n )\n )\n);\n" + } + ], + "specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_pipeline(\n connector_id=\"my-connector\",\n pipeline={\n \"extract_binary_content\": True,\n \"name\": \"my-connector-pipeline\",\n \"reduce_whitespace\": True,\n \"run_ml_inference\": True\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updatePipeline({\n connector_id: \"my-connector\",\n pipeline: {\n extract_binary_content: true,\n name: \"my-connector-pipeline\",\n reduce_whitespace: true,\n run_ml_inference: true,\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_pipeline(\n connector_id: \"my-connector\",\n body: {\n \"pipeline\": {\n \"extract_binary_content\": true,\n \"name\": \"my-connector-pipeline\",\n \"reduce_whitespace\": true,\n \"run_ml_inference\": true\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updatePipeline([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"pipeline\" => [\n \"extract_binary_content\" => true,\n \"name\" => \"my-connector-pipeline\",\n \"reduce_whitespace\" => true,\n \"run_ml_inference\" => true,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"pipeline\":{\"extract_binary_content\":true,\"name\":\"my-connector-pipeline\",\"reduce_whitespace\":true,\"run_ml_inference\":true}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_pipeline\"" + }, + { + "language": "Java", + "code": "client.connector().updatePipeline(u -> u\n .connectorId(\"my-connector\")\n .pipeline(p -> p\n .extractBinaryContent(true)\n .name(\"my-connector-pipeline\")\n .reduceWhitespace(true)\n .runMlInference(true)\n )\n);\n" + } + ], + "specification/connector/sync_job_get/examples/request/ConnectorSyncJobGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_get(\n connector_sync_job_id=\"my-connector-sync-job\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobGet({\n connector_sync_job_id: \"my-connector-sync-job\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_get(\n connector_sync_job_id: \"my-connector-sync-job\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobGet([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobGet(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n);\n" + } + ], + "specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_update_stats(\n connector_sync_job_id=\"my-connector-sync-job\",\n deleted_document_count=10,\n indexed_document_count=20,\n indexed_document_volume=1000,\n total_document_count=2000,\n last_seen=\"2023-01-02T10:00:00Z\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobUpdateStats({\n connector_sync_job_id: \"my-connector-sync-job\",\n deleted_document_count: 10,\n indexed_document_count: 20,\n indexed_document_volume: 1000,\n total_document_count: 2000,\n last_seen: \"2023-01-02T10:00:00Z\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_update_stats(\n connector_sync_job_id: \"my-connector-sync-job\",\n body: {\n \"deleted_document_count\": 10,\n \"indexed_document_count\": 20,\n \"indexed_document_volume\": 1000,\n \"total_document_count\": 2000,\n \"last_seen\": \"2023-01-02T10:00:00Z\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobUpdateStats([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n \"body\" => [\n \"deleted_document_count\" => 10,\n \"indexed_document_count\" => 20,\n \"indexed_document_volume\" => 1000,\n \"total_document_count\" => 2000,\n \"last_seen\" => \"2023-01-02T10:00:00Z\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"deleted_document_count\":10,\"indexed_document_count\":20,\"indexed_document_volume\":1000,\"total_document_count\":2000,\"last_seen\":\"2023-01-02T10:00:00Z\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_stats\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobUpdateStats(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n .deletedDocumentCount(10L)\n .indexedDocumentCount(20L)\n .indexedDocumentVolume(1000L)\n .lastSeen(l -> l\n .time(\"2023-01-02T10:00:00Z\")\n )\n .totalDocumentCount(2000)\n);\n" + } + ], + "specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_post(\n id=\"connector-id\",\n job_type=\"full\",\n trigger_method=\"on_demand\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobPost({\n id: \"connector-id\",\n job_type: \"full\",\n trigger_method: \"on_demand\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_post(\n body: {\n \"id\": \"connector-id\",\n \"job_type\": \"full\",\n \"trigger_method\": \"on_demand\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobPost([\n \"body\" => [\n \"id\" => \"connector-id\",\n \"job_type\" => \"full\",\n \"trigger_method\" => \"on_demand\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"connector-id\",\"job_type\":\"full\",\"trigger_method\":\"on_demand\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobPost(s -> s\n .id(\"connector-id\")\n .jobType(SyncJobType.Full)\n .triggerMethod(SyncJobTriggerMethod.OnDemand)\n);\n" + } + ], + "specification/connector/delete/examples/request/ConnectorDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.delete(\n connector_id=\"my-connector-id&delete_sync_jobs=true\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.delete({\n connector_id: \"my-connector-id&delete_sync_jobs=true\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.delete(\n connector_id: \"my-connector-id&delete_sync_jobs=true\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->delete([\n \"connector_id\" => \"my-connector-id&delete_sync_jobs=true\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector-id&delete_sync_jobs=true\"" + }, + { + "language": "Java", + "code": "client.connector().delete(d -> d\n .connectorId(\"my-connector-id&delete_sync_jobs=true\")\n);\n" + } + ], + "specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.put(\n connector_id=\"my-connector\",\n index_name=\"search-google-drive\",\n name=\"My Connector\",\n description=\"My Connector to sync data to Elastic index from Google Drive\",\n service_type=\"google_drive\",\n language=\"english\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.put({\n connector_id: \"my-connector\",\n index_name: \"search-google-drive\",\n name: \"My Connector\",\n description: \"My Connector to sync data to Elastic index from Google Drive\",\n service_type: \"google_drive\",\n language: \"english\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.put(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"search-google-drive\",\n \"name\": \"My Connector\",\n \"description\": \"My Connector to sync data to Elastic index from Google Drive\",\n \"service_type\": \"google_drive\",\n \"language\": \"english\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->put([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"search-google-drive\",\n \"name\" => \"My Connector\",\n \"description\" => \"My Connector to sync data to Elastic index from Google Drive\",\n \"service_type\" => \"google_drive\",\n \"language\" => \"english\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"search-google-drive\",\"name\":\"My Connector\",\"description\":\"My Connector to sync data to Elastic index from Google Drive\",\"service_type\":\"google_drive\",\"language\":\"english\"}' \"$ELASTICSEARCH_URL/_connector/my-connector\"" + }, + { + "language": "Java", + "code": "client.connector().put(p -> p\n .connectorId(\"my-connector\")\n .description(\"My Connector to sync data to Elastic index from Google Drive\")\n .indexName(\"search-google-drive\")\n .language(\"english\")\n .name(\"My Connector\")\n .serviceType(\"google_drive\")\n);\n" + } + ], + "specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.put(\n connector_id=\"my-connector\",\n index_name=\"search-google-drive\",\n name=\"My Connector\",\n service_type=\"google_drive\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.put({\n connector_id: \"my-connector\",\n index_name: \"search-google-drive\",\n name: \"My Connector\",\n service_type: \"google_drive\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.put(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"search-google-drive\",\n \"name\": \"My Connector\",\n \"service_type\": \"google_drive\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->put([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"search-google-drive\",\n \"name\" => \"My Connector\",\n \"service_type\" => \"google_drive\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"search-google-drive\",\"name\":\"My Connector\",\"service_type\":\"google_drive\"}' \"$ELASTICSEARCH_URL/_connector/my-connector\"" + }, + { + "language": "Java", + "code": "client.connector().put(p -> p\n .connectorId(\"my-connector\")\n .indexName(\"search-google-drive\")\n .name(\"My Connector\")\n .serviceType(\"google_drive\")\n);\n" + } + ], + "specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_features(\n connector_id=\"my-connector\",\n features={\n \"document_level_security\": {\n \"enabled\": True\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateFeatures({\n connector_id: \"my-connector\",\n features: {\n document_level_security: {\n enabled: true,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_features(\n connector_id: \"my-connector\",\n body: {\n \"features\": {\n \"document_level_security\": {\n \"enabled\": true\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateFeatures([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"features\" => [\n \"document_level_security\" => [\n \"enabled\" => true,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"features\":{\"document_level_security\":{\"enabled\":true}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_features\"" + }, + { + "language": "Java", + "code": "client.connector().updateFeatures(u -> u\n .connectorId(\"my-connector\")\n .features(f -> f\n .documentLevelSecurity(d -> d\n .enabled(true)\n )\n )\n);\n" + } + ], + "specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_features(\n connector_id=\"my-connector\",\n features={\n \"document_level_security\": {\n \"enabled\": True\n },\n \"incremental_sync\": {\n \"enabled\": True\n },\n \"sync_rules\": {\n \"advanced\": {\n \"enabled\": False\n },\n \"basic\": {\n \"enabled\": True\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateFeatures({\n connector_id: \"my-connector\",\n features: {\n document_level_security: {\n enabled: true,\n },\n incremental_sync: {\n enabled: true,\n },\n sync_rules: {\n advanced: {\n enabled: false,\n },\n basic: {\n enabled: true,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_features(\n connector_id: \"my-connector\",\n body: {\n \"features\": {\n \"document_level_security\": {\n \"enabled\": true\n },\n \"incremental_sync\": {\n \"enabled\": true\n },\n \"sync_rules\": {\n \"advanced\": {\n \"enabled\": false\n },\n \"basic\": {\n \"enabled\": true\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateFeatures([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"features\" => [\n \"document_level_security\" => [\n \"enabled\" => true,\n ],\n \"incremental_sync\" => [\n \"enabled\" => true,\n ],\n \"sync_rules\" => [\n \"advanced\" => [\n \"enabled\" => false,\n ],\n \"basic\" => [\n \"enabled\" => true,\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"features\":{\"document_level_security\":{\"enabled\":true},\"incremental_sync\":{\"enabled\":true},\"sync_rules\":{\"advanced\":{\"enabled\":false},\"basic\":{\"enabled\":true}}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_features\"" + }, + { + "language": "Java", + "code": "client.connector().updateFeatures(u -> u\n .connectorId(\"my-connector\")\n .features(f -> f\n .documentLevelSecurity(d -> d\n .enabled(true)\n )\n .incrementalSync(i -> i\n .enabled(true)\n )\n .syncRules(s -> s\n .advanced(a -> a\n .enabled(false)\n )\n .basic(b -> b\n .enabled(true)\n )\n )\n )\n);\n" + } + ], + "specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_configuration(\n connector_id=\"my-spo-connector\",\n values={\n \"tenant_id\": \"my-tenant-id\",\n \"tenant_name\": \"my-sharepoint-site\",\n \"client_id\": \"foo\",\n \"secret_value\": \"bar\",\n \"site_collections\": \"*\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateConfiguration({\n connector_id: \"my-spo-connector\",\n values: {\n tenant_id: \"my-tenant-id\",\n tenant_name: \"my-sharepoint-site\",\n client_id: \"foo\",\n secret_value: \"bar\",\n site_collections: \"*\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_configuration(\n connector_id: \"my-spo-connector\",\n body: {\n \"values\": {\n \"tenant_id\": \"my-tenant-id\",\n \"tenant_name\": \"my-sharepoint-site\",\n \"client_id\": \"foo\",\n \"secret_value\": \"bar\",\n \"site_collections\": \"*\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateConfiguration([\n \"connector_id\" => \"my-spo-connector\",\n \"body\" => [\n \"values\" => [\n \"tenant_id\" => \"my-tenant-id\",\n \"tenant_name\" => \"my-sharepoint-site\",\n \"client_id\" => \"foo\",\n \"secret_value\" => \"bar\",\n \"site_collections\" => \"*\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"values\":{\"tenant_id\":\"my-tenant-id\",\"tenant_name\":\"my-sharepoint-site\",\"client_id\":\"foo\",\"secret_value\":\"bar\",\"site_collections\":\"*\"}}' \"$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration\"" + }, + { + "language": "Java", + "code": "client.connector().updateConfiguration(u -> u\n .connectorId(\"my-spo-connector\")\n .values(Map.of(\"tenant_id\", JsonData.fromJson(\"\\\"my-tenant-id\\\"\"),\"tenant_name\", JsonData.fromJson(\"\\\"my-sharepoint-site\\\"\"),\"secret_value\", JsonData.fromJson(\"\\\"bar\\\"\"),\"client_id\", JsonData.fromJson(\"\\\"foo\\\"\"),\"site_collections\", JsonData.fromJson(\"\\\"*\\\"\")))\n);\n" + } + ], + "specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_configuration(\n connector_id=\"my-spo-connector\",\n values={\n \"secret_value\": \"foo-bar\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateConfiguration({\n connector_id: \"my-spo-connector\",\n values: {\n secret_value: \"foo-bar\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_configuration(\n connector_id: \"my-spo-connector\",\n body: {\n \"values\": {\n \"secret_value\": \"foo-bar\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateConfiguration([\n \"connector_id\" => \"my-spo-connector\",\n \"body\" => [\n \"values\" => [\n \"secret_value\" => \"foo-bar\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"values\":{\"secret_value\":\"foo-bar\"}}' \"$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration\"" + }, + { + "language": "Java", + "code": "client.connector().updateConfiguration(u -> u\n .connectorId(\"my-spo-connector\")\n .values(\"secret_value\", JsonData.fromJson(\"\\\"foo-bar\\\"\"))\n);\n" + } + ], + "specification/connector/sync_job_check_in/examples/request/ConnectorSyncJobCheckInExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_check_in(\n connector_sync_job_id=\"my-connector-sync-job\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobCheckIn({\n connector_sync_job_id: \"my-connector-sync-job\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_check_in(\n connector_sync_job_id: \"my-connector-sync-job\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobCheckIn([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_check_in\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobCheckIn(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n);\n" + } + ], + "specification/connector/get/examples/request/ConnectorGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.get(\n connector_id=\"my-connector-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.get({\n connector_id: \"my-connector-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.get(\n connector_id: \"my-connector-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->get([\n \"connector_id\" => \"my-connector-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector-id\"" + }, + { + "language": "Java", + "code": "client.connector().get(g -> g\n .connectorId(\"my-connector-id\")\n);\n" + } + ], + "specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_error(\n connector_sync_job_id=\"my-connector-sync-job\",\n error=\"some-error\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobError({\n connector_sync_job_id: \"my-connector-sync-job\",\n error: \"some-error\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_error(\n connector_sync_job_id: \"my-connector-sync-job\",\n body: {\n \"error\": \"some-error\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobError([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n \"body\" => [\n \"error\" => \"some-error\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"error\":\"some-error\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_error\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobError(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n .error(\"some-error\")\n);\n" + } + ], + "specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_claim(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n worker_hostname=\"some-machine\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobClaim({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n worker_hostname: \"some-machine\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_claim(\n connector_sync_job_id: \"my-connector-sync-job-id\",\n body: {\n \"worker_hostname\": \"some-machine\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobClaim([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n \"body\" => [\n \"worker_hostname\" => \"some-machine\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"worker_hostname\":\"some-machine\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id/_claim\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobClaim(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n .workerHostname(\"some-machine\")\n);\n" + } + ], + "specification/connector/list/examples/request/ConnectorListExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.list()" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.list();" + }, + { + "language": "Ruby", + "code": "response = client.connector.list" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->list();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector\"" + }, + { + "language": "Java", + "code": "client.connector().list(l -> l);\n" + } + ], + "specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_error(\n connector_id=\"my-connector\",\n error=\"Houston, we have a problem!\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateError({\n connector_id: \"my-connector\",\n error: \"Houston, we have a problem!\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_error(\n connector_id: \"my-connector\",\n body: {\n \"error\": \"Houston, we have a problem!\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateError([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"error\" => \"Houston, we have a problem!\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"error\":\"Houston, we have a problem!\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_error\"" + }, + { + "language": "Java", + "code": "client.connector().updateError(u -> u\n .connectorId(\"my-connector\")\n .error(\"Houston, we have a problem!\")\n);\n" + } + ], + "specification/connector/sync_job_list/examples/request/ConnectorSyncJobListExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_list(\n connector_id=\"my-connector-id\",\n size=\"1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobList({\n connector_id: \"my-connector-id\",\n size: 1,\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_list(\n connector_id: \"my-connector-id\",\n size: \"1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobList([\n \"connector_id\" => \"my-connector-id\",\n \"size\" => \"1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job?connector_id=my-connector-id&size=1\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobList(s -> s\n .connectorId(\"my-connector-id\")\n .size(1)\n);\n" + } + ], + "specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_index_name(\n connector_id=\"my-connector\",\n index_name=\"data-from-my-google-drive\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateIndexName({\n connector_id: \"my-connector\",\n index_name: \"data-from-my-google-drive\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_index_name(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"data-from-my-google-drive\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateIndexName([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"data-from-my-google-drive\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"data-from-my-google-drive\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_index_name\"" + }, + { + "language": "Java", + "code": "client.connector().updateIndexName(u -> u\n .connectorId(\"my-connector\")\n .indexName(\"data-from-my-google-drive\")\n);\n" + } + ], + "specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_api_key_id(\n connector_id=\"my-connector\",\n api_key_id=\"my-api-key-id\",\n api_key_secret_id=\"my-connector-secret-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateApiKeyId({\n connector_id: \"my-connector\",\n api_key_id: \"my-api-key-id\",\n api_key_secret_id: \"my-connector-secret-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_api_key_id(\n connector_id: \"my-connector\",\n body: {\n \"api_key_id\": \"my-api-key-id\",\n \"api_key_secret_id\": \"my-connector-secret-id\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateApiKeyId([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"api_key_id\" => \"my-api-key-id\",\n \"api_key_secret_id\" => \"my-connector-secret-id\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"api_key_id\":\"my-api-key-id\",\"api_key_secret_id\":\"my-connector-secret-id\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_api_key_id\"" + }, + { + "language": "Java", + "code": "client.connector().updateApiKeyId(u -> u\n .apiKeyId(\"my-api-key-id\")\n .apiKeySecretId(\"my-connector-secret-id\")\n .connectorId(\"my-connector\")\n);\n" + } + ], + "specification/connector/check_in/examples/request/ConnectorCheckInExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.check_in(\n connector_id=\"my-connector\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.checkIn({\n connector_id: \"my-connector\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.check_in(\n connector_id: \"my-connector\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->checkIn([\n \"connector_id\" => \"my-connector\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector/_check_in\"" + }, + { + "language": "Java", + "code": "client.connector().checkIn(c -> c\n .connectorId(\"my-connector\")\n);\n" + } + ], + "specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_status(\n connector_id=\"my-connector\",\n status=\"needs_configuration\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateStatus({\n connector_id: \"my-connector\",\n status: \"needs_configuration\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_status(\n connector_id: \"my-connector\",\n body: {\n \"status\": \"needs_configuration\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateStatus([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"status\" => \"needs_configuration\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"status\":\"needs_configuration\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_status\"" + }, + { + "language": "Java", + "code": "client.connector().updateStatus(u -> u\n .connectorId(\"my-connector\")\n .status(ConnectorStatus.NeedsConfiguration)\n);\n" + } + ], + "specification/connector/sync_job_cancel/examples/request/ConnectorSyncJobCancelExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_cancel(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobCancel({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_cancel(\n connector_sync_job_id: \"my-connector-sync-job-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobCancel([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id/_cancel\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobCancel(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n);\n" + } + ], + "specification/connector/sync_job_delete/examples/request/ConnectorSyncJobDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.sync_job_delete(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.syncJobDelete({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.sync_job_delete(\n connector_sync_job_id: \"my-connector-sync-job-id\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->syncJobDelete([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id\"" + }, + { + "language": "Java", + "code": "client.connector().syncJobDelete(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n);\n" + } + ], + "specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_name(\n connector_id=\"my-connector\",\n name=\"Custom connector\",\n description=\"This is my customized connector\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateName({\n connector_id: \"my-connector\",\n name: \"Custom connector\",\n description: \"This is my customized connector\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_name(\n connector_id: \"my-connector\",\n body: {\n \"name\": \"Custom connector\",\n \"description\": \"This is my customized connector\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateName([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"name\" => \"Custom connector\",\n \"description\" => \"This is my customized connector\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"Custom connector\",\"description\":\"This is my customized connector\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_name\"" + }, + { + "language": "Java", + "code": "client.connector().updateName(u -> u\n .connectorId(\"my-connector\")\n .description(\"This is my customized connector\")\n .name(\"Custom connector\")\n);\n" + } + ], + "specification/connector/last_sync/examples/request/ConnectorUpdateLastSyncRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.perform_request(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"last_access_control_sync_error\": \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\": \"pending\",\n \"last_deleted_document_count\": 42,\n \"last_incremental_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\": 42,\n \"last_sync_error\": \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\": \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\": \"completed\",\n \"last_synced\": \"2024-11-09T15:13:08.231Z\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transport.request({\n method: \"PUT\",\n path: \"/_connector/my-connector/_last_sync\",\n body: {\n last_access_control_sync_error: \"Houston, we have a problem!\",\n last_access_control_sync_scheduled_at: \"2023-11-09T15:13:08.231Z\",\n last_access_control_sync_status: \"pending\",\n last_deleted_document_count: 42,\n last_incremental_sync_scheduled_at: \"2023-11-09T15:13:08.231Z\",\n last_indexed_document_count: 42,\n last_sync_error: \"Houston, we have a problem!\",\n last_sync_scheduled_at: \"2024-11-09T15:13:08.231Z\",\n last_sync_status: \"completed\",\n last_synced: \"2024-11-09T15:13:08.231Z\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.perform_request(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n {},\n {\n \"last_access_control_sync_error\": \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\": \"pending\",\n \"last_deleted_document_count\": 42,\n \"last_incremental_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\": 42,\n \"last_sync_error\": \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\": \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\": \"completed\",\n \"last_synced\": \"2024-11-09T15:13:08.231Z\"\n },\n { \"Content-Type\": \"application/json\" },\n)" + }, + { + "language": "PHP", + "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"last_access_control_sync_error\" => \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\" => \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\" => \"pending\",\n \"last_deleted_document_count\" => 42,\n \"last_incremental_sync_scheduled_at\" => \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\" => 42,\n \"last_sync_error\" => \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\" => \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\" => \"completed\",\n \"last_synced\" => \"2024-11-09T15:13:08.231Z\",\n ]),\n));\n$resp = $client->sendRequest($request);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"last_access_control_sync_error\":\"Houston, we have a problem!\",\"last_access_control_sync_scheduled_at\":\"2023-11-09T15:13:08.231Z\",\"last_access_control_sync_status\":\"pending\",\"last_deleted_document_count\":42,\"last_incremental_sync_scheduled_at\":\"2023-11-09T15:13:08.231Z\",\"last_indexed_document_count\":42,\"last_sync_error\":\"Houston, we have a problem!\",\"last_sync_scheduled_at\":\"2024-11-09T15:13:08.231Z\",\"last_sync_status\":\"completed\",\"last_synced\":\"2024-11-09T15:13:08.231Z\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_last_sync\"" + } + ], + "specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_filtering(\n connector_id=\"my-sql-connector\",\n advanced_snippet={\n \"value\": [\n {\n \"tables\": [\n \"users\",\n \"orders\"\n ],\n \"query\": \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateFiltering({\n connector_id: \"my-sql-connector\",\n advanced_snippet: {\n value: [\n {\n tables: [\"users\", \"orders\"],\n query:\n \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\",\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_filtering(\n connector_id: \"my-sql-connector\",\n body: {\n \"advanced_snippet\": {\n \"value\": [\n {\n \"tables\": [\n \"users\",\n \"orders\"\n ],\n \"query\": \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateFiltering([\n \"connector_id\" => \"my-sql-connector\",\n \"body\" => [\n \"advanced_snippet\" => [\n \"value\" => array(\n [\n \"tables\" => array(\n \"users\",\n \"orders\",\n ),\n \"query\" => \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\",\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"advanced_snippet\":{\"value\":[{\"tables\":[\"users\",\"orders\"],\"query\":\"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"}]}}' \"$ELASTICSEARCH_URL/_connector/my-sql-connector/_filtering\"" + }, + { + "language": "Java", + "code": "client.connector().updateFiltering(u -> u\n .advancedSnippet(a -> a\n .value(JsonData.fromJson(\"[{\\\"tables\\\":[\\\"users\\\",\\\"orders\\\"],\\\"query\\\":\\\"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\\\"}]\"))\n )\n .connectorId(\"my-sql-connector\")\n);\n" + } + ], + "specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.connector.update_filtering(\n connector_id=\"my-g-drive-connector\",\n rules=[\n {\n \"field\": \"file_extension\",\n \"id\": \"exclude-txt-files\",\n \"order\": 0,\n \"policy\": \"exclude\",\n \"rule\": \"equals\",\n \"value\": \"txt\"\n },\n {\n \"field\": \"_\",\n \"id\": \"DEFAULT\",\n \"order\": 1,\n \"policy\": \"include\",\n \"rule\": \"regex\",\n \"value\": \".*\"\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.connector.updateFiltering({\n connector_id: \"my-g-drive-connector\",\n rules: [\n {\n field: \"file_extension\",\n id: \"exclude-txt-files\",\n order: 0,\n policy: \"exclude\",\n rule: \"equals\",\n value: \"txt\",\n },\n {\n field: \"_\",\n id: \"DEFAULT\",\n order: 1,\n policy: \"include\",\n rule: \"regex\",\n value: \".*\",\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.connector.update_filtering(\n connector_id: \"my-g-drive-connector\",\n body: {\n \"rules\": [\n {\n \"field\": \"file_extension\",\n \"id\": \"exclude-txt-files\",\n \"order\": 0,\n \"policy\": \"exclude\",\n \"rule\": \"equals\",\n \"value\": \"txt\"\n },\n {\n \"field\": \"_\",\n \"id\": \"DEFAULT\",\n \"order\": 1,\n \"policy\": \"include\",\n \"rule\": \"regex\",\n \"value\": \".*\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->connector()->updateFiltering([\n \"connector_id\" => \"my-g-drive-connector\",\n \"body\" => [\n \"rules\" => array(\n [\n \"field\" => \"file_extension\",\n \"id\" => \"exclude-txt-files\",\n \"order\" => 0,\n \"policy\" => \"exclude\",\n \"rule\" => \"equals\",\n \"value\" => \"txt\",\n ],\n [\n \"field\" => \"_\",\n \"id\" => \"DEFAULT\",\n \"order\" => 1,\n \"policy\" => \"include\",\n \"rule\" => \"regex\",\n \"value\" => \".*\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"field\":\"file_extension\",\"id\":\"exclude-txt-files\",\"order\":0,\"policy\":\"exclude\",\"rule\":\"equals\",\"value\":\"txt\"},{\"field\":\"_\",\"id\":\"DEFAULT\",\"order\":1,\"policy\":\"include\",\"rule\":\"regex\",\"value\":\".*\"}]}' \"$ELASTICSEARCH_URL/_connector/my-g-drive-connector/_filtering\"" + }, + { + "language": "Java", + "code": "client.connector().updateFiltering(u -> u\n .connectorId(\"my-g-drive-connector\")\n .rules(List.of(FilteringRule.of(f -> f\n .field(\"file_extension\")\n .id(\"exclude-txt-files\")\n .order(0)\n .policy(FilteringPolicy.Exclude)\n .rule(FilteringRuleRule.Equals)\n .value(\"txt\")),FilteringRule.of(f -> f\n .field(\"_\")\n .id(\"DEFAULT\")\n .order(1)\n .policy(FilteringPolicy.Include)\n .rule(FilteringRuleRule.Regex)\n .value(\".*\"))))\n);\n" + } + ], + "specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"mistral-embeddings-test\",\n inference_config={\n \"service\": \"mistral\",\n \"service_settings\": {\n \"api_key\": \"Mistral-API-Key\",\n \"model\": \"mistral-embed\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"mistral-embeddings-test\",\n inference_config: {\n service: \"mistral\",\n service_settings: {\n api_key: \"Mistral-API-Key\",\n model: \"mistral-embed\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"mistral-embeddings-test\",\n body: {\n \"service\": \"mistral\",\n \"service_settings\": {\n \"api_key\": \"Mistral-API-Key\",\n \"model\": \"mistral-embed\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"mistral-embeddings-test\",\n \"body\" => [\n \"service\" => \"mistral\",\n \"service_settings\" => [\n \"api_key\" => \"Mistral-API-Key\",\n \"model\" => \"mistral-embed\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"mistral\",\"service_settings\":{\"api_key\":\"Mistral-API-Key\",\"model\":\"mistral-embed\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/mistral-embeddings-test\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"mistral-embeddings-test\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"mistral\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Mistral-API-Key\\\",\\\"model\\\":\\\"mistral-embed\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is Elastic?\"\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n model: \"gpt-4o\",\n messages: [\n {\n role: \"user\",\n content: \"What is Elastic?\",\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is Elastic?\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"model\" => \"gpt-4o\",\n \"messages\" => array(\n [\n \"role\" => \"user\",\n \"content\" => \"What is Elastic?\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"model\":\"gpt-4o\",\"messages\":[{\"role\":\"user\",\"content\":\"What is Elastic?\"}]}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" + }, + { + "language": "Java", + "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(m -> m\n .content(co -> co\n .string(\"What is Elastic?\")\n )\n .role(\"user\")\n )\n .model(\"gpt-4o\")\n )\n);\n" + } + ], + "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What's the price of a scarf?\"\n }\n ]\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\",\n \"description\": \"Get the current price of a item\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"id\": \"123\"\n }\n }\n }\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n messages: [\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: \"What's the price of a scarf?\",\n },\n ],\n },\n ],\n tools: [\n {\n type: \"function\",\n function: {\n name: \"get_current_price\",\n description: \"Get the current price of a item\",\n parameters: {\n type: \"object\",\n properties: {\n item: {\n id: \"123\",\n },\n },\n },\n },\n },\n ],\n tool_choice: {\n type: \"function\",\n function: {\n name: \"get_current_price\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What's the price of a scarf?\"\n }\n ]\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\",\n \"description\": \"Get the current price of a item\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"id\": \"123\"\n }\n }\n }\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"messages\" => array(\n [\n \"role\" => \"user\",\n \"content\" => array(\n [\n \"type\" => \"text\",\n \"text\" => \"What's the price of a scarf?\",\n ],\n ),\n ],\n ),\n \"tools\" => array(\n [\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_price\",\n \"description\" => \"Get the current price of a item\",\n \"parameters\" => [\n \"type\" => \"object\",\n \"properties\" => [\n \"item\" => [\n \"id\" => \"123\",\n ],\n ],\n ],\n ],\n ],\n ),\n \"tool_choice\" => [\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_price\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What'\"'\"'s the price of a scarf?\"}]}],\"tools\":[{\"type\":\"function\",\"function\":{\"name\":\"get_current_price\",\"description\":\"Get the current price of a item\",\"parameters\":{\"type\":\"object\",\"properties\":{\"item\":{\"id\":\"123\"}}}}}],\"tool_choice\":{\"type\":\"function\",\"function\":{\"name\":\"get_current_price\"}}}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" + }, + { + "language": "Java", + "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(m -> m\n .content(co -> co\n .string(\"What's the price of a scarf?\")\n )\n .role(\"user\")\n )\n .toolChoice(t -> t\n .object(o -> o\n .type(\"function\")\n .function(f -> f\n .name(\"get_current_price\")\n )\n )\n )\n .tools(to -> to\n .type(\"function\")\n .function(f -> f\n .description(\"Get the current price of a item\")\n .name(\"get_current_price\")\n .parameters(JsonData.fromJson(\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"item\\\":{\\\"id\\\":\\\"123\\\"}}}\"))\n )\n )\n )\n);\n" + } + ], + "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"messages\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Let's find out what the weather is\",\n \"tool_calls\": [\n {\n \"id\": \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\\"location\\\":\\\"Boston, MA\\\"}\"\n }\n }\n ]\n },\n {\n \"role\": \"tool\",\n \"content\": \"The weather is cold\",\n \"tool_call_id\": \"call_KcAjWtAww20AihPHphUh46Gd\"\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n messages: [\n {\n role: \"assistant\",\n content: \"Let's find out what the weather is\",\n tool_calls: [\n {\n id: \"call_KcAjWtAww20AihPHphUh46Gd\",\n type: \"function\",\n function: {\n name: \"get_current_weather\",\n arguments: '{\"location\":\"Boston, MA\"}',\n },\n },\n ],\n },\n {\n role: \"tool\",\n content: \"The weather is cold\",\n tool_call_id: \"call_KcAjWtAww20AihPHphUh46Gd\",\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"messages\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Let's find out what the weather is\",\n \"tool_calls\": [\n {\n \"id\": \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\\"location\\\":\\\"Boston, MA\\\"}\"\n }\n }\n ]\n },\n {\n \"role\": \"tool\",\n \"content\": \"The weather is cold\",\n \"tool_call_id\": \"call_KcAjWtAww20AihPHphUh46Gd\"\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"messages\" => array(\n [\n \"role\" => \"assistant\",\n \"content\" => \"Let's find out what the weather is\",\n \"tool_calls\" => array(\n [\n \"id\" => \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_weather\",\n \"arguments\" => \"{\\\"location\\\":\\\"Boston, MA\\\"}\",\n ],\n ],\n ),\n ],\n [\n \"role\" => \"tool\",\n \"content\" => \"The weather is cold\",\n \"tool_call_id\" => \"call_KcAjWtAww20AihPHphUh46Gd\",\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[{\"role\":\"assistant\",\"content\":\"Let'\"'\"'s find out what the weather is\",\"tool_calls\":[{\"id\":\"call_KcAjWtAww20AihPHphUh46Gd\",\"type\":\"function\",\"function\":{\"name\":\"get_current_weather\",\"arguments\":\"{\\\"location\\\":\\\"Boston, MA\\\"}\"}}]},{\"role\":\"tool\",\"content\":\"The weather is cold\",\"tool_call_id\":\"call_KcAjWtAww20AihPHphUh46Gd\"}]}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" + }, + { + "language": "Java", + "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(List.of(Message.of(m -> m\n .content(co -> co\n .string(\"Let's find out what the weather is\")\n )\n .role(\"assistant\")\n .toolCalls(t -> t\n .id(\"call_KcAjWtAww20AihPHphUh46Gd\")\n .function(f -> f\n .arguments(\"{\\\"location\\\":\\\"Boston, MA\\\"}\")\n .name(\"get_current_weather\")\n )\n .type(\"function\")\n )),Message.of(me -> me\n .content(co -> co\n .string(\"The weather is cold\")\n )\n .role(\"tool\")\n .toolCallId(\"call_KcAjWtAww20AihPHphUh46Gd\"))))\n )\n);\n" + } + ], + "specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.text_embedding(\n inference_id=\"my-cohere-endpoint\",\n input=\"The sky above the port was the color of television tuned to a dead channel.\",\n task_settings={\n \"input_type\": \"ingest\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.textEmbedding({\n inference_id: \"my-cohere-endpoint\",\n input:\n \"The sky above the port was the color of television tuned to a dead channel.\",\n task_settings: {\n input_type: \"ingest\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.text_embedding(\n inference_id: \"my-cohere-endpoint\",\n body: {\n \"input\": \"The sky above the port was the color of television tuned to a dead channel.\",\n \"task_settings\": {\n \"input_type\": \"ingest\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->textEmbedding([\n \"inference_id\" => \"my-cohere-endpoint\",\n \"body\" => [\n \"input\" => \"The sky above the port was the color of television tuned to a dead channel.\",\n \"task_settings\" => [\n \"input_type\" => \"ingest\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"The sky above the port was the color of television tuned to a dead channel.\",\"task_settings\":{\"input_type\":\"ingest\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-cohere-endpoint\"" + }, + { + "language": "Java", + "code": "client.inference().textEmbedding(t -> t\n .inferenceId(\"my-cohere-endpoint\")\n .input(\"The sky above the port was the color of television tuned to a dead channel.\")\n .taskSettings(JsonData.fromJson(\"{\\\"input_type\\\":\\\"ingest\\\"}\"))\n);\n" + } + ], + "specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"jinaai-embeddings\",\n inference_config={\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"model_id\": \"jina-embeddings-v3\",\n \"api_key\": \"JinaAi-Api-key\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"jinaai-embeddings\",\n inference_config: {\n service: \"jinaai\",\n service_settings: {\n model_id: \"jina-embeddings-v3\",\n api_key: \"JinaAi-Api-key\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"jinaai-embeddings\",\n body: {\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"model_id\": \"jina-embeddings-v3\",\n \"api_key\": \"JinaAi-Api-key\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"jinaai-embeddings\",\n \"body\" => [\n \"service\" => \"jinaai\",\n \"service_settings\" => [\n \"model_id\" => \"jina-embeddings-v3\",\n \"api_key\" => \"JinaAi-Api-key\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"jinaai\",\"service_settings\":{\"model_id\":\"jina-embeddings-v3\",\"api_key\":\"JinaAi-Api-key\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/jinaai-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"jinaai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"jinaai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"jina-embeddings-v3\\\",\\\"api_key\\\":\\\"JinaAi-Api-key\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"jinaai-rerank\",\n inference_config={\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"api_key\": \"JinaAI-Api-key\",\n \"model_id\": \"jina-reranker-v2-base-multilingual\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": True\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"jinaai-rerank\",\n inference_config: {\n service: \"jinaai\",\n service_settings: {\n api_key: \"JinaAI-Api-key\",\n model_id: \"jina-reranker-v2-base-multilingual\",\n },\n task_settings: {\n top_n: 10,\n return_documents: true,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"jinaai-rerank\",\n body: {\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"api_key\": \"JinaAI-Api-key\",\n \"model_id\": \"jina-reranker-v2-base-multilingual\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"jinaai-rerank\",\n \"body\" => [\n \"service\" => \"jinaai\",\n \"service_settings\" => [\n \"api_key\" => \"JinaAI-Api-key\",\n \"model_id\" => \"jina-reranker-v2-base-multilingual\",\n ],\n \"task_settings\" => [\n \"top_n\" => 10,\n \"return_documents\" => true,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"jinaai\",\"service_settings\":{\"api_key\":\"JinaAI-Api-key\",\"model_id\":\"jina-reranker-v2-base-multilingual\"},\"task_settings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/jinaai-rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"jinaai-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"jinaai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"JinaAI-Api-key\\\",\\\"model_id\\\":\\\"jina-reranker-v2-base-multilingual\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"top_n\\\":10,\\\"return_documents\\\":true}\"))\n )\n);\n" + } + ], + "specification/inference/update/examples/request/InferenceUpdateExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.update(\n inference_id=\"my-inference-endpoint\",\n inference_config={\n \"service_settings\": {\n \"api_key\": \"\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.update({\n inference_id: \"my-inference-endpoint\",\n inference_config: {\n service_settings: {\n api_key: \"\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.update(\n inference_id: \"my-inference-endpoint\",\n body: {\n \"service_settings\": {\n \"api_key\": \"\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->update([\n \"inference_id\" => \"my-inference-endpoint\",\n \"body\" => [\n \"service_settings\" => [\n \"api_key\" => \"\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service_settings\":{\"api_key\":\"\"}}' \"$ELASTICSEARCH_URL/_inference/my-inference-endpoint/_update\"" + } + ], + "specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elser\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elser\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elser\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elser\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elser\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elser\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1}\"))\n )\n);\n" + } + ], + "specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elser\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elser\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 3,\n max_number_of_allocations: 10,\n },\n num_threads: 1,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elser\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elser\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 3,\n \"max_number_of_allocations\" => 10,\n ],\n \"num_threads\" => 1,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elser\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elser\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":3,\\\"max_number_of_allocations\\\":10},\\\"num_threads\\\":1}\"))\n )\n);\n" + } + ], + "specification/inference/delete/examples/request/InferenceDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.delete(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.delete({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.delete(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->delete([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().delete(d -> d\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n);\n" + } + ], + "specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"cohere-embeddings\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"cohere-embeddings\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-Api-key\",\n model_id: \"embed-english-light-v3.0\",\n embedding_type: \"byte\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"cohere-embeddings\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"cohere-embeddings\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-Api-key\",\n \"model_id\" => \"embed-english-light-v3.0\",\n \"embedding_type\" => \"byte\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-Api-key\",\"model_id\":\"embed-english-light-v3.0\",\"embedding_type\":\"byte\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/cohere-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"cohere-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Cohere-Api-key\\\",\\\"model_id\\\":\\\"embed-english-light-v3.0\\\",\\\"embedding_type\\\":\\\"byte\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"cohere-rerank\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": True\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"cohere-rerank\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-API-key\",\n model_id: \"rerank-english-v3.0\",\n },\n task_settings: {\n top_n: 10,\n return_documents: true,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"cohere-rerank\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"cohere-rerank\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-API-key\",\n \"model_id\" => \"rerank-english-v3.0\",\n ],\n \"task_settings\" => [\n \"top_n\" => 10,\n \"return_documents\" => true,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-API-key\",\"model_id\":\"rerank-english-v3.0\"},\"task_settings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/cohere-rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"cohere-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Cohere-API-key\\\",\\\"model_id\\\":\\\"rerank-english-v3.0\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"top_n\\\":10,\\\"return_documents\\\":true}\"))\n )\n);\n" + } + ], + "specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"google_ai_studio_completion\",\n inference_config={\n \"service\": \"googleaistudio\",\n \"service_settings\": {\n \"api_key\": \"api-key\",\n \"model_id\": \"model-id\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"google_ai_studio_completion\",\n inference_config: {\n service: \"googleaistudio\",\n service_settings: {\n api_key: \"api-key\",\n model_id: \"model-id\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"google_ai_studio_completion\",\n body: {\n \"service\": \"googleaistudio\",\n \"service_settings\": {\n \"api_key\": \"api-key\",\n \"model_id\": \"model-id\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"google_ai_studio_completion\",\n \"body\" => [\n \"service\" => \"googleaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"api-key\",\n \"model_id\" => \"model-id\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googleaistudio\",\"service_settings\":{\"api_key\":\"api-key\",\"model_id\":\"model-id\"}}' \"$ELASTICSEARCH_URL/_inference/completion/google_ai_studio_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"google_ai_studio_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"googleaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"api-key\\\",\\\"model_id\\\":\\\"model-id\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put/examples/request/InferencePutExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"my-rerank-model\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"model_id\": \"rerank-english-v3.0\",\n \"api_key\": \"{{COHERE_API_KEY}}\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"my-rerank-model\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n model_id: \"rerank-english-v3.0\",\n api_key: \"{{COHERE_API_KEY}}\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"my-rerank-model\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"model_id\": \"rerank-english-v3.0\",\n \"api_key\": \"{{COHERE_API_KEY}}\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"my-rerank-model\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"model_id\" => \"rerank-english-v3.0\",\n \"api_key\" => \"{{COHERE_API_KEY}}\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"model_id\":\"rerank-english-v3.0\",\"api_key\":\"{{COHERE_API_KEY}}\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/my-rerank-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-rerank-model\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"rerank-english-v3.0\\\",\\\"api_key\\\":\\\"{{COHERE_API_KEY}}\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"voyageai-rerank\",\n inference_config={\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"rerank-2\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"voyageai-rerank\",\n inference_config: {\n service: \"voyageai\",\n service_settings: {\n model_id: \"rerank-2\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"voyageai-rerank\",\n body: {\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"rerank-2\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"voyageai-rerank\",\n \"body\" => [\n \"service\" => \"voyageai\",\n \"service_settings\" => [\n \"model_id\" => \"rerank-2\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"voyageai\",\"service_settings\":{\"model_id\":\"rerank-2\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/voyageai-rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"voyageai-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"voyageai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"rerank-2\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"openai-embeddings\",\n inference_config={\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"voyage-3-large\",\n \"dimensions\": 512\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n inference_config: {\n service: \"voyageai\",\n service_settings: {\n model_id: \"voyage-3-large\",\n dimensions: 512,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n body: {\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"voyage-3-large\",\n \"dimensions\": 512\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"openai-embeddings\",\n \"body\" => [\n \"service\" => \"voyageai\",\n \"service_settings\" => [\n \"model_id\" => \"voyage-3-large\",\n \"dimensions\" => 512,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"voyageai\",\"service_settings\":{\"model_id\":\"voyage-3-large\",\"dimensions\":512}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"openai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"voyageai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"voyage-3-large\\\",\\\"dimensions\\\":512}\"))\n )\n);\n" + } + ], + "specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"watsonx-embeddings\",\n inference_config={\n \"service\": \"watsonxai\",\n \"service_settings\": {\n \"api_key\": \"Watsonx-API-Key\",\n \"url\": \"Wastonx-URL\",\n \"model_id\": \"ibm/slate-30m-english-rtrvr\",\n \"project_id\": \"IBM-Cloud-ID\",\n \"api_version\": \"2024-03-14\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"watsonx-embeddings\",\n inference_config: {\n service: \"watsonxai\",\n service_settings: {\n api_key: \"Watsonx-API-Key\",\n url: \"Wastonx-URL\",\n model_id: \"ibm/slate-30m-english-rtrvr\",\n project_id: \"IBM-Cloud-ID\",\n api_version: \"2024-03-14\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"watsonx-embeddings\",\n body: {\n \"service\": \"watsonxai\",\n \"service_settings\": {\n \"api_key\": \"Watsonx-API-Key\",\n \"url\": \"Wastonx-URL\",\n \"model_id\": \"ibm/slate-30m-english-rtrvr\",\n \"project_id\": \"IBM-Cloud-ID\",\n \"api_version\": \"2024-03-14\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"watsonx-embeddings\",\n \"body\" => [\n \"service\" => \"watsonxai\",\n \"service_settings\" => [\n \"api_key\" => \"Watsonx-API-Key\",\n \"url\" => \"Wastonx-URL\",\n \"model_id\" => \"ibm/slate-30m-english-rtrvr\",\n \"project_id\" => \"IBM-Cloud-ID\",\n \"api_version\" => \"2024-03-14\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"watsonxai\",\"service_settings\":{\"api_key\":\"Watsonx-API-Key\",\"url\":\"Wastonx-URL\",\"model_id\":\"ibm/slate-30m-english-rtrvr\",\"project_id\":\"IBM-Cloud-ID\",\"api_version\":\"2024-03-14\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/watsonx-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"watsonx-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"watsonxai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Watsonx-API-Key\\\",\\\"url\\\":\\\"Wastonx-URL\\\",\\\"model_id\\\":\\\"ibm/slate-30m-english-rtrvr\\\",\\\"project_id\\\":\\\"IBM-Cloud-ID\\\",\\\"api_version\\\":\\\"2024-03-14\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/completion/examples/request/CompletionRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.completion(\n inference_id=\"openai_chat_completions\",\n input=\"What is Elastic?\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.completion({\n inference_id: \"openai_chat_completions\",\n input: \"What is Elastic?\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.completion(\n inference_id: \"openai_chat_completions\",\n body: {\n \"input\": \"What is Elastic?\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->completion([\n \"inference_id\" => \"openai_chat_completions\",\n \"body\" => [\n \"input\" => \"What is Elastic?\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"What is Elastic?\"}' \"$ELASTICSEARCH_URL/_inference/completion/openai_chat_completions\"" + }, + { + "language": "Java", + "code": "client.inference().completion(c -> c\n .inferenceId(\"openai_chat_completions\")\n .input(\"What is Elastic?\")\n);\n" + } + ], + "specification/inference/get/examples/request/InferenceGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.get(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.get({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.get(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->get([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().get(g -> g\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n);\n" + } + ], + "specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"anthropic_completion\",\n inference_config={\n \"service\": \"anthropic\",\n \"service_settings\": {\n \"api_key\": \"Anthropic-Api-Key\",\n \"model_id\": \"Model-ID\"\n },\n \"task_settings\": {\n \"max_tokens\": 1024\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"anthropic_completion\",\n inference_config: {\n service: \"anthropic\",\n service_settings: {\n api_key: \"Anthropic-Api-Key\",\n model_id: \"Model-ID\",\n },\n task_settings: {\n max_tokens: 1024,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"anthropic_completion\",\n body: {\n \"service\": \"anthropic\",\n \"service_settings\": {\n \"api_key\": \"Anthropic-Api-Key\",\n \"model_id\": \"Model-ID\"\n },\n \"task_settings\": {\n \"max_tokens\": 1024\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"anthropic_completion\",\n \"body\" => [\n \"service\" => \"anthropic\",\n \"service_settings\" => [\n \"api_key\" => \"Anthropic-Api-Key\",\n \"model_id\" => \"Model-ID\",\n ],\n \"task_settings\" => [\n \"max_tokens\" => 1024,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"anthropic\",\"service_settings\":{\"api_key\":\"Anthropic-Api-Key\",\"model_id\":\"Model-ID\"},\"task_settings\":{\"max_tokens\":1024}}' \"$ELASTICSEARCH_URL/_inference/completion/anthropic_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"anthropic_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"anthropic\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Anthropic-Api-Key\\\",\\\"model_id\\\":\\\"Model-ID\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"max_tokens\\\":1024}\"))\n )\n);\n" + } + ], + "specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.sparse_embedding(\n inference_id=\"my-elser-model\",\n input=\"The sky above the port was the color of television tuned to a dead channel.\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.sparseEmbedding({\n inference_id: \"my-elser-model\",\n input:\n \"The sky above the port was the color of television tuned to a dead channel.\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.sparse_embedding(\n inference_id: \"my-elser-model\",\n body: {\n \"input\": \"The sky above the port was the color of television tuned to a dead channel.\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->sparseEmbedding([\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"input\" => \"The sky above the port was the color of television tuned to a dead channel.\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"The sky above the port was the color of television tuned to a dead channel.\"}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().sparseEmbedding(s -> s\n .inferenceId(\"my-elser-model\")\n .input(\"The sky above the port was the color of television tuned to a dead channel.\")\n);\n" + } + ], + "specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"google_vertex_ai_rerank\",\n inference_config={\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"project_id\": \"project-id\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"google_vertex_ai_rerank\",\n inference_config: {\n service: \"googlevertexai\",\n service_settings: {\n service_account_json: \"service-account-json\",\n project_id: \"project-id\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"google_vertex_ai_rerank\",\n body: {\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"project_id\": \"project-id\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"google_vertex_ai_rerank\",\n \"body\" => [\n \"service\" => \"googlevertexai\",\n \"service_settings\" => [\n \"service_account_json\" => \"service-account-json\",\n \"project_id\" => \"project-id\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"project_id\":\"project-id\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/google_vertex_ai_rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"google_vertex_ai_rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"googlevertexai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"service_account_json\\\":\\\"service-account-json\\\",\\\"project_id\\\":\\\"project-id\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"google_vertex_ai_embeddingss\",\n inference_config={\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"model_id\": \"model-id\",\n \"location\": \"location\",\n \"project_id\": \"project-id\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"google_vertex_ai_embeddingss\",\n inference_config: {\n service: \"googlevertexai\",\n service_settings: {\n service_account_json: \"service-account-json\",\n model_id: \"model-id\",\n location: \"location\",\n project_id: \"project-id\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"google_vertex_ai_embeddingss\",\n body: {\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"model_id\": \"model-id\",\n \"location\": \"location\",\n \"project_id\": \"project-id\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"google_vertex_ai_embeddingss\",\n \"body\" => [\n \"service\" => \"googlevertexai\",\n \"service_settings\" => [\n \"service_account_json\" => \"service-account-json\",\n \"model_id\" => \"model-id\",\n \"location\" => \"location\",\n \"project_id\" => \"project-id\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"model_id\":\"model-id\",\"location\":\"location\",\"project_id\":\"project-id\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/google_vertex_ai_embeddingss\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"google_vertex_ai_embeddingss\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"googlevertexai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"service_account_json\\\":\\\"service-account-json\\\",\\\"model_id\\\":\\\"model-id\\\",\\\"location\\\":\\\"location\\\",\\\"project_id\\\":\\\"project-id\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"hugging-face-embeddings\",\n inference_config={\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"hugging-face-embeddings\",\n inference_config: {\n service: \"hugging_face\",\n service_settings: {\n api_key: \"hugging-face-access-token\",\n url: \"url-endpoint\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"hugging-face-embeddings\",\n body: {\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"hugging-face-embeddings\",\n \"body\" => [\n \"service\" => \"hugging_face\",\n \"service_settings\" => [\n \"api_key\" => \"hugging-face-access-token\",\n \"url\" => \"url-endpoint\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"hugging_face\",\"service_settings\":{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/hugging-face-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"hugging-face-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"hugging_face\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"hugging-face-access-token\\\",\\\"url\\\":\\\"url-endpoint\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"hugging-face-rerank\",\n inference_config={\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n },\n \"task_settings\": {\n \"return_documents\": True,\n \"top_n\": 3\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"hugging-face-rerank\",\n inference_config: {\n service: \"hugging_face\",\n service_settings: {\n api_key: \"hugging-face-access-token\",\n url: \"url-endpoint\",\n },\n task_settings: {\n return_documents: true,\n top_n: 3,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"hugging-face-rerank\",\n body: {\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n },\n \"task_settings\": {\n \"return_documents\": true,\n \"top_n\": 3\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"hugging-face-rerank\",\n \"body\" => [\n \"service\" => \"hugging_face\",\n \"service_settings\" => [\n \"api_key\" => \"hugging-face-access-token\",\n \"url\" => \"url-endpoint\",\n ],\n \"task_settings\" => [\n \"return_documents\" => true,\n \"top_n\" => 3,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"hugging_face\",\"service_settings\":{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"},\"task_settings\":{\"return_documents\":true,\"top_n\":3}}' \"$ELASTICSEARCH_URL/_inference/rerank/hugging-face-rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"hugging-face-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"hugging_face\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"hugging-face-access-token\\\",\\\"url\\\":\\\"url-endpoint\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"return_documents\\\":true,\\\"top_n\\\":3}\"))\n )\n);\n" + } + ], + "specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"amazon_bedrock_embeddings\",\n inference_config={\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-embed-text-v2:0\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"amazon_bedrock_embeddings\",\n inference_config: {\n service: \"amazonbedrock\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n provider: \"amazontitan\",\n model: \"amazon.titan-embed-text-v2:0\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"amazon_bedrock_embeddings\",\n body: {\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-embed-text-v2:0\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"amazon_bedrock_embeddings\",\n \"body\" => [\n \"service\" => \"amazonbedrock\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"provider\" => \"amazontitan\",\n \"model\" => \"amazon.titan-embed-text-v2:0\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-embed-text-v2:0\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/amazon_bedrock_embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"amazon_bedrock_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"amazonbedrock\")\n .serviceSettings(JsonData.fromJson(\"{\\\"access_key\\\":\\\"AWS-access-key\\\",\\\"secret_key\\\":\\\"AWS-secret-key\\\",\\\"region\\\":\\\"us-east-1\\\",\\\"provider\\\":\\\"amazontitan\\\",\\\"model\\\":\\\"amazon.titan-embed-text-v2:0\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"openai-completion\",\n inference_config={\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"gpt-3.5-turbo\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"openai-completion\",\n inference_config: {\n service: \"openai\",\n service_settings: {\n api_key: \"OpenAI-API-Key\",\n model_id: \"gpt-3.5-turbo\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"openai-completion\",\n body: {\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"gpt-3.5-turbo\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"service\" => \"openai\",\n \"service_settings\" => [\n \"api_key\" => \"OpenAI-API-Key\",\n \"model_id\" => \"gpt-3.5-turbo\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"openai\",\"service_settings\":{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"gpt-3.5-turbo\"}}' \"$ELASTICSEARCH_URL/_inference/completion/openai-completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"openai-completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"openai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"OpenAI-API-Key\\\",\\\"model_id\\\":\\\"gpt-3.5-turbo\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"amazon_bedrock_completion\",\n inference_config={\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-text-premier-v1:0\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"amazon_bedrock_completion\",\n inference_config: {\n service: \"amazonbedrock\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n provider: \"amazontitan\",\n model: \"amazon.titan-text-premier-v1:0\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"amazon_bedrock_completion\",\n body: {\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-text-premier-v1:0\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"amazon_bedrock_completion\",\n \"body\" => [\n \"service\" => \"amazonbedrock\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"provider\" => \"amazontitan\",\n \"model\" => \"amazon.titan-text-premier-v1:0\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-text-premier-v1:0\"}}' \"$ELASTICSEARCH_URL/_inference/completion/amazon_bedrock_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"amazon_bedrock_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"amazonbedrock\")\n .serviceSettings(JsonData.fromJson(\"{\\\"access_key\\\":\\\"AWS-access-key\\\",\\\"secret_key\\\":\\\"AWS-secret-key\\\",\\\"region\\\":\\\"us-east-1\\\",\\\"provider\\\":\\\"amazontitan\\\",\\\"model\\\":\\\"amazon.titan-text-premier-v1:0\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"openai-embeddings\",\n inference_config={\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"text-embedding-3-small\",\n \"dimensions\": 128\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n inference_config: {\n service: \"openai\",\n service_settings: {\n api_key: \"OpenAI-API-Key\",\n model_id: \"text-embedding-3-small\",\n dimensions: 128,\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n body: {\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"text-embedding-3-small\",\n \"dimensions\": 128\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"openai-embeddings\",\n \"body\" => [\n \"service\" => \"openai\",\n \"service_settings\" => [\n \"api_key\" => \"OpenAI-API-Key\",\n \"model_id\" => \"text-embedding-3-small\",\n \"dimensions\" => 128,\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"openai\",\"service_settings\":{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"text-embedding-3-small\",\"dimensions\":128}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"openai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"openai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"OpenAI-API-Key\\\",\\\"model_id\\\":\\\"text-embedding-3-small\\\",\\\"dimensions\\\":128}\"))\n )\n);\n" + } + ], + "specification/inference/rerank/examples/request/RerankRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.rerank(\n inference_id=\"cohere_rerank\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.rerank({\n inference_id: \"cohere_rerank\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.rerank(\n inference_id: \"cohere_rerank\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"cohere_rerank\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\"}' \"$ELASTICSEARCH_URL/_inference/rerank/cohere_rerank\"" + }, + { + "language": "Java", + "code": "client.inference().rerank(r -> r\n .inferenceId(\"cohere_rerank\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" + } + ], + "specification/inference/rerank/examples/request/RerankRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.rerank(\n inference_id=\"bge-reranker-base-mkn\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n return_documents=False,\n top_n=2,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.rerank({\n inference_id: \"bge-reranker-base-mkn\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n return_documents: false,\n top_n: 2,\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.rerank(\n inference_id: \"bge-reranker-base-mkn\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\",\n \"return_documents\": false,\n \"top_n\": 2\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"bge-reranker-base-mkn\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n \"return_documents\" => false,\n \"top_n\" => 2,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\",\"return_documents\":false,\"top_n\":2}' \"$ELASTICSEARCH_URL/_inference/rerank/bge-reranker-base-mkn\"" + }, + { + "language": "Java", + "code": "client.inference().rerank(r -> r\n .inferenceId(\"bge-reranker-base-mkn\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" + } + ], + "specification/inference/rerank/examples/request/RerankRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.rerank(\n inference_id=\"bge-reranker-base-mkn\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n return_documents=True,\n top_n=3,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.rerank({\n inference_id: \"bge-reranker-base-mkn\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n return_documents: true,\n top_n: 3,\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.rerank(\n inference_id: \"bge-reranker-base-mkn\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\",\n \"return_documents\": true,\n \"top_n\": 3\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"bge-reranker-base-mkn\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n \"return_documents\" => true,\n \"top_n\" => 3,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\",\"return_documents\":true,\"top_n\":3}' \"$ELASTICSEARCH_URL/_inference/rerank/bge-reranker-base-mkn\"" + }, + { + "language": "Java", + "code": "client.inference().rerank(r -> r\n .inferenceId(\"bge-reranker-base-mkn\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" + } + ], + "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"alibabacloud_ai_search_embeddings\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"alibabacloud_ai_search_embeddings\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-text-embedding-001\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"alibabacloud_ai_search_embeddings\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"alibabacloud_ai_search_embeddings\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-text-embedding-001\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/alibabacloud_ai_search_embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-text-embedding-001\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"alibabacloud_ai_search_sparse\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-sparse-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"alibabacloud_ai_search_sparse\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-text-sparse-embedding-001\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"alibabacloud_ai_search_sparse\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-sparse-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"alibabacloud_ai_search_sparse\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-text-sparse-embedding-001\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-sparse-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/alibabacloud_ai_search_sparse\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_sparse\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-text-sparse-embedding-001\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"alibabacloud_ai_search_rerank\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-bge-reranker-larger\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"alibabacloud_ai_search_rerank\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-bge-reranker-larger\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"alibabacloud_ai_search_rerank\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-bge-reranker-larger\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"alibabacloud_ai_search_rerank\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-bge-reranker-larger\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-bge-reranker-larger\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/alibabacloud_ai_search_rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-bge-reranker-larger\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"alibabacloud_ai_search_completion\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-qwen-turbo\",\n \"workspace\": \"default\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"alibabacloud_ai_search_completion\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-qwen-turbo\",\n workspace: \"default\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"alibabacloud_ai_search_completion\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-qwen-turbo\",\n \"workspace\": \"default\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"alibabacloud_ai_search_completion\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-qwen-turbo\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-qwen-turbo\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/completion/alibabacloud_ai_search_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-qwen-turbo\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"azure_openai_embeddings\",\n inference_config={\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"azure_openai_embeddings\",\n inference_config: {\n service: \"azureopenai\",\n service_settings: {\n api_key: \"Api-Key\",\n resource_name: \"Resource-name\",\n deployment_id: \"Deployment-id\",\n api_version: \"2024-02-01\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"azure_openai_embeddings\",\n body: {\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"azure_openai_embeddings\",\n \"body\" => [\n \"service\" => \"azureopenai\",\n \"service_settings\" => [\n \"api_key\" => \"Api-Key\",\n \"resource_name\" => \"Resource-name\",\n \"deployment_id\" => \"Deployment-id\",\n \"api_version\" => \"2024-02-01\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_openai_embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"azure_openai_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"azureopenai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Api-Key\\\",\\\"resource_name\\\":\\\"Resource-name\\\",\\\"deployment_id\\\":\\\"Deployment-id\\\",\\\"api_version\\\":\\\"2024-02-01\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"azure_openai_completion\",\n inference_config={\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"azure_openai_completion\",\n inference_config: {\n service: \"azureopenai\",\n service_settings: {\n api_key: \"Api-Key\",\n resource_name: \"Resource-name\",\n deployment_id: \"Deployment-id\",\n api_version: \"2024-02-01\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"azure_openai_completion\",\n body: {\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"azure_openai_completion\",\n \"body\" => [\n \"service\" => \"azureopenai\",\n \"service_settings\" => [\n \"api_key\" => \"Api-Key\",\n \"resource_name\" => \"Resource-name\",\n \"deployment_id\" => \"Deployment-id\",\n \"api_version\" => \"2024-02-01\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_openai_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"azure_openai_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"azureopenai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Api-Key\\\",\\\"resource_name\\\":\\\"Resource-name\\\",\\\"deployment_id\\\":\\\"Deployment-id\\\",\\\"api_version\\\":\\\"2024-02-01\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.stream_completion(\n inference_id=\"openai-completion\",\n input=\"What is Elastic?\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.streamCompletion({\n inference_id: \"openai-completion\",\n input: \"What is Elastic?\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.stream_completion(\n inference_id: \"openai-completion\",\n body: {\n \"input\": \"What is Elastic?\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->streamCompletion([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"input\" => \"What is Elastic?\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"What is Elastic?\"}' \"$ELASTICSEARCH_URL/_inference/completion/openai-completion/_stream\"" + }, + { + "language": "Java", + "code": "client.inference().streamCompletion(s -> s\n .inferenceId(\"openai-completion\")\n .input(\"What is Elastic?\")\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-e5-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 3,\n max_number_of_allocations: 10,\n },\n num_threads: 1,\n model_id: \".multilingual-e5-small\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-e5-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 3,\n \"max_number_of_allocations\" => 10,\n ],\n \"num_threads\" => 1,\n \"model_id\" => \".multilingual-e5-small\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-e5-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":3,\\\"max_number_of_allocations\\\":10},\\\"num_threads\\\":1,\\\"model_id\\\":\\\".multilingual-e5-small\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-msmarco-minilm-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \"msmarco-MiniLM-L12-cos-v5\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-msmarco-minilm-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n model_id: \"msmarco-MiniLM-L12-cos-v5\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-msmarco-minilm-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \"msmarco-MiniLM-L12-cos-v5\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-msmarco-minilm-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n \"model_id\" => \"msmarco-MiniLM-L12-cos-v5\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\"msmarco-MiniLM-L12-cos-v5\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-msmarco-minilm-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-msmarco-minilm-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1,\\\"model_id\\\":\\\"msmarco-MiniLM-L12-cos-v5\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-e5-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n model_id: \".multilingual-e5-small\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-e5-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n \"model_id\" => \".multilingual-e5-small\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-e5-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1,\\\"model_id\\\":\\\".multilingual-e5-small\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"my-elastic-rerank\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"model_id\": \".rerank-v1\",\n \"num_threads\": 1,\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"my-elastic-rerank\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n model_id: \".rerank-v1\",\n num_threads: 1,\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 1,\n max_number_of_allocations: 4,\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"my-elastic-rerank\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"model_id\": \".rerank-v1\",\n \"num_threads\": 1,\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"my-elastic-rerank\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"model_id\" => \".rerank-v1\",\n \"num_threads\" => 1,\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 1,\n \"max_number_of_allocations\" => 4,\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"model_id\":\".rerank-v1\",\"num_threads\":1,\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4}}}' \"$ELASTICSEARCH_URL/_inference/rerank/my-elastic-rerank\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-elastic-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\".rerank-v1\\\",\\\"num_threads\\\":1,\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":1,\\\"max_number_of_allocations\\\":4}}\"))\n )\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n },\n \"num_threads\": 1,\n \"model_id\": \".elser_model_2\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 1,\n max_number_of_allocations: 4,\n },\n num_threads: 1,\n model_id: \".elser_model_2\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n },\n \"num_threads\": 1,\n \"model_id\": \".elser_model_2\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 1,\n \"max_number_of_allocations\" => 4,\n ],\n \"num_threads\" => 1,\n \"model_id\" => \".elser_model_2\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4},\"num_threads\":1,\"model_id\":\".elser_model_2\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":1,\\\"max_number_of_allocations\\\":4},\\\"num_threads\\\":1,\\\"model_id\\\":\\\".elser_model_2\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"use_existing_deployment\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"deployment_id\": \".elser_model_2\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"use_existing_deployment\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n deployment_id: \".elser_model_2\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"use_existing_deployment\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"deployment_id\": \".elser_model_2\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"use_existing_deployment\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"deployment_id\" => \".elser_model_2\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"deployment_id\":\".elser_model_2\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/use_existing_deployment\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"use_existing_deployment\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"deployment_id\\\":\\\".elser_model_2\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"azure_ai_studio_completion\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"databricks\",\n \"endpoint_type\": \"realtime\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"azure_ai_studio_completion\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-URI\",\n provider: \"databricks\",\n endpoint_type: \"realtime\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"azure_ai_studio_completion\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"databricks\",\n \"endpoint_type\": \"realtime\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"azure_ai_studio_completion\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-URI\",\n \"provider\" => \"databricks\",\n \"endpoint_type\" => \"realtime\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"provider\":\"databricks\",\"endpoint_type\":\"realtime\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_ai_studio_completion\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"azure_ai_studio_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"azureaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Azure-AI-Studio-API-key\\\",\\\"target\\\":\\\"Target-URI\\\",\\\"provider\\\":\\\"databricks\\\",\\\"endpoint_type\\\":\\\"realtime\\\"}\"))\n )\n);\n" + } + ], + "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"azure_ai_studio_embeddings\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-Uri\",\n \"provider\": \"openai\",\n \"endpoint_type\": \"token\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"azure_ai_studio_embeddings\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-Uri\",\n provider: \"openai\",\n endpoint_type: \"token\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"azure_ai_studio_embeddings\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-Uri\",\n \"provider\": \"openai\",\n \"endpoint_type\": \"token\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"azure_ai_studio_embeddings\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-Uri\",\n \"provider\" => \"openai\",\n \"endpoint_type\" => \"token\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-Uri\",\"provider\":\"openai\",\"endpoint_type\":\"token\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_ai_studio_embeddings\"" + }, + { + "language": "Java", + "code": "client.inference().put(p -> p\n .inferenceId(\"azure_ai_studio_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"azureaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Azure-AI-Studio-API-key\\\",\\\"target\\\":\\\"Target-Uri\\\",\\\"provider\\\":\\\"openai\\\",\\\"endpoint_type\\\":\\\"token\\\"}\"))\n )\n);\n" + } + ], + "specification/query_rules/list_rulesets/examples/request/QueryRulesetListRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.list_rulesets(\n from=\"0\",\n size=\"3\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.listRulesets({\n from: 0,\n size: 3,\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.list_rulesets(\n from: \"0\",\n size: \"3\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->listRulesets([\n \"from\" => \"0\",\n \"size\" => \"3\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/?from=0&size=3\"" + }, + { + "language": "Java", + "code": "client.queryRules().listRulesets(l -> l\n .from(0)\n .size(3)\n);\n" + } + ], + "specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.put_ruleset(\n ruleset_id=\"my-ruleset\",\n rules=[\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.putRuleset({\n ruleset_id: \"my-ruleset\",\n rules: [\n {\n rule_id: \"my-rule1\",\n type: \"pinned\",\n criteria: [\n {\n type: \"contains\",\n metadata: \"user_query\",\n values: [\"pugs\", \"puggles\"],\n },\n {\n type: \"exact\",\n metadata: \"user_country\",\n values: [\"us\"],\n },\n ],\n actions: {\n ids: [\"id1\", \"id2\"],\n },\n },\n {\n rule_id: \"my-rule2\",\n type: \"pinned\",\n criteria: [\n {\n type: \"fuzzy\",\n metadata: \"user_query\",\n values: [\"rescue dogs\"],\n },\n ],\n actions: {\n docs: [\n {\n _index: \"index1\",\n _id: \"id3\",\n },\n {\n _index: \"index2\",\n _id: \"id4\",\n },\n ],\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.put_ruleset(\n ruleset_id: \"my-ruleset\",\n body: {\n \"rules\": [\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->putRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"rules\" => array(\n [\n \"rule_id\" => \"my-rule1\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"contains\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"pugs\",\n \"puggles\",\n ),\n ],\n [\n \"type\" => \"exact\",\n \"metadata\" => \"user_country\",\n \"values\" => array(\n \"us\",\n ),\n ],\n ),\n \"actions\" => [\n \"ids\" => array(\n \"id1\",\n \"id2\",\n ),\n ],\n ],\n [\n \"rule_id\" => \"my-rule2\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"fuzzy\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"rescue dogs\",\n ),\n ],\n ),\n \"actions\" => [\n \"docs\" => array(\n [\n \"_index\" => \"index1\",\n \"_id\" => \"id3\",\n ],\n [\n \"_index\" => \"index2\",\n \"_id\" => \"id4\",\n ],\n ),\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"rule_id\":\"my-rule1\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"contains\",\"metadata\":\"user_query\",\"values\":[\"pugs\",\"puggles\"]},{\"type\":\"exact\",\"metadata\":\"user_country\",\"values\":[\"us\"]}],\"actions\":{\"ids\":[\"id1\",\"id2\"]}},{\"rule_id\":\"my-rule2\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"fuzzy\",\"metadata\":\"user_query\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" + }, + { + "language": "Java", + "code": "client.queryRules().putRuleset(p -> p\n .rules(List.of(QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule1\")\n .type(QueryRuleType.Pinned)\n .criteria(List.of(QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Contains)\n .metadata(\"user_query\")\n .values(List.of(JsonData.fromJson(\"\\\"pugs\\\"\"),JsonData.fromJson(\"\\\"puggles\\\"\")))),QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Exact)\n .metadata(\"user_country\")\n .values(JsonData.fromJson(\"\\\"us\\\"\")))))\n .actions(a -> a\n .ids(List.of(\"id1\",\"id2\"))\n )),QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule2\")\n .type(QueryRuleType.Pinned)\n .criteria(c -> c\n .type(QueryRuleCriteriaType.Fuzzy)\n .metadata(\"user_query\")\n .values(JsonData.fromJson(\"\\\"rescue dogs\\\"\"))\n )\n .actions(a -> a\n .docs(List.of(PinnedDoc.of(pi -> pi\n .id(\"id3\")\n .index(\"index1\")),PinnedDoc.of(pi -> pi\n .id(\"id4\")\n .index(\"index2\"))))\n ))))\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.test(\n ruleset_id=\"my-ruleset\",\n match_criteria={\n \"query_string\": \"puggles\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.test({\n ruleset_id: \"my-ruleset\",\n match_criteria: {\n query_string: \"puggles\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.test(\n ruleset_id: \"my-ruleset\",\n body: {\n \"match_criteria\": {\n \"query_string\": \"puggles\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->test([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"match_criteria\" => [\n \"query_string\" => \"puggles\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"match_criteria\":{\"query_string\":\"puggles\"}}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_test\"" + }, + { + "language": "Java", + "code": "client.queryRules().test(t -> t\n .matchCriteria(\"query_string\", JsonData.fromJson(\"\\\"puggles\\\"\"))\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/delete_rule/examples/request/QueryRulesDeleteRuleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.delete_rule(\n ruleset_id=\"my-ruleset\",\n rule_id=\"my-rule1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.deleteRule({\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.delete_rule(\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->deleteRule([\n \"ruleset_id\" => \"my-ruleset\",\n \"rule_id\" => \"my-rule1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_rule/my-rule1\"" + }, + { + "language": "Java", + "code": "client.queryRules().deleteRule(d -> d\n .ruleId(\"my-rule1\")\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/get_rule/examples/request/QueryRuleGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.get_rule(\n ruleset_id=\"my-ruleset\",\n rule_id=\"my-rule1\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.getRule({\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.get_rule(\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->getRule([\n \"ruleset_id\" => \"my-ruleset\",\n \"rule_id\" => \"my-rule1\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_rule/my-rule1\"" + }, + { + "language": "Java", + "code": "client.queryRules().getRule(g -> g\n .ruleId(\"my-rule1\")\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/get_ruleset/examples/request/QueryRulesetGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.get_ruleset(\n ruleset_id=\"my-ruleset\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.getRuleset({\n ruleset_id: \"my-ruleset\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.get_ruleset(\n ruleset_id: \"my-ruleset\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->getRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/\"" + }, + { + "language": "Java", + "code": "client.queryRules().getRuleset(g -> g\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/delete_ruleset/examples/request/QueryRulesDeleteRulesetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.delete_ruleset(\n ruleset_id=\"my-ruleset\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.deleteRuleset({\n ruleset_id: \"my-ruleset\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.delete_ruleset(\n ruleset_id: \"my-ruleset\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->deleteRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/\"" + }, + { + "language": "Java", + "code": "client.queryRules().deleteRuleset(d -> d\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.query_rules.put_ruleset(\n ruleset_id=\"my-ruleset\",\n rules=[\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ],\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.queryRules.putRuleset({\n ruleset_id: \"my-ruleset\",\n rules: [\n {\n rule_id: \"my-rule1\",\n type: \"pinned\",\n criteria: [\n {\n type: \"contains\",\n metadata: \"user_query\",\n values: [\"pugs\", \"puggles\"],\n },\n {\n type: \"exact\",\n metadata: \"user_country\",\n values: [\"us\"],\n },\n ],\n actions: {\n ids: [\"id1\", \"id2\"],\n },\n },\n {\n rule_id: \"my-rule2\",\n type: \"pinned\",\n criteria: [\n {\n type: \"fuzzy\",\n metadata: \"user_query\",\n values: [\"rescue dogs\"],\n },\n ],\n actions: {\n docs: [\n {\n _index: \"index1\",\n _id: \"id3\",\n },\n {\n _index: \"index2\",\n _id: \"id4\",\n },\n ],\n },\n },\n ],\n});" + }, + { + "language": "Ruby", + "code": "response = client.query_rules.put_ruleset(\n ruleset_id: \"my-ruleset\",\n body: {\n \"rules\": [\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ]\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->queryRules()->putRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"rules\" => array(\n [\n \"rule_id\" => \"my-rule1\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"contains\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"pugs\",\n \"puggles\",\n ),\n ],\n [\n \"type\" => \"exact\",\n \"metadata\" => \"user_country\",\n \"values\" => array(\n \"us\",\n ),\n ],\n ),\n \"actions\" => [\n \"ids\" => array(\n \"id1\",\n \"id2\",\n ),\n ],\n ],\n [\n \"rule_id\" => \"my-rule2\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"fuzzy\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"rescue dogs\",\n ),\n ],\n ),\n \"actions\" => [\n \"docs\" => array(\n [\n \"_index\" => \"index1\",\n \"_id\" => \"id3\",\n ],\n [\n \"_index\" => \"index2\",\n \"_id\" => \"id4\",\n ],\n ),\n ],\n ],\n ),\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"rule_id\":\"my-rule1\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"contains\",\"metadata\":\"user_query\",\"values\":[\"pugs\",\"puggles\"]},{\"type\":\"exact\",\"metadata\":\"user_country\",\"values\":[\"us\"]}],\"actions\":{\"ids\":[\"id1\",\"id2\"]}},{\"rule_id\":\"my-rule2\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"fuzzy\",\"metadata\":\"user_query\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" + }, + { + "language": "Java", + "code": "client.queryRules().putRuleset(p -> p\n .rules(List.of(QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule1\")\n .type(QueryRuleType.Pinned)\n .criteria(List.of(QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Contains)\n .metadata(\"user_query\")\n .values(List.of(JsonData.fromJson(\"\\\"pugs\\\"\"),JsonData.fromJson(\"\\\"puggles\\\"\")))),QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Exact)\n .metadata(\"user_country\")\n .values(JsonData.fromJson(\"\\\"us\\\"\")))))\n .actions(a -> a\n .ids(List.of(\"id1\",\"id2\"))\n )),QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule2\")\n .type(QueryRuleType.Pinned)\n .criteria(c -> c\n .type(QueryRuleCriteriaType.Fuzzy)\n .metadata(\"user_query\")\n .values(JsonData.fromJson(\"\\\"rescue dogs\\\"\"))\n )\n .actions(a -> a\n .docs(List.of(PinnedDoc.of(pi -> pi\n .id(\"id3\")\n .index(\"index1\")),PinnedDoc.of(pi -> pi\n .id(\"id4\")\n .index(\"index2\"))))\n ))))\n .rulesetId(\"my-ruleset\")\n);\n" + } + ], + "specification/enrich/delete_policy/examples/request/EnrichDeletePolicyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.enrich.delete_policy(\n name=\"my-policy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.enrich.deletePolicy({\n name: \"my-policy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.enrich.delete_policy(\n name: \"my-policy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->enrich()->deletePolicy([\n \"name\" => \"my-policy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy\"" + }, + { + "language": "Java", + "code": "client.enrich().deletePolicy(d -> d\n .name(\"my-policy\")\n);\n" + } + ], + "specification/enrich/execute_policy/examples/request/EnrichExecutePolicyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.enrich.execute_policy(\n name=\"my-policy\",\n wait_for_completion=False,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.enrich.executePolicy({\n name: \"my-policy\",\n wait_for_completion: \"false\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.enrich.execute_policy(\n name: \"my-policy\",\n wait_for_completion: \"false\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->enrich()->executePolicy([\n \"name\" => \"my-policy\",\n \"wait_for_completion\" => \"false\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy/_execute?wait_for_completion=false\"" + }, + { + "language": "Java", + "code": "client.enrich().executePolicy(e -> e\n .name(\"my-policy\")\n .waitForCompletion(false)\n);\n" + } + ], + "specification/enrich/get_policy/examples/request/EnrichGetPolicyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.enrich.get_policy(\n name=\"my-policy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.enrich.getPolicy({\n name: \"my-policy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.enrich.get_policy(\n name: \"my-policy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->enrich()->getPolicy([\n \"name\" => \"my-policy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy\"" + }, + { + "language": "Java", + "code": "client.enrich().getPolicy(g -> g\n .name(\"my-policy\")\n);\n" + } + ], + "specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.enrich.put_policy(\n name=\"postal_policy\",\n geo_match={\n \"indices\": \"postal_codes\",\n \"match_field\": \"location\",\n \"enrich_fields\": [\n \"location\",\n \"postal_code\"\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.enrich.putPolicy({\n name: \"postal_policy\",\n geo_match: {\n indices: \"postal_codes\",\n match_field: \"location\",\n enrich_fields: [\"location\", \"postal_code\"],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.enrich.put_policy(\n name: \"postal_policy\",\n body: {\n \"geo_match\": {\n \"indices\": \"postal_codes\",\n \"match_field\": \"location\",\n \"enrich_fields\": [\n \"location\",\n \"postal_code\"\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->enrich()->putPolicy([\n \"name\" => \"postal_policy\",\n \"body\" => [\n \"geo_match\" => [\n \"indices\" => \"postal_codes\",\n \"match_field\" => \"location\",\n \"enrich_fields\" => array(\n \"location\",\n \"postal_code\",\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"geo_match\":{\"indices\":\"postal_codes\",\"match_field\":\"location\",\"enrich_fields\":[\"location\",\"postal_code\"]}}' \"$ELASTICSEARCH_URL/_enrich/policy/postal_policy\"" + }, + { + "language": "Java", + "code": "client.enrich().putPolicy(p -> p\n .geoMatch(g -> g\n .enrichFields(List.of(\"location\",\"postal_code\"))\n .indices(\"postal_codes\")\n .matchField(\"location\")\n )\n .name(\"postal_policy\")\n);\n" + } + ], + "specification/enrich/stats/examples/request/EnrichStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.enrich.stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.enrich.stats();" + }, + { + "language": "Ruby", + "code": "response = client.enrich.stats" + }, + { + "language": "PHP", + "code": "$resp = $client->enrich()->stats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/_stats\"" + }, + { + "language": "Java", + "code": "client.enrich().stats(s -> s);\n" + } + ], + "specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.async_search.submit(\n index=\"sales*\",\n size=\"0\",\n sort=[\n {\n \"date\": {\n \"order\": \"asc\"\n }\n }\n ],\n aggs={\n \"sale_date\": {\n \"date_histogram\": {\n \"field\": \"date\",\n \"calendar_interval\": \"1d\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.asyncSearch.submit({\n index: \"sales*\",\n size: 0,\n sort: [\n {\n date: {\n order: \"asc\",\n },\n },\n ],\n aggs: {\n sale_date: {\n date_histogram: {\n field: \"date\",\n calendar_interval: \"1d\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.async_search.submit(\n index: \"sales*\",\n size: \"0\",\n body: {\n \"sort\": [\n {\n \"date\": {\n \"order\": \"asc\"\n }\n }\n ],\n \"aggs\": {\n \"sale_date\": {\n \"date_histogram\": {\n \"field\": \"date\",\n \"calendar_interval\": \"1d\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->asyncSearch()->submit([\n \"index\" => \"sales*\",\n \"size\" => \"0\",\n \"body\" => [\n \"sort\" => array(\n [\n \"date\" => [\n \"order\" => \"asc\",\n ],\n ],\n ),\n \"aggs\" => [\n \"sale_date\" => [\n \"date_histogram\" => [\n \"field\" => \"date\",\n \"calendar_interval\" => \"1d\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":[{\"date\":{\"order\":\"asc\"}}],\"aggs\":{\"sale_date\":{\"date_histogram\":{\"field\":\"date\",\"calendar_interval\":\"1d\"}}}}' \"$ELASTICSEARCH_URL/sales*/_async_search?size=0\"" + }, + { + "language": "Java", + "code": "client.asyncSearch().submit(s -> s\n .aggregations(\"sale_date\", a -> a\n .dateHistogram(d -> d\n .calendarInterval(CalendarInterval.Day)\n .field(\"date\")\n )\n )\n .index(\"sales*\")\n .size(0)\n .sort(so -> so\n .field(f -> f\n .field(\"date\")\n .order(SortOrder.Asc)\n )\n )\n,Void.class);\n" + } + ], + "specification/async_search/delete/examples/request/AsyncSearchDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.async_search.delete(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.asyncSearch.delete({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.async_search.delete(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->asyncSearch()->delete([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" + }, + { + "language": "Java", + "code": "client.asyncSearch().delete(d -> d\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" + } + ], + "specification/async_search/get/examples/request/AsyncSearchGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.async_search.get(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.asyncSearch.get({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.async_search.get(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->asyncSearch()->get([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" + }, + { + "language": "Java", + "code": "client.asyncSearch().get(g -> g\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" + } + ], + "specification/async_search/status/examples/request/AsyncSearchStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.async_search.status(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.asyncSearch.status({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.async_search.status(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->asyncSearch()->status([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/status/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" + }, + { + "language": "Java", + "code": "client.asyncSearch().status(s -> s\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" + } + ], + "specification/eql/get_status/examples/request/EqlGetStatusExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.eql.get_status(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.eql.getStatus({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.eql.get_status(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->eql()->getStatus([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/status/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"" + }, + { + "language": "Java", + "code": "client.eql().getStatus(g -> g\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n);\n" + } + ], + "specification/eql/delete/examples/request/EqlDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.eql.delete(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.eql.delete({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.eql.delete(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->eql()->delete([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"" + }, + { + "language": "Java", + "code": "client.eql().delete(d -> d\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n);\n" + } + ], + "specification/eql/get/examples/request/EqlGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.eql.get(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout=\"2s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.eql.get({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"2s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.eql.get(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"2s\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->eql()->get([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n \"wait_for_completion_timeout\" => \"2s\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=2s\"" + }, + { + "language": "Java", + "code": "client.eql().get(g -> g\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n .waitForCompletionTimeout(w -> w\n .offset(2)\n )\n);\n" + } + ], + "specification/eql/search/examples/request/EqlSearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.eql.search(\n index=\"my-data-stream\",\n query=\"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.eql.search({\n index: \"my-data-stream\",\n query:\n '\\n process where (process.name == \"cmd.exe\" and process.pid != 2013)\\n ',\n});" + }, + { + "language": "Ruby", + "code": "response = client.eql.search(\n index: \"my-data-stream\",\n body: {\n \"query\": \"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->eql()->search([\n \"index\" => \"my-data-stream\",\n \"body\" => [\n \"query\" => \"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" + }, + { + "language": "Java", + "code": "client.eql().search(s -> s\n .index(\"my-data-stream\")\n .query(\" process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013) \")\n);\n" + } + ], + "specification/eql/search/examples/request/EqlSearchRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.eql.search(\n index=\"my-data-stream\",\n query=\"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.eql.search({\n index: \"my-data-stream\",\n query:\n '\\n sequence by process.pid\\n [ file where file.name == \"cmd.exe\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \"regsvr32\") ]\\n ',\n});" + }, + { + "language": "Ruby", + "code": "response = client.eql.search(\n index: \"my-data-stream\",\n body: {\n \"query\": \"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->eql()->search([\n \"index\" => \"my-data-stream\",\n \"body\" => [\n \"query\" => \"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" + }, + { + "language": "Java", + "code": "client.eql().search(s -> s\n .index(\"my-data-stream\")\n .query(\" sequence by process.pid [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ][ process where stringContains(process.executable, \\\"regsvr32\\\") ] \")\n);\n" + } + ], + "specification/esql/async_query_stop/examples/request/EsqlAsyncQueryStopExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.esql.async_query_stop(\n id=\"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.esql.asyncQueryStop({\n id: \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.esql.async_query_stop(\n id: \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->esql()->asyncQueryStop([\n \"id\" => \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=/stop\"" + } + ], + "specification/esql/async_query/examples/request/AsyncQueryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.esql.async_query(\n query=\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n wait_for_completion_timeout=\"2s\",\n include_ccs_metadata=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.esql.asyncQuery({\n query:\n \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n wait_for_completion_timeout: \"2s\",\n include_ccs_metadata: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.esql.async_query(\n body: {\n \"query\": \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"wait_for_completion_timeout\": \"2s\",\n \"include_ccs_metadata\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->esql()->asyncQuery([\n \"body\" => [\n \"query\" => \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"wait_for_completion_timeout\" => \"2s\",\n \"include_ccs_metadata\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\"wait_for_completion_timeout\":\"2s\",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query/async\"" + } + ], + "specification/esql/async_query_get/examples/request/EsqlAsyncQueryGetExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.esql.async_query_get(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout=\"30s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.esql.asyncQueryGet({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"30s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.esql.async_query_get(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"30s\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->esql()->asyncQueryGet([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n \"wait_for_completion_timeout\" => \"30s\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=30s\"" + } + ], + "specification/esql/query/examples/request/QueryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.esql.query(\n query=\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n include_ccs_metadata=True,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.esql.query({\n query:\n \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n include_ccs_metadata: true,\n});" + }, + { + "language": "Ruby", + "code": "response = client.esql.query(\n body: {\n \"query\": \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"include_ccs_metadata\": true\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->esql()->query([\n \"body\" => [\n \"query\" => \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"include_ccs_metadata\" => true,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query\"" + }, + { + "language": "Java", + "code": "client.esql().query(q -> q\n .includeCcsMetadata(true)\n .query(\" FROM library,remote-*:library | EVAL year = DATE_TRUNC(1 YEARS, release_date) | STATS MAX(page_count) BY year | SORT year | LIMIT 5 \")\n);\n" + } + ], + "specification/esql/async_query_delete/examples/request/EsqlAsyncQueryDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.esql.async_query_delete(\n id=\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.esql.asyncQueryDelete({\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.esql.async_query_delete(\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->esql()->asyncQueryDelete([\n \"id\" => \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"" + } + ], + "specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.autoscaling.put_autoscaling_policy(\n name=\"\",\n policy={\n \"roles\": [],\n \"deciders\": {\n \"fixed\": {}\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.autoscaling.putAutoscalingPolicy({\n name: \"\",\n policy: {\n roles: [],\n deciders: {\n fixed: {},\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.autoscaling.put_autoscaling_policy(\n name: \"\",\n body: {\n \"roles\": [],\n \"deciders\": {\n \"fixed\": {}\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->autoscaling()->putAutoscalingPolicy([\n \"name\" => \"\",\n \"body\" => [\n \"roles\" => array(\n ),\n \"deciders\" => [\n \"fixed\" => new ArrayObject([]),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[],\"deciders\":{\"fixed\":{}}}' \"$ELASTICSEARCH_URL/_autoscaling/policy/\"" + }, + { + "language": "Java", + "code": "client.autoscaling().putAutoscalingPolicy(p -> p\n .name(\"\")\n .policy(po -> po\n .deciders(\"fixed\", JsonData.fromJson(\"{}\"))\n )\n);\n" + } + ], + "specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.autoscaling.put_autoscaling_policy(\n name=\"my_autoscaling_policy\",\n policy={\n \"roles\": [\n \"data_hot\"\n ],\n \"deciders\": {\n \"fixed\": {}\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.autoscaling.putAutoscalingPolicy({\n name: \"my_autoscaling_policy\",\n policy: {\n roles: [\"data_hot\"],\n deciders: {\n fixed: {},\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.autoscaling.put_autoscaling_policy(\n name: \"my_autoscaling_policy\",\n body: {\n \"roles\": [\n \"data_hot\"\n ],\n \"deciders\": {\n \"fixed\": {}\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->autoscaling()->putAutoscalingPolicy([\n \"name\" => \"my_autoscaling_policy\",\n \"body\" => [\n \"roles\" => array(\n \"data_hot\",\n ),\n \"deciders\" => [\n \"fixed\" => new ArrayObject([]),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"data_hot\"],\"deciders\":{\"fixed\":{}}}' \"$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy\"" + }, + { + "language": "Java", + "code": "client.autoscaling().putAutoscalingPolicy(p -> p\n .name(\"my_autoscaling_policy\")\n .policy(po -> po\n .roles(\"data_hot\")\n .deciders(\"fixed\", JsonData.fromJson(\"{}\"))\n )\n);\n" + } + ], + "specification/autoscaling/delete_autoscaling_policy/examples/request/DeleteAutoscalingPolicyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.autoscaling.delete_autoscaling_policy(\n name=\"*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.autoscaling.deleteAutoscalingPolicy({\n name: \"*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.autoscaling.delete_autoscaling_policy(\n name: \"*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->autoscaling()->deleteAutoscalingPolicy([\n \"name\" => \"*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/policy/*\"" + }, + { + "language": "Java", + "code": "client.autoscaling().deleteAutoscalingPolicy(d -> d\n .name(\"*\")\n);\n" + } + ], + "specification/autoscaling/get_autoscaling_policy/examples/request/GetAutoscalingPolicyRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.autoscaling.get_autoscaling_policy(\n name=\"my_autoscaling_policy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.autoscaling.getAutoscalingPolicy({\n name: \"my_autoscaling_policy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.autoscaling.get_autoscaling_policy(\n name: \"my_autoscaling_policy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->autoscaling()->getAutoscalingPolicy([\n \"name\" => \"my_autoscaling_policy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy\"" + }, + { + "language": "Java", + "code": "client.autoscaling().getAutoscalingPolicy(g -> g\n .name(\"my_autoscaling_policy\")\n);\n" + } + ], + "specification/autoscaling/get_autoscaling_capacity/examples/request/GetAutoscalingCapacityRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.autoscaling.get_autoscaling_capacity()" + }, + { + "language": "JavaScript", + "code": "const response = await client.autoscaling.getAutoscalingCapacity();" + }, + { + "language": "Ruby", + "code": "response = client.autoscaling.get_autoscaling_capacity" + }, + { + "language": "PHP", + "code": "$resp = $client->autoscaling()->getAutoscalingCapacity();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/capacity\"" + }, + { + "language": "Java", + "code": "client.autoscaling().getAutoscalingCapacity(g -> g);\n" + } + ], + "specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.render_query(\n name=\"my-app\",\n params={\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.renderQuery({\n name: \"my-app\",\n params: {\n query_string: \"my first query\",\n text_fields: [\n {\n name: \"title\",\n boost: 5,\n },\n {\n name: \"description\",\n boost: 1,\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.render_query(\n name: \"my-app\",\n body: {\n \"params\": {\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->renderQuery([\n \"name\" => \"my-app\",\n \"body\" => [\n \"params\" => [\n \"query_string\" => \"my first query\",\n \"text_fields\" => array(\n [\n \"name\" => \"title\",\n \"boost\" => 5,\n ],\n [\n \"name\" => \"description\",\n \"boost\" => 1,\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"params\":{\"query_string\":\"my first query\",\"text_fields\":[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app/_render_query\"" + }, + { + "language": "Java", + "code": "client.searchApplication().renderQuery(r -> r\n .name(\"my-app\")\n .params(Map.of(\"text_fields\", JsonData.fromJson(\"[{\\\"name\\\":\\\"title\\\",\\\"boost\\\":5},{\\\"name\\\":\\\"description\\\",\\\"boost\\\":1}]\"),\"query_string\", JsonData.fromJson(\"\\\"my first query\\\"\")))\n);\n" + } + ], + "specification/search_application/delete/examples/request/SearchApplicationDeleteExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.delete(\n name=\"my-app\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.delete({\n name: \"my-app\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.delete(\n name: \"my-app\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->delete([\n \"name\" => \"my-app\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application/my-app/\"" + }, + { + "language": "Java", + "code": "client.searchApplication().delete(d -> d\n .name(\"my-app\")\n);\n" + } + ], + "specification/search_application/put/examples/request/SearchApplicationPutRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.put(\n name=\"my-app\",\n search_application={\n \"indices\": [\n \"index1\",\n \"index2\"\n ],\n \"template\": {\n \"script\": {\n \"source\": {\n \"query\": {\n \"query_string\": {\n \"query\": \"{{query_string}}\",\n \"default_field\": \"{{default_field}}\"\n }\n }\n },\n \"params\": {\n \"query_string\": \"*\",\n \"default_field\": \"*\"\n }\n },\n \"dictionary\": {\n \"properties\": {\n \"query_string\": {\n \"type\": \"string\"\n },\n \"default_field\": {\n \"type\": \"string\",\n \"enum\": [\n \"title\",\n \"description\"\n ]\n },\n \"additionalProperties\": False\n },\n \"required\": [\n \"query_string\"\n ]\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.put({\n name: \"my-app\",\n search_application: {\n indices: [\"index1\", \"index2\"],\n template: {\n script: {\n source: {\n query: {\n query_string: {\n query: \"{{query_string}}\",\n default_field: \"{{default_field}}\",\n },\n },\n },\n params: {\n query_string: \"*\",\n default_field: \"*\",\n },\n },\n dictionary: {\n properties: {\n query_string: {\n type: \"string\",\n },\n default_field: {\n type: \"string\",\n enum: [\"title\", \"description\"],\n },\n additionalProperties: false,\n },\n required: [\"query_string\"],\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.put(\n name: \"my-app\",\n body: {\n \"indices\": [\n \"index1\",\n \"index2\"\n ],\n \"template\": {\n \"script\": {\n \"source\": {\n \"query\": {\n \"query_string\": {\n \"query\": \"{{query_string}}\",\n \"default_field\": \"{{default_field}}\"\n }\n }\n },\n \"params\": {\n \"query_string\": \"*\",\n \"default_field\": \"*\"\n }\n },\n \"dictionary\": {\n \"properties\": {\n \"query_string\": {\n \"type\": \"string\"\n },\n \"default_field\": {\n \"type\": \"string\",\n \"enum\": [\n \"title\",\n \"description\"\n ]\n },\n \"additionalProperties\": false\n },\n \"required\": [\n \"query_string\"\n ]\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->put([\n \"name\" => \"my-app\",\n \"body\" => [\n \"indices\" => array(\n \"index1\",\n \"index2\",\n ),\n \"template\" => [\n \"script\" => [\n \"source\" => [\n \"query\" => [\n \"query_string\" => [\n \"query\" => \"{{query_string}}\",\n \"default_field\" => \"{{default_field}}\",\n ],\n ],\n ],\n \"params\" => [\n \"query_string\" => \"*\",\n \"default_field\" => \"*\",\n ],\n ],\n \"dictionary\" => [\n \"properties\" => [\n \"query_string\" => [\n \"type\" => \"string\",\n ],\n \"default_field\" => [\n \"type\" => \"string\",\n \"enum\" => array(\n \"title\",\n \"description\",\n ),\n ],\n \"additionalProperties\" => false,\n ],\n \"required\" => array(\n \"query_string\",\n ),\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":[\"index1\",\"index2\"],\"template\":{\"script\":{\"source\":{\"query\":{\"query_string\":{\"query\":\"{{query_string}}\",\"default_field\":\"{{default_field}}\"}}},\"params\":{\"query_string\":\"*\",\"default_field\":\"*\"}},\"dictionary\":{\"properties\":{\"query_string\":{\"type\":\"string\"},\"default_field\":{\"type\":\"string\",\"enum\":[\"title\",\"description\"]},\"additionalProperties\":false},\"required\":[\"query_string\"]}}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app\"" + }, + { + "language": "Java", + "code": "client.searchApplication().put(p -> p\n .name(\"my-app\")\n .searchApplication(s -> s\n .indices(List.of(\"index1\",\"index2\"))\n .template(t -> t\n .script(sc -> sc\n .source(so -> so\n .scriptTemplate(scr -> scr\n .query(q -> q\n .queryString(qu -> qu\n .defaultField(\"{{default_field}}\")\n .query(\"{{query_string}}\")\n )\n )\n )\n )\n .params(Map.of(\"default_field\", JsonData.fromJson(\"\\\"*\\\"\"),\"query_string\", JsonData.fromJson(\"\\\"*\\\"\")))\n )\n )\n )\n);\n" + } + ], + "specification/search_application/get/examples/request/SearchApplicationGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.get(\n name=\"my-app\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.get({\n name: \"my-app\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.get(\n name: \"my-app\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->get([\n \"name\" => \"my-app\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application/my-app/\"" + }, + { + "language": "Java", + "code": "client.searchApplication().get(g -> g\n .name(\"my-app\")\n);\n" + } + ], + "specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.post_behavioral_analytics_event(\n collection_name=\"my_analytics_collection\",\n event_type=\"search_click\",\n payload={\n \"session\": {\n \"id\": \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"\n },\n \"user\": {\n \"id\": \"5f26f01a-bbee-4202-9298-81261067abbd\"\n },\n \"search\": {\n \"query\": \"search term\",\n \"results\": {\n \"items\": [\n {\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n ],\n \"total_results\": 10\n },\n \"sort\": {\n \"name\": \"relevance\"\n },\n \"search_application\": \"website\"\n },\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.postBehavioralAnalyticsEvent({\n collection_name: \"my_analytics_collection\",\n event_type: \"search_click\",\n payload: {\n session: {\n id: \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\",\n },\n user: {\n id: \"5f26f01a-bbee-4202-9298-81261067abbd\",\n },\n search: {\n query: \"search term\",\n results: {\n items: [\n {\n document: {\n id: \"123\",\n index: \"products\",\n },\n },\n ],\n total_results: 10,\n },\n sort: {\n name: \"relevance\",\n },\n search_application: \"website\",\n },\n document: {\n id: \"123\",\n index: \"products\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.post_behavioral_analytics_event(\n collection_name: \"my_analytics_collection\",\n event_type: \"search_click\",\n body: {\n \"session\": {\n \"id\": \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"\n },\n \"user\": {\n \"id\": \"5f26f01a-bbee-4202-9298-81261067abbd\"\n },\n \"search\": {\n \"query\": \"search term\",\n \"results\": {\n \"items\": [\n {\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n ],\n \"total_results\": 10\n },\n \"sort\": {\n \"name\": \"relevance\"\n },\n \"search_application\": \"website\"\n },\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->postBehavioralAnalyticsEvent([\n \"collection_name\" => \"my_analytics_collection\",\n \"event_type\" => \"search_click\",\n \"body\" => [\n \"session\" => [\n \"id\" => \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\",\n ],\n \"user\" => [\n \"id\" => \"5f26f01a-bbee-4202-9298-81261067abbd\",\n ],\n \"search\" => [\n \"query\" => \"search term\",\n \"results\" => [\n \"items\" => array(\n [\n \"document\" => [\n \"id\" => \"123\",\n \"index\" => \"products\",\n ],\n ],\n ),\n \"total_results\" => 10,\n ],\n \"sort\" => [\n \"name\" => \"relevance\",\n ],\n \"search_application\" => \"website\",\n ],\n \"document\" => [\n \"id\" => \"123\",\n \"index\" => \"products\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"session\":{\"id\":\"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"},\"user\":{\"id\":\"5f26f01a-bbee-4202-9298-81261067abbd\"},\"search\":{\"query\":\"search term\",\"results\":{\"items\":[{\"document\":{\"id\":\"123\",\"index\":\"products\"}}],\"total_results\":10},\"sort\":{\"name\":\"relevance\"},\"search_application\":\"website\"},\"document\":{\"id\":\"123\",\"index\":\"products\"}}' \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection/event/search_click\"" + }, + { + "language": "Java", + "code": "client.searchApplication().postBehavioralAnalyticsEvent(p -> p\n .collectionName(\"my_analytics_collection\")\n .eventType(EventType.SearchClick)\n .payload(JsonData.fromJson(\"{\\\"session\\\":{\\\"id\\\":\\\"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\\\"},\\\"user\\\":{\\\"id\\\":\\\"5f26f01a-bbee-4202-9298-81261067abbd\\\"},\\\"search\\\":{\\\"query\\\":\\\"search term\\\",\\\"results\\\":{\\\"items\\\":[{\\\"document\\\":{\\\"id\\\":\\\"123\\\",\\\"index\\\":\\\"products\\\"}}],\\\"total_results\\\":10},\\\"sort\\\":{\\\"name\\\":\\\"relevance\\\"},\\\"search_application\\\":\\\"website\\\"},\\\"document\\\":{\\\"id\\\":\\\"123\\\",\\\"index\\\":\\\"products\\\"}}\"))\n);\n" + } + ], + "specification/search_application/get_behavioral_analytics/examples/request/BehavioralAnalyticsGetRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.get_behavioral_analytics(\n name=\"my*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.getBehavioralAnalytics({\n name: \"my*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.get_behavioral_analytics(\n name: \"my*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->getBehavioralAnalytics([\n \"name\" => \"my*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my*\"" + }, + { + "language": "Java", + "code": "client.searchApplication().getBehavioralAnalytics(g -> g\n .name(\"my*\")\n);\n" + } + ], + "specification/search_application/delete_behavioral_analytics/examples/request/SearchApplicationDeleteBehavioralAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.delete_behavioral_analytics(\n name=\"my_analytics_collection\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.deleteBehavioralAnalytics({\n name: \"my_analytics_collection\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.delete_behavioral_analytics(\n name: \"my_analytics_collection\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->deleteBehavioralAnalytics([\n \"name\" => \"my_analytics_collection\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection/\"" + }, + { + "language": "Java", + "code": "client.searchApplication().deleteBehavioralAnalytics(d -> d\n .name(\"my_analytics_collection\")\n);\n" + } + ], + "specification/search_application/put_behavioral_analytics/examples/request/SearchApplicationPutBehavioralAnalyticsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.put_behavioral_analytics(\n name=\"my_analytics_collection\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.putBehavioralAnalytics({\n name: \"my_analytics_collection\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.put_behavioral_analytics(\n name: \"my_analytics_collection\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->putBehavioralAnalytics([\n \"name\" => \"my_analytics_collection\",\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection\"" + }, + { + "language": "Java", + "code": "client.searchApplication().putBehavioralAnalytics(p -> p\n .name(\"my_analytics_collection\")\n);\n" + } + ], + "specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.search(\n name=\"my-app\",\n params={\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.search({\n name: \"my-app\",\n params: {\n query_string: \"my first query\",\n text_fields: [\n {\n name: \"title\",\n boost: 5,\n },\n {\n name: \"description\",\n boost: 1,\n },\n ],\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.search(\n name: \"my-app\",\n body: {\n \"params\": {\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->search([\n \"name\" => \"my-app\",\n \"body\" => [\n \"params\" => [\n \"query_string\" => \"my first query\",\n \"text_fields\" => array(\n [\n \"name\" => \"title\",\n \"boost\" => 5,\n ],\n [\n \"name\" => \"description\",\n \"boost\" => 1,\n ],\n ),\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"params\":{\"query_string\":\"my first query\",\"text_fields\":[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app/_search\"" + }, + { + "language": "Java", + "code": "client.searchApplication().search(s -> s\n .name(\"my-app\")\n .params(Map.of(\"text_fields\", JsonData.fromJson(\"[{\\\"name\\\":\\\"title\\\",\\\"boost\\\":5},{\\\"name\\\":\\\"description\\\",\\\"boost\\\":1}]\"),\"query_string\", JsonData.fromJson(\"\\\"my first query\\\"\")))\n);\n" + } + ], + "specification/search_application/list/examples/request/SearchApplicationsListRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.search_application.list(\n from=\"0\",\n size=\"3\",\n q=\"app*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.searchApplication.list({\n from: 0,\n size: 3,\n q: \"app*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.search_application.list(\n from: \"0\",\n size: \"3\",\n q: \"app*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->searchApplication()->list([\n \"from\" => \"0\",\n \"size\" => \"3\",\n \"q\" => \"app*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application?from=0&size=3&q=app*\"" + }, + { + "language": "Java", + "code": "client.searchApplication().list(l -> l\n .from(0)\n .q(\"app*\")\n .size(3)\n);\n" + } + ], + "specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.migration.get_feature_upgrade_status()" + }, + { + "language": "JavaScript", + "code": "const response = await client.migration.getFeatureUpgradeStatus();" + }, + { + "language": "Ruby", + "code": "response = client.migration.get_feature_upgrade_status" + }, + { + "language": "PHP", + "code": "$resp = $client->migration()->getFeatureUpgradeStatus();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/system_features\"" + }, + { + "language": "Java", + "code": "client.migration().getFeatureUpgradeStatus();\n" + } + ], + "specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.migration.post_feature_upgrade()" + }, + { + "language": "JavaScript", + "code": "const response = await client.migration.postFeatureUpgrade();" + }, + { + "language": "Ruby", + "code": "response = client.migration.post_feature_upgrade" + }, + { + "language": "PHP", + "code": "$resp = $client->migration()->postFeatureUpgrade();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/system_features\"" + }, + { + "language": "Java", + "code": "client.migration().postFeatureUpgrade();\n" + } + ], + "specification/migration/deprecations/examples/request/DeprecationInfoRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.migration.deprecations()" + }, + { + "language": "JavaScript", + "code": "const response = await client.migration.deprecations();" + }, + { + "language": "Ruby", + "code": "response = client.migration.deprecations" + }, + { + "language": "PHP", + "code": "$resp = $client->migration()->deprecations();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/deprecations\"" + }, + { + "language": "Java", + "code": "client.migration().deprecations(d -> d);\n" + } + ], + "specification/transform/start_transform/examples/request/TransformStartTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.start_transform(\n transform_id=\"ecommerce-customer-transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.startTransform({\n transform_id: \"ecommerce-customer-transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.start_transform(\n transform_id: \"ecommerce-customer-transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->startTransform([\n \"transform_id\" => \"ecommerce-customer-transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce-customer-transform/_start\"" + }, + { + "language": "Java", + "code": "client.transform().startTransform(s -> s\n .transformId(\"ecommerce-customer-transform\")\n);\n" + } + ], + "specification/transform/schedule_now_transform/examples/request/TransformScheduleNowTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.schedule_now_transform(\n transform_id=\"ecommerce_transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.scheduleNowTransform({\n transform_id: \"ecommerce_transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.schedule_now_transform(\n transform_id: \"ecommerce_transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->scheduleNowTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_schedule_now\"" + }, + { + "language": "Java", + "code": "client.transform().scheduleNowTransform(s -> s\n .transformId(\"ecommerce_transform\")\n);\n" + } + ], + "specification/transform/get_transform/examples/request/TransformGetTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.get_transform(\n size=\"10\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.getTransform({\n size: 10,\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.get_transform(\n size: \"10\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->getTransform([\n \"size\" => \"10\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform?size=10\"" + }, + { + "language": "Java", + "code": "client.transform().getTransform(g -> g\n .size(10)\n);\n" + } + ], + "specification/transform/upgrade_transforms/examples/request/TransformUpgradeTransformsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.upgrade_transforms()" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.upgradeTransforms();" + }, + { + "language": "Ruby", + "code": "response = client.transform.upgrade_transforms" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->upgradeTransforms();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/_upgrade\"" + }, + { + "language": "Java", + "code": "client.transform().upgradeTransforms(u -> u);\n" + } + ], + "specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.preview_transform(\n source={\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n pivot={\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": True\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.previewTransform({\n source: {\n index: \"kibana_sample_data_ecommerce\",\n },\n pivot: {\n group_by: {\n customer_id: {\n terms: {\n field: \"customer_id\",\n missing_bucket: true,\n },\n },\n },\n aggregations: {\n max_price: {\n max: {\n field: \"taxful_total_price\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.preview_transform(\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n \"pivot\": {\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": true\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->previewTransform([\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n ],\n \"pivot\" => [\n \"group_by\" => [\n \"customer_id\" => [\n \"terms\" => [\n \"field\" => \"customer_id\",\n \"missing_bucket\" => true,\n ],\n ],\n ],\n \"aggregations\" => [\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"taxful_total_price\",\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\"},\"pivot\":{\"group_by\":{\"customer_id\":{\"terms\":{\"field\":\"customer_id\",\"missing_bucket\":true}}},\"aggregations\":{\"max_price\":{\"max\":{\"field\":\"taxful_total_price\"}}}}}' \"$ELASTICSEARCH_URL/_transform/_preview\"" + }, + { + "language": "Java", + "code": "client.transform().previewTransform(p -> p\n .pivot(pi -> pi\n .aggregations(\"max_price\", a -> a\n .max(m -> m\n .field(\"taxful_total_price\")\n )\n )\n .groupBy(\"customer_id\", g -> g\n .terms(t -> t\n .field(\"customer_id\")\n .missingBucket(true)\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n )\n);\n" + } + ], + "specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.put_transform(\n transform_id=\"ecommerce_transform2\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n latest={\n \"unique_key\": [\n \"customer_id\"\n ],\n \"sort\": \"order_date\"\n },\n description=\"Latest order for each customer\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform2\"\n },\n frequency=\"5m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.putTransform({\n transform_id: \"ecommerce_transform2\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n },\n latest: {\n unique_key: [\"customer_id\"],\n sort: \"order_date\",\n },\n description: \"Latest order for each customer\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform2\",\n },\n frequency: \"5m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"60s\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.put_transform(\n transform_id: \"ecommerce_transform2\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n \"latest\": {\n \"unique_key\": [\n \"customer_id\"\n ],\n \"sort\": \"order_date\"\n },\n \"description\": \"Latest order for each customer\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform2\"\n },\n \"frequency\": \"5m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->putTransform([\n \"transform_id\" => \"ecommerce_transform2\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n ],\n \"latest\" => [\n \"unique_key\" => array(\n \"customer_id\",\n ),\n \"sort\" => \"order_date\",\n ],\n \"description\" => \"Latest order for each customer\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform2\",\n ],\n \"frequency\" => \"5m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"60s\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\"},\"latest\":{\"unique_key\":[\"customer_id\"],\"sort\":\"order_date\"},\"description\":\"Latest order for each customer\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform2\"},\"frequency\":\"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform2\"" + }, + { + "language": "Java", + "code": "client.transform().putTransform(p -> p\n .description(\"Latest order for each customer\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform2\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .latest(l -> l\n .sort(\"order_date\")\n .uniqueKey(\"customer_id\")\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n )\n .sync(s -> s\n .time(t -> t\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"ecommerce_transform2\")\n);\n" + } + ], + "specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.put_transform(\n transform_id=\"ecommerce_transform1\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n pivot={\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": True\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n description=\"Maximum priced ecommerce data by customer_id in Asia\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n frequency=\"5m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n retention_policy={\n \"time\": {\n \"field\": \"order_date\",\n \"max_age\": \"30d\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.putTransform({\n transform_id: \"ecommerce_transform1\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n query: {\n term: {\n \"geoip.continent_name\": {\n value: \"Asia\",\n },\n },\n },\n },\n pivot: {\n group_by: {\n customer_id: {\n terms: {\n field: \"customer_id\",\n missing_bucket: true,\n },\n },\n },\n aggregations: {\n max_price: {\n max: {\n field: \"taxful_total_price\",\n },\n },\n },\n },\n description: \"Maximum priced ecommerce data by customer_id in Asia\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform1\",\n pipeline: \"add_timestamp_pipeline\",\n },\n frequency: \"5m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"60s\",\n },\n },\n retention_policy: {\n time: {\n field: \"order_date\",\n max_age: \"30d\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.put_transform(\n transform_id: \"ecommerce_transform1\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n \"pivot\": {\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": true\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n \"description\": \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n \"frequency\": \"5m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n \"retention_policy\": {\n \"time\": {\n \"field\": \"order_date\",\n \"max_age\": \"30d\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->putTransform([\n \"transform_id\" => \"ecommerce_transform1\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n \"query\" => [\n \"term\" => [\n \"geoip.continent_name\" => [\n \"value\" => \"Asia\",\n ],\n ],\n ],\n ],\n \"pivot\" => [\n \"group_by\" => [\n \"customer_id\" => [\n \"terms\" => [\n \"field\" => \"customer_id\",\n \"missing_bucket\" => true,\n ],\n ],\n ],\n \"aggregations\" => [\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"taxful_total_price\",\n ],\n ],\n ],\n ],\n \"description\" => \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\" => \"add_timestamp_pipeline\",\n ],\n \"frequency\" => \"5m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"60s\",\n ],\n ],\n \"retention_policy\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"max_age\" => \"30d\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\",\"query\":{\"term\":{\"geoip.continent_name\":{\"value\":\"Asia\"}}}},\"pivot\":{\"group_by\":{\"customer_id\":{\"terms\":{\"field\":\"customer_id\",\"missing_bucket\":true}}},\"aggregations\":{\"max_price\":{\"max\":{\"field\":\"taxful_total_price\"}}}},\"description\":\"Maximum priced ecommerce data by customer_id in Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform1\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}},\"retention_policy\":{\"time\":{\"field\":\"order_date\",\"max_age\":\"30d\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform1\"" + }, + { + "language": "Java", + "code": "client.transform().putTransform(p -> p\n .description(\"Maximum priced ecommerce data by customer_id in Asia\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform1\")\n .pipeline(\"add_timestamp_pipeline\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .pivot(pi -> pi\n .aggregations(\"max_price\", a -> a\n .max(m -> m\n .field(\"taxful_total_price\")\n )\n )\n .groupBy(\"customer_id\", g -> g\n .terms(t -> t\n .field(\"customer_id\")\n .missingBucket(true)\n )\n )\n )\n .retentionPolicy(r -> r\n .time(t -> t\n .field(\"order_date\")\n .maxAge(m -> m\n .time(\"30d\")\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n .query(q -> q\n .term(te -> te\n .field(\"geoip.continent_name\")\n .value(FieldValue.of(\"Asia\"))\n )\n )\n )\n .sync(sy -> sy\n .time(ti -> ti\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"ecommerce_transform1\")\n);\n" + } + ], + "specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.update_transform(\n transform_id=\"simple-kibana-ecomm-pivot\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n description=\"Maximum priced ecommerce data by customer_id in Asia\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n frequency=\"15m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"120s\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.updateTransform({\n transform_id: \"simple-kibana-ecomm-pivot\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n query: {\n term: {\n \"geoip.continent_name\": {\n value: \"Asia\",\n },\n },\n },\n },\n description: \"Maximum priced ecommerce data by customer_id in Asia\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform_v2\",\n pipeline: \"add_timestamp_pipeline\",\n },\n frequency: \"15m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"120s\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.update_transform(\n transform_id: \"simple-kibana-ecomm-pivot\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n \"description\": \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n \"frequency\": \"15m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"120s\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->updateTransform([\n \"transform_id\" => \"simple-kibana-ecomm-pivot\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n \"query\" => [\n \"term\" => [\n \"geoip.continent_name\" => [\n \"value\" => \"Asia\",\n ],\n ],\n ],\n ],\n \"description\" => \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\" => \"add_timestamp_pipeline\",\n ],\n \"frequency\" => \"15m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"120s\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\",\"query\":{\"term\":{\"geoip.continent_name\":{\"value\":\"Asia\"}}}},\"description\":\"Maximum priced ecommerce data by customer_id in Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform_v2\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\"15m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"120s\"}}}' \"$ELASTICSEARCH_URL/_transform/simple-kibana-ecomm-pivot/_update\"" + }, + { + "language": "Java", + "code": "client.transform().updateTransform(u -> u\n .description(\"Maximum priced ecommerce data by customer_id in Asia\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform1\")\n .pipeline(\"add_timestamp_pipeline\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .retentionPolicy(r -> r\n .time(t -> t\n .field(\"order_date\")\n .maxAge(m -> m\n .time(\"30d\")\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n .query(q -> q\n .term(te -> te\n .field(\"geoip.continent_name\")\n .value(FieldValue.of(\"Asia\"))\n )\n )\n )\n .sync(sy -> sy\n .time(ti -> ti\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"simple-kibana-ecomm-pivot\")\n);\n" + } + ], + "specification/transform/reset_transform/examples/request/TransformResetTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.reset_transform(\n transform_id=\"ecommerce_transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.resetTransform({\n transform_id: \"ecommerce_transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.reset_transform(\n transform_id: \"ecommerce_transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->resetTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_reset\"" + }, + { + "language": "Java", + "code": "client.transform().resetTransform(r -> r\n .transformId(\"ecommerce_transform\")\n);\n" + } + ], + "specification/transform/stop_transform/examples/request/TransformStopTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.stop_transform(\n transform_id=\"ecommerce_transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.stopTransform({\n transform_id: \"ecommerce_transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.stop_transform(\n transform_id: \"ecommerce_transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->stopTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_stop\"" + }, + { + "language": "Java", + "code": "client.transform().stopTransform(s -> s\n .transformId(\"ecommerce_transform\")\n);\n" + } + ], + "specification/transform/get_transform_stats/examples/request/TransformGetTransformStatsExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.get_transform_stats(\n transform_id=\"ecommerce-customer-transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.getTransformStats({\n transform_id: \"ecommerce-customer-transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.get_transform_stats(\n transform_id: \"ecommerce-customer-transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->getTransformStats([\n \"transform_id\" => \"ecommerce-customer-transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce-customer-transform/_stats\"" + }, + { + "language": "Java", + "code": "client.transform().getTransformStats(g -> g\n .transformId(\"ecommerce-customer-transform\")\n);\n" + } + ], + "specification/transform/delete_transform/examples/request/TransformDeleteTransformExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.transform.delete_transform(\n transform_id=\"ecommerce_transform\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.transform.deleteTransform({\n transform_id: \"ecommerce_transform\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.transform.delete_transform(\n transform_id: \"ecommerce_transform\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->transform()->deleteTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform\"" + }, + { + "language": "Java", + "code": "client.transform().deleteTransform(d -> d\n .transformId(\"ecommerce_transform\")\n);\n" + } + ], + "specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.forget_follower(\n index=\"\",\n follower_cluster=\"\",\n follower_index=\"\",\n follower_index_uuid=\"\",\n leader_remote_cluster=\"\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.forgetFollower({\n index: \"\",\n follower_cluster: \"\",\n follower_index: \"\",\n follower_index_uuid: \"\",\n leader_remote_cluster: \"\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.forget_follower(\n index: \"\",\n body: {\n \"follower_cluster\": \"\",\n \"follower_index\": \"\",\n \"follower_index_uuid\": \"\",\n \"leader_remote_cluster\": \"\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->forgetFollower([\n \"index\" => \"\",\n \"body\" => [\n \"follower_cluster\" => \"\",\n \"follower_index\" => \"\",\n \"follower_index_uuid\" => \"\",\n \"leader_remote_cluster\" => \"\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"follower_cluster\":\"\",\"follower_index\":\"\",\"follower_index_uuid\":\"\",\"leader_remote_cluster\":\"\"}' \"$ELASTICSEARCH_URL//_ccr/forget_follower\"" + }, + { + "language": "Java", + "code": "client.ccr().forgetFollower(f -> f\n .followerCluster(\"\")\n .followerIndex(\"\")\n .followerIndexUuid(\"\")\n .index(\"\")\n .leaderRemoteCluster(\"\")\n);\n" + } + ], + "specification/ccr/delete_auto_follow_pattern/examples/request/DeleteAutoFollowPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.delete_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.deleteAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.delete_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->deleteAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" + }, + { + "language": "Java", + "code": "client.ccr().deleteAutoFollowPattern(d -> d\n .name(\"my_auto_follow_pattern\")\n);\n" + } + ], + "specification/ccr/resume_auto_follow_pattern/examples/request/ResumeAutoFollowPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.resume_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.resumeAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.resume_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->resumeAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern/resume\"" + }, + { + "language": "Java", + "code": "client.ccr().resumeAutoFollowPattern(r -> r\n .name(\"my_auto_follow_pattern\")\n);\n" + } + ], + "specification/ccr/pause_follow/examples/request/PauseFollowIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.pause_follow(\n index=\"follower_index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.pauseFollow({\n index: \"follower_index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.pause_follow(\n index: \"follower_index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->pauseFollow([\n \"index\" => \"follower_index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/pause_follow\"" + }, + { + "language": "Java", + "code": "client.ccr().pauseFollow(p -> p\n .index(\"follower_index\")\n);\n" + } + ], + "specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.follow(\n index=\"follower_index\",\n wait_for_active_shards=\"1\",\n remote_cluster=\"remote_cluster\",\n leader_index=\"leader_index\",\n settings={\n \"index.number_of_replicas\": 0\n },\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.follow({\n index: \"follower_index\",\n wait_for_active_shards: 1,\n remote_cluster: \"remote_cluster\",\n leader_index: \"leader_index\",\n settings: {\n \"index.number_of_replicas\": 0,\n },\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.follow(\n index: \"follower_index\",\n wait_for_active_shards: \"1\",\n body: {\n \"remote_cluster\": \"remote_cluster\",\n \"leader_index\": \"leader_index\",\n \"settings\": {\n \"index.number_of_replicas\": 0\n },\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->follow([\n \"index\" => \"follower_index\",\n \"wait_for_active_shards\" => \"1\",\n \"body\" => [\n \"remote_cluster\" => \"remote_cluster\",\n \"leader_index\" => \"leader_index\",\n \"settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_cluster\":\"remote_cluster\",\"leader_index\":\"leader_index\",\"settings\":{\"index.number_of_replicas\":0},\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/follow?wait_for_active_shards=1\"" + }, + { + "language": "Java", + "code": "client.ccr().follow(f -> f\n .index(\"follower_index\")\n .leaderIndex(\"leader_index\")\n .maxOutstandingReadRequests(16L)\n .maxOutstandingWriteRequests(8)\n .maxReadRequestOperationCount(1024)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768)\n .maxWriteRequestSize(\"16k\")\n .readPollTimeout(r -> r\n .time(\"30s\")\n )\n .remoteCluster(\"remote_cluster\")\n .settings(s -> s\n .otherSettings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n )\n .waitForActiveShards(w -> w\n .count(1)\n )\n);\n" + } + ], + "specification/ccr/get_auto_follow_pattern/examples/request/GetAutoFollowPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.get_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.getAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.get_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->getAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" + }, + { + "language": "Java", + "code": "client.ccr().getAutoFollowPattern(g -> g\n .name(\"my_auto_follow_pattern\")\n);\n" + } + ], + "specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.put_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n remote_cluster=\"remote_cluster\",\n leader_index_patterns=[\n \"leader_index*\"\n ],\n follow_index_pattern=\"{{leader_index}}-follower\",\n settings={\n \"index.number_of_replicas\": 0\n },\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.putAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n remote_cluster: \"remote_cluster\",\n leader_index_patterns: [\"leader_index*\"],\n follow_index_pattern: \"{{leader_index}}-follower\",\n settings: {\n \"index.number_of_replicas\": 0,\n },\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.put_auto_follow_pattern(\n name: \"my_auto_follow_pattern\",\n body: {\n \"remote_cluster\": \"remote_cluster\",\n \"leader_index_patterns\": [\n \"leader_index*\"\n ],\n \"follow_index_pattern\": \"{{leader_index}}-follower\",\n \"settings\": {\n \"index.number_of_replicas\": 0\n },\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->putAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n \"body\" => [\n \"remote_cluster\" => \"remote_cluster\",\n \"leader_index_patterns\" => array(\n \"leader_index*\",\n ),\n \"follow_index_pattern\" => \"{{leader_index}}-follower\",\n \"settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_cluster\":\"remote_cluster\",\"leader_index_patterns\":[\"leader_index*\"],\"follow_index_pattern\":\"{{leader_index}}-follower\",\"settings\":{\"index.number_of_replicas\":0},\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" + }, + { + "language": "Java", + "code": "client.ccr().putAutoFollowPattern(p -> p\n .followIndexPattern(\"{{leader_index}}-follower\")\n .leaderIndexPatterns(\"leader_index*\")\n .maxOutstandingReadRequests(16)\n .maxOutstandingWriteRequests(8)\n .maxReadRequestOperationCount(1024)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768)\n .maxWriteRequestSize(\"16k\")\n .name(\"my_auto_follow_pattern\")\n .readPollTimeout(r -> r\n .time(\"30s\")\n )\n .remoteCluster(\"remote_cluster\")\n .settings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n);\n" + } + ], + "specification/ccr/follow_info/examples/request/FollowInfoRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.follow_info(\n index=\"follower_index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.followInfo({\n index: \"follower_index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.follow_info(\n index: \"follower_index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->followInfo([\n \"index\" => \"follower_index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/info\"" + }, + { + "language": "Java", + "code": "client.ccr().followInfo(f -> f\n .index(\"follower_index\")\n);\n" + } + ], + "specification/ccr/unfollow/examples/request/UnfollowIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.unfollow(\n index=\"follower_index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.unfollow({\n index: \"follower_index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.unfollow(\n index: \"follower_index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->unfollow([\n \"index\" => \"follower_index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/unfollow\"" + }, + { + "language": "Java", + "code": "client.ccr().unfollow(u -> u\n .index(\"follower_index\")\n);\n" + } + ], + "specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.resume_follow(\n index=\"follower_index\",\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.resumeFollow({\n index: \"follower_index\",\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.resume_follow(\n index: \"follower_index\",\n body: {\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->resumeFollow([\n \"index\" => \"follower_index\",\n \"body\" => [\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/resume_follow\"" + }, + { + "language": "Java", + "code": "client.ccr().resumeFollow(r -> r\n .index(\"follower_index\")\n .maxOutstandingReadRequests(16L)\n .maxOutstandingWriteRequests(8L)\n .maxReadRequestOperationCount(1024L)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512L)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768L)\n .maxWriteRequestSize(\"16k\")\n .readPollTimeout(re -> re\n .time(\"30s\")\n )\n);\n" + } + ], + "specification/ccr/follow_stats/examples/request/FollowIndexStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.follow_stats(\n index=\"follower_index\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.followStats({\n index: \"follower_index\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.follow_stats(\n index: \"follower_index\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->followStats([\n \"index\" => \"follower_index\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/stats\"" + }, + { + "language": "Java", + "code": "client.ccr().followStats(f -> f\n .index(\"follower_index\")\n);\n" + } + ], + "specification/ccr/stats/examples/request/CcrStatsRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.stats()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.stats();" + }, + { + "language": "Ruby", + "code": "response = client.ccr.stats" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->stats();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/stats\"" + }, + { + "language": "Java", + "code": "client.ccr().stats(s -> s);\n" + } + ], + "specification/ccr/pause_auto_follow_pattern/examples/request/PauseAutoFollowPatternRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ccr.pause_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ccr.pauseAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ccr.pause_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ccr()->pauseAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern/pause\"" + }, + { + "language": "Java", + "code": "client.ccr().pauseAutoFollowPattern(p -> p\n .name(\"my_auto_follow_pattern\")\n);\n" + } + ], + "specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.get_status()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.getStatus();" + }, + { + "language": "Ruby", + "code": "response = client.ilm.get_status" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->getStatus();" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/status\"" + }, + { + "language": "Java", + "code": "client.ilm().getStatus();\n" + } + ], + "specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.move_to_step(\n index=\"my-index-000001\",\n current_step={\n \"phase\": \"new\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n next_step={\n \"phase\": \"warm\",\n \"action\": \"forcemerge\",\n \"name\": \"forcemerge\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.moveToStep({\n index: \"my-index-000001\",\n current_step: {\n phase: \"new\",\n action: \"complete\",\n name: \"complete\",\n },\n next_step: {\n phase: \"warm\",\n action: \"forcemerge\",\n name: \"forcemerge\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.move_to_step(\n index: \"my-index-000001\",\n body: {\n \"current_step\": {\n \"phase\": \"new\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n \"next_step\": {\n \"phase\": \"warm\",\n \"action\": \"forcemerge\",\n \"name\": \"forcemerge\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->moveToStep([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"current_step\" => [\n \"phase\" => \"new\",\n \"action\" => \"complete\",\n \"name\" => \"complete\",\n ],\n \"next_step\" => [\n \"phase\" => \"warm\",\n \"action\" => \"forcemerge\",\n \"name\" => \"forcemerge\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"current_step\":{\"phase\":\"new\",\"action\":\"complete\",\"name\":\"complete\"},\"next_step\":{\"phase\":\"warm\",\"action\":\"forcemerge\",\"name\":\"forcemerge\"}}' \"$ELASTICSEARCH_URL/_ilm/move/my-index-000001\"" + }, + { + "language": "Java", + "code": "client.ilm().moveToStep(m -> m\n .currentStep(c -> c\n .action(\"complete\")\n .name(\"complete\")\n .phase(\"new\")\n )\n .index(\"my-index-000001\")\n .nextStep(n -> n\n .action(\"forcemerge\")\n .name(\"forcemerge\")\n .phase(\"warm\")\n )\n);\n" + } + ], + "specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.move_to_step(\n index=\"my-index-000001\",\n current_step={\n \"phase\": \"hot\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n next_step={\n \"phase\": \"warm\"\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.moveToStep({\n index: \"my-index-000001\",\n current_step: {\n phase: \"hot\",\n action: \"complete\",\n name: \"complete\",\n },\n next_step: {\n phase: \"warm\",\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.move_to_step(\n index: \"my-index-000001\",\n body: {\n \"current_step\": {\n \"phase\": \"hot\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n \"next_step\": {\n \"phase\": \"warm\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->moveToStep([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"current_step\" => [\n \"phase\" => \"hot\",\n \"action\" => \"complete\",\n \"name\" => \"complete\",\n ],\n \"next_step\" => [\n \"phase\" => \"warm\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"current_step\":{\"phase\":\"hot\",\"action\":\"complete\",\"name\":\"complete\"},\"next_step\":{\"phase\":\"warm\"}}' \"$ELASTICSEARCH_URL/_ilm/move/my-index-000001\"" + }, + { + "language": "Java", + "code": "client.ilm().moveToStep(m -> m\n .currentStep(c -> c\n .action(\"complete\")\n .name(\"complete\")\n .phase(\"hot\")\n )\n .index(\"my-index-000001\")\n .nextStep(n -> n\n .phase(\"warm\")\n )\n);\n" + } + ], + "specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.migrate_to_data_tiers(\n legacy_template_to_delete=\"global-template\",\n node_attribute=\"custom_attribute_name\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.migrateToDataTiers({\n legacy_template_to_delete: \"global-template\",\n node_attribute: \"custom_attribute_name\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.migrate_to_data_tiers(\n body: {\n \"legacy_template_to_delete\": \"global-template\",\n \"node_attribute\": \"custom_attribute_name\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->migrateToDataTiers([\n \"body\" => [\n \"legacy_template_to_delete\" => \"global-template\",\n \"node_attribute\" => \"custom_attribute_name\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"legacy_template_to_delete\":\"global-template\",\"node_attribute\":\"custom_attribute_name\"}' \"$ELASTICSEARCH_URL/_ilm/migrate_to_data_tiers\"" + }, + { + "language": "Java", + "code": "client.ilm().migrateToDataTiers(m -> m\n .legacyTemplateToDelete(\"global-template\")\n .nodeAttribute(\"custom_attribute_name\")\n);\n" + } + ], + "specification/ilm/retry/examples/request/IlmRetryExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.retry(\n index=\"my-index-000001\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.retry({\n index: \"my-index-000001\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.retry(\n index: \"my-index-000001\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->retry([\n \"index\" => \"my-index-000001\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_ilm/retry\"" + }, + { + "language": "Java", + "code": "client.ilm().retry(r -> r\n .index(\"my-index-000001\")\n);\n" + } + ], + "specification/ilm/delete_lifecycle/examples/request/IlmDeleteLifecycleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.delete_lifecycle(\n name=\"my_policy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.deleteLifecycle({\n name: \"my_policy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.delete_lifecycle(\n policy: \"my_policy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->deleteLifecycle([\n \"policy\" => \"my_policy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" + }, + { + "language": "Java", + "code": "client.ilm().deleteLifecycle(d -> d\n .name(\"my_policy\")\n);\n" + } + ], + "specification/ilm/start/examples/request/IlmStartExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.start()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.start();" + }, + { + "language": "Ruby", + "code": "response = client.ilm.start" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->start();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/start\"" + }, + { + "language": "Java", + "code": "client.ilm().start(s -> s);\n" + } + ], + "specification/ilm/explain_lifecycle/examples/request/IlmExplainLifecycleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.explain_lifecycle(\n index=\".ds-timeseries-*\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.explainLifecycle({\n index: \".ds-timeseries-*\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.explain_lifecycle(\n index: \".ds-timeseries-*\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->explainLifecycle([\n \"index\" => \".ds-timeseries-*\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-timeseries-*/_ilm/explain\"" + }, + { + "language": "Java", + "code": "client.ilm().explainLifecycle(e -> e\n .index(\".ds-timeseries-*\")\n);\n" + } + ], + "specification/ilm/stop/examples/request/IlmStopExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.stop()" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.stop();" + }, + { + "language": "Ruby", + "code": "response = client.ilm.stop" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->stop();" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/stop\"" + }, + { + "language": "Java", + "code": "client.ilm().stop(s -> s);\n" + } + ], + "specification/ilm/remove_policy/examples/request/IlmRemovePolicyExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.remove_policy(\n index=\"logs-my_app-default\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.removePolicy({\n index: \"logs-my_app-default\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.remove_policy(\n index: \"logs-my_app-default\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->removePolicy([\n \"index\" => \"logs-my_app-default\",\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/logs-my_app-default/_ilm/remove\"" + }, + { + "language": "Java", + "code": "client.ilm().removePolicy(r -> r\n .index(\"logs-my_app-default\")\n);\n" + } + ], + "specification/ilm/get_lifecycle/examples/request/IlmGetLifecycleExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.get_lifecycle(\n name=\"my_policy\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.getLifecycle({\n name: \"my_policy\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.get_lifecycle(\n policy: \"my_policy\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->getLifecycle([\n \"policy\" => \"my_policy\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" + }, + { + "language": "Java", + "code": "client.ilm().getLifecycle(g -> g\n .name(\"my_policy\")\n);\n" + } + ], + "specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.ilm.put_lifecycle(\n name=\"my_policy\",\n policy={\n \"_meta\": {\n \"description\": \"used for nginx log\",\n \"project\": {\n \"name\": \"myProject\",\n \"department\": \"myDepartment\"\n }\n },\n \"phases\": {\n \"warm\": {\n \"min_age\": \"10d\",\n \"actions\": {\n \"forcemerge\": {\n \"max_num_segments\": 1\n }\n }\n },\n \"delete\": {\n \"min_age\": \"30d\",\n \"actions\": {\n \"delete\": {}\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.ilm.putLifecycle({\n name: \"my_policy\",\n policy: {\n _meta: {\n description: \"used for nginx log\",\n project: {\n name: \"myProject\",\n department: \"myDepartment\",\n },\n },\n phases: {\n warm: {\n min_age: \"10d\",\n actions: {\n forcemerge: {\n max_num_segments: 1,\n },\n },\n },\n delete: {\n min_age: \"30d\",\n actions: {\n delete: {},\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.ilm.put_lifecycle(\n policy: \"my_policy\",\n body: {\n \"policy\": {\n \"_meta\": {\n \"description\": \"used for nginx log\",\n \"project\": {\n \"name\": \"myProject\",\n \"department\": \"myDepartment\"\n }\n },\n \"phases\": {\n \"warm\": {\n \"min_age\": \"10d\",\n \"actions\": {\n \"forcemerge\": {\n \"max_num_segments\": 1\n }\n }\n },\n \"delete\": {\n \"min_age\": \"30d\",\n \"actions\": {\n \"delete\": {}\n }\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->ilm()->putLifecycle([\n \"policy\" => \"my_policy\",\n \"body\" => [\n \"policy\" => [\n \"_meta\" => [\n \"description\" => \"used for nginx log\",\n \"project\" => [\n \"name\" => \"myProject\",\n \"department\" => \"myDepartment\",\n ],\n ],\n \"phases\" => [\n \"warm\" => [\n \"min_age\" => \"10d\",\n \"actions\" => [\n \"forcemerge\" => [\n \"max_num_segments\" => 1,\n ],\n ],\n ],\n \"delete\" => [\n \"min_age\" => \"30d\",\n \"actions\" => [\n \"delete\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"policy\":{\"_meta\":{\"description\":\"used for nginx log\",\"project\":{\"name\":\"myProject\",\"department\":\"myDepartment\"}},\"phases\":{\"warm\":{\"min_age\":\"10d\",\"actions\":{\"forcemerge\":{\"max_num_segments\":1}}},\"delete\":{\"min_age\":\"30d\",\"actions\":{\"delete\":{}}}}}}' \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" + }, + { + "language": "Java", + "code": "client.ilm().putLifecycle(p -> p\n .name(\"my_policy\")\n .policy(po -> po\n .phases(ph -> ph\n .delete(d -> d\n .actions(a -> a\n .delete(de -> de)\n )\n .minAge(m -> m\n .time(\"30d\")\n )\n )\n .warm(w -> w\n .actions(a -> a\n .forcemerge(f -> f\n .maxNumSegments(1)\n )\n )\n .minAge(m -> m\n .time(\"10d\")\n )\n )\n )\n .meta(Map.of(\"description\", JsonData.fromJson(\"\\\"used for nginx log\\\"\"),\"project\", JsonData.fromJson(\"{\\\"name\\\":\\\"myProject\\\",\\\"department\\\":\\\"myDepartment\\\"}\")))\n )\n);\n" + } + ], + "specification/sql/delete_async/examples/request/SqlDeleteAsyncExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.delete_async(\n id=\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.deleteAsync({\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.delete_async(\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->deleteAsync([\n \"id\" => \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/delete/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"" + }, + { + "language": "Java", + "code": "client.sql().deleteAsync(d -> d\n .id(\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\")\n);\n" + } + ], + "specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.translate(\n query=\"SELECT * FROM library ORDER BY page_count DESC\",\n fetch_size=10,\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.translate({\n query: \"SELECT * FROM library ORDER BY page_count DESC\",\n fetch_size: 10,\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.translate(\n body: {\n \"query\": \"SELECT * FROM library ORDER BY page_count DESC\",\n \"fetch_size\": 10\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->translate([\n \"body\" => [\n \"query\" => \"SELECT * FROM library ORDER BY page_count DESC\",\n \"fetch_size\" => 10,\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"SELECT * FROM library ORDER BY page_count DESC\",\"fetch_size\":10}' \"$ELASTICSEARCH_URL/_sql/translate\"" + }, + { + "language": "Java", + "code": "client.sql().translate(t -> t\n .fetchSize(10)\n .query(\"SELECT * FROM library ORDER BY page_count DESC\")\n);\n" + } + ], + "specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.clear_cursor(\n cursor=\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.clearCursor({\n cursor:\n \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.clear_cursor(\n body: {\n \"cursor\": \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->clearCursor([\n \"body\" => [\n \"cursor\" => \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cursor\":\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\"}' \"$ELASTICSEARCH_URL/_sql/close\"" + }, + { + "language": "Java", + "code": "client.sql().clearCursor(c -> c\n .cursor(\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\")\n);\n" + } + ], + "specification/sql/get_async/examples/request/SqlGetAsyncExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.get_async(\n id=\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout=\"2s\",\n format=\"json\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.getAsync({\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout: \"2s\",\n format: \"json\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.get_async(\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout: \"2s\",\n format: \"json\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->getAsync([\n \"id\" => \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n \"wait_for_completion_timeout\" => \"2s\",\n \"format\" => \"json\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=?wait_for_completion_timeout=2s&format=json\"" + }, + { + "language": "Java", + "code": "client.sql().getAsync(g -> g\n .format(\"json\")\n .id(\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\")\n .waitForCompletionTimeout(w -> w\n .offset(2)\n )\n);\n" + } + ], + "specification/sql/get_async_status/examples/request/SqlGetAsyncStatusExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.get_async_status(\n id=\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.getAsyncStatus({\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.get_async_status(\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\"\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->getAsyncStatus([\n \"id\" => \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/status/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\"" + }, + { + "language": "Java", + "code": "client.sql().getAsyncStatus(g -> g\n .id(\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\")\n);\n" + } + ], + "specification/sql/query/examples/request/QuerySqlRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.sql.query(\n format=\"txt\",\n query=\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.sql.query({\n format: \"txt\",\n query: \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.sql.query(\n format: \"txt\",\n body: {\n \"query\": \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\"\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->sql()->query([\n \"format\" => \"txt\",\n \"body\" => [\n \"query\" => \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\"}' \"$ELASTICSEARCH_URL/_sql?format=txt\"" + }, + { + "language": "Java", + "code": "client.sql().query(q -> q\n .format(SqlFormat.Txt)\n .query(\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\")\n);\n" + } + ], + "specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.cluster.allocation_explain(\n index=\"my-index-000001\",\n shard=\"0\",\n primary=False,\n current_node=\"my-node\",\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.cluster.allocationExplain({\n index: \"my-index-000001\",\n shard: 0,\n primary: \"false\",\n current_node: \"my-node\",\n});" + }, + { + "language": "Ruby", + "code": "response = client.cluster.allocation_explain(\n index: \"my-index-000001\",\n shard: \"0\",\n primary: \"false\",\n current_node: \"my-node\",\n body: {}\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->cluster()->allocationExplain([\n \"index\" => \"my-index-000001\",\n \"shard\" => \"0\",\n \"primary\" => \"false\",\n \"current_node\" => \"my-node\",\n \"body\" => new ArrayObject([]),\n]);" + }, + { + "language": "curl", + "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{}' \"$ELASTICSEARCH_URL/_cluster/allocation/explain?index=my-index-000001&shard=0&primary=false¤t_node=my-node\"" + }, + { + "language": "Java", + "code": "client.cluster().allocationExplain(a -> a\n .currentNode(\"my-node\")\n .index(\"my-index-000001\")\n .primary(false)\n .shard(0)\n);\n" + } + ], + "specification/inference/put_cohere/examples/request/PutCohereRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"cohere-completion\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"command-a-03-2025\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"cohere-completion\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-API-key\",\n model_id: \"command-a-03-2025\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"cohere-completion\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"command-a-03-2025\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"cohere-completion\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-API-key\",\n \"model_id\" => \"command-a-03-2025\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-API-key\",\"model_id\":\"command-a-03-2025\"}}' \"$ELASTICSEARCH_URL/_inference/completion/cohere-completion\"" + } + ], + "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"amazon_sagemaker_embeddings\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\",\n \"dimensions\": 384,\n \"element_type\": \"float\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"amazon_sagemaker_embeddings\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n dimensions: 384,\n element_type: \"float\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"amazon_sagemaker_embeddings\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\",\n \"dimensions\": 384,\n \"element_type\": \"float\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"amazon_sagemaker_embeddings\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n \"dimensions\" => 384,\n \"element_type\" => \"float\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\",\"dimensions\":384,\"element_type\":\"float\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/amazon_sagemaker_embeddings\"" + } + ], + "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"amazon_sagemaker_completion\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"amazon_sagemaker_completion\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"amazon_sagemaker_completion\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"amazon_sagemaker_completion\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/completion/amazon_sagemaker_completion\"" + } + ], + "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"chat_completion\",\n inference_id=\"amazon_sagemaker_chat_completion\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"chat_completion\",\n inference_id: \"amazon_sagemaker_chat_completion\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"chat_completion\",\n inference_id: \"amazon_sagemaker_chat_completion\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"chat_completion\",\n \"inference_id\" => \"amazon_sagemaker_chat_completion\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/chat_completion/amazon_sagemaker_chat_completion\"" + } + ], + "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"amazon_sagemaker_sparse_embedding\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"amazon_sagemaker_sparse_embedding\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"amazon_sagemaker_sparse_embedding\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"amazon_sagemaker_sparse_embedding\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/amazon_sagemaker_sparse_embedding\"" + } + ], + "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"amazon_sagemaker_rerank\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"amazon_sagemaker_rerank\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"amazon_sagemaker_rerank\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"amazon_sagemaker_rerank\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/amazon_sagemaker_rerank\"" + } + ], + "specification/inference/put_ai21/examples/request/PutAi21RequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"ai21-completion\",\n inference_config={\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-large\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"ai21-completion\",\n inference_config: {\n service: \"ai21\",\n service_settings: {\n api_key: \"ai21-api-key\",\n model_id: \"jamba-large\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"ai21-completion\",\n body: {\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-large\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"ai21-completion\",\n \"body\" => [\n \"service\" => \"ai21\",\n \"service_settings\" => [\n \"api_key\" => \"ai21-api-key\",\n \"model_id\" => \"jamba-large\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"ai21\",\"service_settings\":{\"api_key\":\"ai21-api-key\",\"model_id\":\"jamba-large\"}}' \"$ELASTICSEARCH_URL/_inference/completion/ai21-completion\"" + } + ], + "specification/inference/put_ai21/examples/request/PutAi21RequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"chat-completion\",\n inference_id=\"ai21-chat-completion\",\n inference_config={\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-mini\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"chat-completion\",\n inference_id: \"ai21-chat-completion\",\n inference_config: {\n service: \"ai21\",\n service_settings: {\n api_key: \"ai21-api-key\",\n model_id: \"jamba-mini\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"chat-completion\",\n inference_id: \"ai21-chat-completion\",\n body: {\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-mini\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"chat-completion\",\n \"inference_id\" => \"ai21-chat-completion\",\n \"body\" => [\n \"service\" => \"ai21\",\n \"service_settings\" => [\n \"api_key\" => \"ai21-api-key\",\n \"model_id\" => \"jamba-mini\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"ai21\",\"service_settings\":{\"api_key\":\"ai21-api-key\",\"model_id\":\"jamba-mini\"}}' \"$ELASTICSEARCH_URL/_inference/chat-completion/ai21-chat-completion\"" + } + ], + "specification/inference/put_custom/examples/request/PutCustomRequestExample1.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-embeddings\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.openai.com/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\"\n },\n \"request\": \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-embeddings\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.openai.com/v1/embeddings\",\n headers: {\n Authorization: \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\",\n },\n request: '{\"input\": ${input}, \"model\": \"text-embedding-3-small\"}',\n response: {\n json_parser: {\n text_embeddings: \"$.data[*].embedding[*]\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-embeddings\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.openai.com/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\"\n },\n \"request\": \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-embeddings\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.openai.com/v1/embeddings\",\n \"headers\" => [\n \"Authorization\" => \"Bearer ${api_key}\",\n \"Content-Type\" => \"application/json;charset=utf-8\",\n ],\n \"request\" => \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.data[*].embedding[*]\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.openai.com/v1/embeddings\",\"headers\":{\"Authorization\":\"Bearer ${api_key}\",\"Content-Type\":\"application/json;charset=utf-8\"},\"request\":\"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.data[*].embedding[*]\"}}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-embeddings\"" + } + ], + "specification/inference/put_custom/examples/request/PutCustomRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-text-embedding\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/embed\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.embeddings.float[*]\"\n }\n },\n \"input_type\": {\n \"translation\": {\n \"ingest\": \"search_document\",\n \"search\": \"search_query\"\n },\n \"default\": \"search_document\"\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.cohere.com/v2/embed\",\n headers: {\n Authorization: \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request:\n '{\"texts\": ${input}, \"model\": \"embed-v4.0\", \"input_type\": ${input_type}}',\n response: {\n json_parser: {\n text_embeddings: \"$.embeddings.float[*]\",\n },\n },\n input_type: {\n translation: {\n ingest: \"search_document\",\n search: \"search_query\",\n },\n default: \"search_document\",\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/embed\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.embeddings.float[*]\"\n }\n },\n \"input_type\": {\n \"translation\": {\n \"ingest\": \"search_document\",\n \"search\": \"search_query\"\n },\n \"default\": \"search_document\"\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-text-embedding\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.cohere.com/v2/embed\",\n \"headers\" => [\n \"Authorization\" => \"bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.embeddings.float[*]\",\n ],\n ],\n \"input_type\" => [\n \"translation\" => [\n \"ingest\" => \"search_document\",\n \"search\" => \"search_query\",\n ],\n \"default\" => \"search_document\",\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.cohere.com/v2/embed\",\"headers\":{\"Authorization\":\"bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.embeddings.float[*]\"}},\"input_type\":{\"translation\":{\"ingest\":\"search_document\",\"search\":\"search_query\"},\"default\":\"search_document\"}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-text-embedding\"" + } + ], + "specification/inference/put_custom/examples/request/PutCustomRequestExample2.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"custom-rerank\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/rerank\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"reranked_index\": \"$.results[*].index\",\n \"relevance_score\": \"$.results[*].relevance_score\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"custom-rerank\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.cohere.com/v2/rerank\",\n headers: {\n Authorization: \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request:\n '{\"documents\": ${input}, \"query\": ${query}, \"model\": \"rerank-v3.5\"}',\n response: {\n json_parser: {\n reranked_index: \"$.results[*].index\",\n relevance_score: \"$.results[*].relevance_score\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"custom-rerank\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/rerank\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"reranked_index\": \"$.results[*].index\",\n \"relevance_score\": \"$.results[*].relevance_score\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"custom-rerank\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.cohere.com/v2/rerank\",\n \"headers\" => [\n \"Authorization\" => \"bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\" => [\n \"json_parser\" => [\n \"reranked_index\" => \"$.results[*].index\",\n \"relevance_score\" => \"$.results[*].relevance_score\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.cohere.com/v2/rerank\",\"headers\":{\"Authorization\":\"bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\"response\":{\"json_parser\":{\"reranked_index\":\"$.results[*].index\",\"relevance_score\":\"$.results[*].relevance_score\"}}}}' \"$ELASTICSEARCH_URL/_inference/rerank/custom-rerank\"" + } + ], + "specification/inference/put_custom/examples/request/PutCustomRequestExample5.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-text-embedding-hf\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"input\\\": ${input}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding-hf\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"/v1/embeddings\",\n headers: {\n Authorization: \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request: '{\"input\": ${input}}',\n response: {\n json_parser: {\n text_embeddings: \"$.data[*].embedding[*]\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding-hf\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"input\\\": ${input}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-text-embedding-hf\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"/v1/embeddings\",\n \"headers\" => [\n \"Authorization\" => \"Bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"input\\\": ${input}}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.data[*].embedding[*]\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"/v1/embeddings\",\"headers\":{\"Authorization\":\"Bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"input\\\": ${input}}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.data[*].embedding[*]\"}}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-text-embedding-hf\"" + } + ], + "specification/inference/put_custom/examples/request/PutCustomRequestExample4.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"custom-rerank-jina\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.jina.ai/v1/rerank\",\n \"headers\": {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${api_key}\"\n },\n \"request\": \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\": {\n \"json_parser\": {\n \"relevance_score\": \"$.results[*].relevance_score\",\n \"reranked_index\": \"$.results[*].index\"\n }\n }\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"custom-rerank-jina\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.jina.ai/v1/rerank\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: \"Bearer ${api_key}\",\n },\n request:\n '{\"model\": \"jina-reranker-v2-base-multilingual\",\"query\": ${query},\"documents\":${input}}',\n response: {\n json_parser: {\n relevance_score: \"$.results[*].relevance_score\",\n reranked_index: \"$.results[*].index\",\n },\n },\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"custom-rerank-jina\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.jina.ai/v1/rerank\",\n \"headers\": {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${api_key}\"\n },\n \"request\": \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\": {\n \"json_parser\": {\n \"relevance_score\": \"$.results[*].relevance_score\",\n \"reranked_index\": \"$.results[*].index\"\n }\n }\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"custom-rerank-jina\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.jina.ai/v1/rerank\",\n \"headers\" => [\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer ${api_key}\",\n ],\n \"request\" => \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\" => [\n \"json_parser\" => [\n \"relevance_score\" => \"$.results[*].relevance_score\",\n \"reranked_index\" => \"$.results[*].index\",\n ],\n ],\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.jina.ai/v1/rerank\",\"headers\":{\"Content-Type\":\"application/json\",\"Authorization\":\"Bearer ${api_key}\"},\"request\":\"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\"response\":{\"json_parser\":{\"relevance_score\":\"$.results[*].relevance_score\",\"reranked_index\":\"$.results[*].index\"}}}}' \"$ELASTICSEARCH_URL/_inference/rerank/custom-rerank-jina\"" + } + ], + "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample3.yaml": [ + { + "language": "Python", + "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"azure_ai_studio_rerank\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"cohere\",\n \"endpoint_type\": \"token\"\n }\n },\n)" + }, + { + "language": "JavaScript", + "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"azure_ai_studio_rerank\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-URI\",\n provider: \"cohere\",\n endpoint_type: \"token\",\n },\n },\n});" + }, + { + "language": "Ruby", + "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"azure_ai_studio_rerank\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"cohere\",\n \"endpoint_type\": \"token\"\n }\n }\n)" + }, + { + "language": "PHP", + "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"azure_ai_studio_rerank\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-URI\",\n \"provider\" => \"cohere\",\n \"endpoint_type\" => \"token\",\n ],\n ],\n]);" + }, + { + "language": "curl", + "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"provider\":\"cohere\",\"endpoint_type\":\"token\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/azure_ai_studio_rerank\"" + } + ] +} \ No newline at end of file diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index e4f18ab0f8..cbe675382d 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -42322,8 +42322,8 @@ } } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "GET /_snapshot/my_repository/snapshot_*?sort=start_time&from_sort_value=1577833200000\n" @@ -42362,8 +42362,8 @@ "$ref": "#/components/responses/snapshot.create-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n}" @@ -42402,8 +42402,8 @@ "$ref": "#/components/responses/snapshot.create-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n}" @@ -42501,8 +42501,8 @@ "$ref": "#/components/responses/snapshot.get_repository-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "GET /_snapshot/my_repository\n" @@ -42541,8 +42541,8 @@ "$ref": "#/components/responses/snapshot.create_repository-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository\n{\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n}" @@ -42581,8 +42581,8 @@ "$ref": "#/components/responses/snapshot.create_repository-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository\n{\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n}" @@ -42641,8 +42641,8 @@ } } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "DELETE /_snapshot/my_repository\n" @@ -42671,8 +42671,8 @@ "$ref": "#/components/responses/snapshot.get_repository-200" } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "GET /_snapshot/my_repository\n" @@ -43088,8 +43088,8 @@ } } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"rename_pattern\": \"index_(.+)\",\n \"rename_replacement\": \"restored_index_$1\",\n \"include_aliases\": false\n}" @@ -43264,8 +43264,8 @@ } } }, - "x-state": "Added in 0.0.0", - "x-codeSamples": [ + "x-state": "Generally available", + "x-metaTags": [ { "lang": "Console", "source": "POST _snapshot/my_unverified_backup/_verify\n" diff --git a/output/schema/schema.json b/output/schema/schema.json index 0f32c3003e..2065b63c4f 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -20684,7 +20684,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -20731,7 +20730,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -20818,7 +20816,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -20859,7 +20856,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -20900,7 +20896,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -21023,7 +21018,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, @@ -21122,7 +21116,6 @@ "visibility": "private" }, "stack": { - "since": "0.0.0", "stability": "stable" } }, diff --git a/specification/snapshot/create/SnapshotCreateRequest.ts b/specification/snapshot/create/SnapshotCreateRequest.ts index 5c7ca93bc9..4e449d47db 100644 --- a/specification/snapshot/create/SnapshotCreateRequest.ts +++ b/specification/snapshot/create/SnapshotCreateRequest.ts @@ -25,7 +25,7 @@ import { Duration } from '@_types/Time' * Create a snapshot. * Take a snapshot of a cluster or of data streams and indices. * @rest_spec_name snapshot.create - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges create_snapshot * @doc_id snapshot-create-api diff --git a/specification/snapshot/create_repository/SnapshotCreateRepositoryRequest.ts b/specification/snapshot/create_repository/SnapshotCreateRepositoryRequest.ts index f1fd161b23..427cbf73a8 100644 --- a/specification/snapshot/create_repository/SnapshotCreateRepositoryRequest.ts +++ b/specification/snapshot/create_repository/SnapshotCreateRepositoryRequest.ts @@ -31,7 +31,7 @@ import { Repository } from '@snapshot/_types/SnapshotRepository' * Several options for this API can be specified using a query parameter or a request body parameter. * If both parameters are specified, only the query parameter is used. * @rest_spec_name snapshot.create_repository - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges manage * @doc_id snapshot-repo-create diff --git a/specification/snapshot/delete_repository/SnapshotDeleteRepositoryRequest.ts b/specification/snapshot/delete_repository/SnapshotDeleteRepositoryRequest.ts index 022e7c6751..19ee50fc3d 100644 --- a/specification/snapshot/delete_repository/SnapshotDeleteRepositoryRequest.ts +++ b/specification/snapshot/delete_repository/SnapshotDeleteRepositoryRequest.ts @@ -26,7 +26,7 @@ import { Duration } from '@_types/Time' * When a repository is unregistered, Elasticsearch removes only the reference to the location where the repository is storing the snapshots. * The snapshots themselves are left untouched and in place. * @rest_spec_name snapshot.delete_repository - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges manage * @doc_id snapshot-repo-delete diff --git a/specification/snapshot/get/SnapshotGetRequest.ts b/specification/snapshot/get/SnapshotGetRequest.ts index 69875f92b6..8f83e496b9 100644 --- a/specification/snapshot/get/SnapshotGetRequest.ts +++ b/specification/snapshot/get/SnapshotGetRequest.ts @@ -31,7 +31,7 @@ import { SnapshotSort } from '@snapshot/_types/SnapshotInfo' * It is guaranteed that any snapshot that exists at the beginning of the iteration and is not concurrently deleted will be seen during the iteration. * Snapshots concurrently created may be seen during an iteration. * @rest_spec_name snapshot.get - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges monitor_snapshot * @doc_id snapshot-get diff --git a/specification/snapshot/get_repository/SnapshotGetRepositoryRequest.ts b/specification/snapshot/get_repository/SnapshotGetRepositoryRequest.ts index c17c9ef80f..7c01fe1fdb 100644 --- a/specification/snapshot/get_repository/SnapshotGetRepositoryRequest.ts +++ b/specification/snapshot/get_repository/SnapshotGetRepositoryRequest.ts @@ -24,7 +24,7 @@ import { Duration } from '@_types/Time' /** * Get snapshot repository information. * @rest_spec_name snapshot.get_repository - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges monitor_snapshot * @doc_id snapshot-repo-get diff --git a/specification/snapshot/restore/SnapshotRestoreRequest.ts b/specification/snapshot/restore/SnapshotRestoreRequest.ts index 2e55e7f6a2..2b5d1ff29d 100644 --- a/specification/snapshot/restore/SnapshotRestoreRequest.ts +++ b/specification/snapshot/restore/SnapshotRestoreRequest.ts @@ -42,7 +42,7 @@ import { IndexSettings } from '@indices/_types/IndexSettings' * * If your snapshot contains data from App Search or Workplace Search, you must restore the Enterprise Search encryption key before you restore the snapshot. * @rest_spec_name snapshot.restore - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges manage * @doc_id snapshot-restore-api diff --git a/specification/snapshot/verify_repository/SnapshotVerifyRepositoryRequest.ts b/specification/snapshot/verify_repository/SnapshotVerifyRepositoryRequest.ts index bd15e40869..b3ac543a90 100644 --- a/specification/snapshot/verify_repository/SnapshotVerifyRepositoryRequest.ts +++ b/specification/snapshot/verify_repository/SnapshotVerifyRepositoryRequest.ts @@ -25,7 +25,7 @@ import { Duration } from '@_types/Time' * Verify a snapshot repository. * Check for common misconfigurations in a snapshot repository. * @rest_spec_name snapshot.verify_repository - * @availability stack since=0.0.0 stability=stable + * @availability stack stability=stable * @availability serverless stability=stable visibility=private * @cluster_privileges manage * @doc_id snapshot-repo-verify From d06051124f8f6ec770000bd337d0ef704d16460d Mon Sep 17 00:00:00 2001 From: Liam Thompson Date: Tue, 19 Aug 2025 09:35:36 +0200 Subject: [PATCH 2/3] fix fat-fingered conflict resolution --- output/openapi/elasticsearch-openapi.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index cbe675382d..b7e15be120 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -42323,7 +42323,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "GET /_snapshot/my_repository/snapshot_*?sort=start_time&from_sort_value=1577833200000\n" @@ -42363,7 +42363,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n}" @@ -42403,7 +42403,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n}" @@ -42502,7 +42502,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "GET /_snapshot/my_repository\n" @@ -42542,7 +42542,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository\n{\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n}" @@ -42582,7 +42582,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "PUT /_snapshot/my_repository\n{\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n}" @@ -42642,7 +42642,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "DELETE /_snapshot/my_repository\n" @@ -42672,7 +42672,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "GET /_snapshot/my_repository\n" @@ -43089,7 +43089,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true\n{\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"rename_pattern\": \"index_(.+)\",\n \"rename_replacement\": \"restored_index_$1\",\n \"include_aliases\": false\n}" @@ -43265,7 +43265,7 @@ } }, "x-state": "Generally available", - "x-metaTags": [ + "x-codeSamples": [ { "lang": "Console", "source": "POST _snapshot/my_unverified_backup/_verify\n" From 38a5d1952ee4bde9f855ec5291ce9aa94af8b9de Mon Sep 17 00:00:00 2001 From: Liam Thompson Date: Tue, 19 Aug 2025 09:44:58 +0200 Subject: [PATCH 3/3] delete examples file --- docs/examples/languageExamples.json | 17226 -------------------------- 1 file changed, 17226 deletions(-) delete mode 100644 docs/examples/languageExamples.json diff --git a/docs/examples/languageExamples.json b/docs/examples/languageExamples.json deleted file mode 100644 index 52cdfb6409..0000000000 --- a/docs/examples/languageExamples.json +++ /dev/null @@ -1,17226 +0,0 @@ -{ - "specification/xpack/usage/examples/request/XPackUsageRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.xpack.usage()" - }, - { - "language": "JavaScript", - "code": "const response = await client.xpack.usage();" - }, - { - "language": "Ruby", - "code": "response = client.xpack.usage" - }, - { - "language": "PHP", - "code": "$resp = $client->xpack()->usage();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_xpack/usage\"" - }, - { - "language": "Java", - "code": "client.xpack().usage(u -> u);\n" - } - ], - "specification/xpack/info/examples/request/XPackInfoRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.xpack.info()" - }, - { - "language": "JavaScript", - "code": "const response = await client.xpack.info();" - }, - { - "language": "Ruby", - "code": "response = client.xpack.info" - }, - { - "language": "PHP", - "code": "$resp = $client->xpack()->info();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_xpack\"" - }, - { - "language": "Java", - "code": "client.xpack().info(i -> i);\n" - } - ], - "specification/cat/shards/examples/request/CatShardsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.shards(\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.shards({\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.shards(\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->shards([\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/shards?format=json\"" - }, - { - "language": "Java", - "code": "client.cat().shards();\n" - } - ], - "specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.component_templates(\n name=\"my-template-*\",\n v=True,\n s=\"name\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.componentTemplates({\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.component_templates(\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->componentTemplates([\n \"name\" => \"my-template-*\",\n \"v\" => \"true\",\n \"s\" => \"name\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/component_templates/my-template-*?v=true&s=name&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().componentTemplates();\n" - } - ], - "specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.tasks(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.tasks({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.tasks(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->tasks([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/tasks?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().tasks();\n" - } - ], - "specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.indices(\n index=\"my-index-*\",\n v=True,\n s=\"index\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.indices({\n index: \"my-index-*\",\n v: \"true\",\n s: \"index\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.indices(\n index: \"my-index-*\",\n v: \"true\",\n s: \"index\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->indices([\n \"index\" => \"my-index-*\",\n \"v\" => \"true\",\n \"s\" => \"index\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/indices/my-index-*?v=true&s=index&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().indices();\n" - } - ], - "specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.thread_pool(\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.threadPool({\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.thread_pool(\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->threadPool([\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/thread_pool?format=json\"" - }, - { - "language": "Java", - "code": "client.cat().threadPool();\n" - } - ], - "specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.pending_tasks(\n v=\"trueh=insertOrder,timeInQueue,priority,source\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.pendingTasks({\n v: \"trueh=insertOrder,timeInQueue,priority,source\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.pending_tasks(\n v: \"trueh=insertOrder,timeInQueue,priority,source\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->pendingTasks([\n \"v\" => \"trueh=insertOrder,timeInQueue,priority,source\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/pending_tasks?v=trueh=insertOrder,timeInQueue,priority,source&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().pendingTasks();\n" - } - ], - "specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.nodeattrs(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.nodeattrs({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.nodeattrs(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->nodeattrs([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/nodeattrs?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().nodeattrs();\n" - } - ], - "specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.snapshots(\n repository=\"repo1\",\n v=True,\n s=\"id\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.snapshots({\n repository: \"repo1\",\n v: \"true\",\n s: \"id\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.snapshots(\n repository: \"repo1\",\n v: \"true\",\n s: \"id\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->snapshots([\n \"repository\" => \"repo1\",\n \"v\" => \"true\",\n \"s\" => \"id\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/snapshots/repo1?v=true&s=id&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().snapshots();\n" - } - ], - "specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.nodes(\n v=True,\n h=\"id,ip,port,v,m\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.nodes({\n v: \"true\",\n h: \"id,ip,port,v,m\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.nodes(\n v: \"true\",\n h: \"id,ip,port,v,m\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->nodes([\n \"v\" => \"true\",\n \"h\" => \"id,ip,port,v,m\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/nodes?v=true&h=id,ip,port,v,m&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().nodes();\n" - } - ], - "specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.ml_datafeeds(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.mlDatafeeds({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.ml_datafeeds(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->mlDatafeeds([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/datafeeds?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().mlDatafeeds();\n" - } - ], - "specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.plugins(\n v=True,\n s=\"component\",\n h=\"name,component,version,description\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.plugins({\n v: \"true\",\n s: \"component\",\n h: \"name,component,version,description\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.plugins(\n v: \"true\",\n s: \"component\",\n h: \"name,component,version,description\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->plugins([\n \"v\" => \"true\",\n \"s\" => \"component\",\n \"h\" => \"name,component,version,description\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/plugins?v=true&s=component&h=name,component,version,description&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().plugins();\n" - } - ], - "specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.recovery(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.recovery({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.recovery(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->recovery([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/recovery?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().recovery();\n" - } - ], - "specification/cat/health/examples/request/CatHealthRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.health(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.health({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.health(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->health([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/health?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().health();\n" - } - ], - "specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.ml_jobs(\n h=\"id,s,dpr,mb\",\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.mlJobs({\n h: \"id,s,dpr,mb\",\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.ml_jobs(\n h: \"id,s,dpr,mb\",\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->mlJobs([\n \"h\" => \"id,s,dpr,mb\",\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/anomaly_detectors?h=id,s,dpr,mb&v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().mlJobs();\n" - } - ], - "specification/cat/count/examples/request/CatCountRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.count(\n index=\"my-index-000001\",\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.count({\n index: \"my-index-000001\",\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.count(\n index: \"my-index-000001\",\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->count([\n \"index\" => \"my-index-000001\",\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/count/my-index-000001?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().count();\n" - } - ], - "specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.repositories(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.repositories({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.repositories(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->repositories([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/repositories?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().repositories();\n" - } - ], - "specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.ml_data_frame_analytics(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.mlDataFrameAnalytics({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.ml_data_frame_analytics(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->mlDataFrameAnalytics([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/data_frame/analytics?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().mlDataFrameAnalytics();\n" - } - ], - "specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.transforms(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.transforms({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.transforms(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->transforms([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/transforms?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().transforms();\n" - } - ], - "specification/cat/master/examples/request/CatMasterRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.master(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.master({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.master(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->master([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/master?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().master();\n" - } - ], - "specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.templates(\n name=\"my-template-*\",\n v=True,\n s=\"name\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.templates({\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.templates(\n name: \"my-template-*\",\n v: \"true\",\n s: \"name\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->templates([\n \"name\" => \"my-template-*\",\n \"v\" => \"true\",\n \"s\" => \"name\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/templates/my-template-*?v=true&s=name&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().templates();\n" - } - ], - "specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.ml_trained_models(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.mlTrainedModels({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.ml_trained_models(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->mlTrainedModels([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/ml/trained_models?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().mlTrainedModels();\n" - } - ], - "specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.aliases(\n format=\"json\",\n v=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.aliases({\n format: \"json\",\n v: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.aliases(\n format: \"json\",\n v: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->aliases([\n \"format\" => \"json\",\n \"v\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/aliases?format=json&v=true\"" - }, - { - "language": "Java", - "code": "client.cat().aliases();\n" - } - ], - "specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.fielddata(\n v=True,\n fields=\"body\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.fielddata({\n v: \"true\",\n fields: \"body\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.fielddata(\n v: \"true\",\n fields: \"body\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->fielddata([\n \"v\" => \"true\",\n \"fields\" => \"body\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/fielddata?v=true&fields=body&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().fielddata();\n" - } - ], - "specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.segments(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.segments({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.segments(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->segments([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/segments?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().segments();\n" - } - ], - "specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cat.allocation(\n v=True,\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cat.allocation({\n v: \"true\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cat.allocation(\n v: \"true\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cat()->allocation([\n \"v\" => \"true\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cat/allocation?v=true&format=json\"" - }, - { - "language": "Java", - "code": "client.cat().allocation();\n" - } - ], - "specification/searchable_snapshots/cache_stats/examples/request/CacheStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.searchable_snapshots.cache_stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchableSnapshots.cacheStats();" - }, - { - "language": "Ruby", - "code": "response = client.searchable_snapshots.cache_stats" - }, - { - "language": "PHP", - "code": "$resp = $client->searchableSnapshots()->cacheStats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_searchable_snapshots/cache/stats\"" - }, - { - "language": "Java", - "code": "client.searchableSnapshots().cacheStats(c -> c);\n" - } - ], - "specification/searchable_snapshots/clear_cache/examples/request/SearchableSnapshotsClearCacheExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.searchable_snapshots.clear_cache(\n index=\"my-index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchableSnapshots.clearCache({\n index: \"my-index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.searchable_snapshots.clear_cache(\n index: \"my-index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchableSnapshots()->clearCache([\n \"index\" => \"my-index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index/_searchable_snapshots/cache/clear\"" - }, - { - "language": "Java", - "code": "client.searchableSnapshots().clearCache(c -> c\n .index(\"my-index\")\n);\n" - } - ], - "specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.searchable_snapshots.mount(\n repository=\"my_repository\",\n snapshot=\"my_snapshot\",\n wait_for_completion=True,\n index=\"my_docs\",\n renamed_index=\"docs\",\n index_settings={\n \"index.number_of_replicas\": 0\n },\n ignore_index_settings=[\n \"index.refresh_interval\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchableSnapshots.mount({\n repository: \"my_repository\",\n snapshot: \"my_snapshot\",\n wait_for_completion: \"true\",\n index: \"my_docs\",\n renamed_index: \"docs\",\n index_settings: {\n \"index.number_of_replicas\": 0,\n },\n ignore_index_settings: [\"index.refresh_interval\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.searchable_snapshots.mount(\n repository: \"my_repository\",\n snapshot: \"my_snapshot\",\n wait_for_completion: \"true\",\n body: {\n \"index\": \"my_docs\",\n \"renamed_index\": \"docs\",\n \"index_settings\": {\n \"index.number_of_replicas\": 0\n },\n \"ignore_index_settings\": [\n \"index.refresh_interval\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchableSnapshots()->mount([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"my_snapshot\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"index\" => \"my_docs\",\n \"renamed_index\" => \"docs\",\n \"index_settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"ignore_index_settings\" => array(\n \"index.refresh_interval\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_docs\",\"renamed_index\":\"docs\",\"index_settings\":{\"index.number_of_replicas\":0},\"ignore_index_settings\":[\"index.refresh_interval\"]}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/my_snapshot/_mount?wait_for_completion=true\"" - }, - { - "language": "Java", - "code": "client.searchableSnapshots().mount(m -> m\n .ignoreIndexSettings(\"index.refresh_interval\")\n .index(\"my_docs\")\n .indexSettings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n .renamedIndex(\"docs\")\n .repository(\"my_repository\")\n .snapshot(\"my_snapshot\")\n .waitForCompletion(true)\n);\n" - } - ], - "specification/searchable_snapshots/stats/examples/request/SearchableSnapshotsStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.searchable_snapshots.stats(\n index=\"my-index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchableSnapshots.stats({\n index: \"my-index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.searchable_snapshots.stats(\n index: \"my-index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchableSnapshots()->stats([\n \"index\" => \"my-index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index/_searchable_snapshots/stats\"" - }, - { - "language": "Java", - "code": "client.searchableSnapshots().stats(s -> s\n .index(\"my-index\")\n);\n" - } - ], - "specification/snapshot/delete_repository/examples/request/SnapshotDeleteRepositoryExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.delete_repository(\n name=\"my_repository\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.deleteRepository({\n name: \"my_repository\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.delete_repository(\n repository: \"my_repository\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->deleteRepository([\n \"repository\" => \"my_repository\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().deleteRepository(d -> d\n .name(\"my_repository\")\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_s3_repository\",\n repository={\n \"type\": \"s3\",\n \"settings\": {\n \"bucket\": \"my-bucket\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_s3_repository\",\n repository: {\n type: \"s3\",\n settings: {\n bucket: \"my-bucket\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_s3_repository\",\n body: {\n \"type\": \"s3\",\n \"settings\": {\n \"bucket\": \"my-bucket\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_s3_repository\",\n \"body\" => [\n \"type\" => \"s3\",\n \"settings\" => [\n \"bucket\" => \"my-bucket\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"s3\",\"settings\":{\"bucket\":\"my-bucket\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_s3_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_s3_repository\")\n .repository(r -> r\n .s3(s -> s\n .settings(se -> se\n .bucket(\"my-bucket\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_src_only_repository\",\n repository={\n \"type\": \"source\",\n \"settings\": {\n \"delegate_type\": \"fs\",\n \"location\": \"my_backup_repository\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_src_only_repository\",\n repository: {\n type: \"source\",\n settings: {\n delegate_type: \"fs\",\n location: \"my_backup_repository\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_src_only_repository\",\n body: {\n \"type\": \"source\",\n \"settings\": {\n \"delegate_type\": \"fs\",\n \"location\": \"my_backup_repository\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_src_only_repository\",\n \"body\" => [\n \"type\" => \"source\",\n \"settings\" => [\n \"delegate_type\" => \"fs\",\n \"location\" => \"my_backup_repository\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"source\",\"settings\":{\"delegate_type\":\"fs\",\"location\":\"my_backup_repository\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_src_only_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_src_only_repository\")\n .repository(r -> r\n .source(s -> s\n .settings(se -> se\n .delegateType(\"fs\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_backup\",\n repository={\n \"type\": \"azure\",\n \"settings\": {\n \"client\": \"secondary\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_backup\",\n repository: {\n type: \"azure\",\n settings: {\n client: \"secondary\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_backup\",\n body: {\n \"type\": \"azure\",\n \"settings\": {\n \"client\": \"secondary\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_backup\",\n \"body\" => [\n \"type\" => \"azure\",\n \"settings\" => [\n \"client\" => \"secondary\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"azure\",\"settings\":{\"client\":\"secondary\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_backup\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_backup\")\n .repository(r -> r\n .azure(a -> a\n .settings(s -> s\n .client(\"secondary\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_gcs_repository\",\n repository={\n \"type\": \"gcs\",\n \"settings\": {\n \"bucket\": \"my_other_bucket\",\n \"base_path\": \"dev\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_gcs_repository\",\n repository: {\n type: \"gcs\",\n settings: {\n bucket: \"my_other_bucket\",\n base_path: \"dev\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_gcs_repository\",\n body: {\n \"type\": \"gcs\",\n \"settings\": {\n \"bucket\": \"my_other_bucket\",\n \"base_path\": \"dev\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_gcs_repository\",\n \"body\" => [\n \"type\" => \"gcs\",\n \"settings\" => [\n \"bucket\" => \"my_other_bucket\",\n \"base_path\" => \"dev\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"gcs\",\"settings\":{\"bucket\":\"my_other_bucket\",\"base_path\":\"dev\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_gcs_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_gcs_repository\")\n .repository(r -> r\n .gcs(g -> g\n .settings(s -> s\n .bucket(\"my_other_bucket\")\n .basePath(\"dev\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_repository\",\n repository={\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_repository\",\n repository: {\n type: \"fs\",\n settings: {\n location: \"my_backup_location\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_repository\",\n body: {\n \"type\": \"fs\",\n \"settings\": {\n \"location\": \"my_backup_location\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_repository\",\n \"body\" => [\n \"type\" => \"fs\",\n \"settings\" => [\n \"location\" => \"my_backup_location\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"fs\",\"settings\":{\"location\":\"my_backup_location\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_repository\")\n .repository(r -> r\n .fs(f -> f\n .settings(s -> s\n .location(\"my_backup_location\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create_repository(\n name=\"my_read_only_url_repository\",\n repository={\n \"type\": \"url\",\n \"settings\": {\n \"url\": \"file:/mount/backups/my_fs_backup_location\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.createRepository({\n name: \"my_read_only_url_repository\",\n repository: {\n type: \"url\",\n settings: {\n url: \"file:/mount/backups/my_fs_backup_location\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create_repository(\n repository: \"my_read_only_url_repository\",\n body: {\n \"type\": \"url\",\n \"settings\": {\n \"url\": \"file:/mount/backups/my_fs_backup_location\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->createRepository([\n \"repository\" => \"my_read_only_url_repository\",\n \"body\" => [\n \"type\" => \"url\",\n \"settings\" => [\n \"url\" => \"file:/mount/backups/my_fs_backup_location\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"url\",\"settings\":{\"url\":\"file:/mount/backups/my_fs_backup_location\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_read_only_url_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().createRepository(c -> c\n .name(\"my_read_only_url_repository\")\n .repository(r -> r\n .url(u -> u\n .settings(s -> s\n .url(\"file:/mount/backups/my_fs_backup_location\")\n )\n )\n )\n);\n" - } - ], - "specification/snapshot/delete/examples/request/SnapshotDeleteRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.delete(\n repository=\"my_repository\",\n snapshot=\"snapshot_2,snapshot_3\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.delete({\n repository: \"my_repository\",\n snapshot: \"snapshot_2,snapshot_3\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.delete(\n repository: \"my_repository\",\n snapshot: \"snapshot_2,snapshot_3\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->delete([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2,snapshot_3\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2,snapshot_3\"" - }, - { - "language": "Java", - "code": "client.snapshot().delete(d -> d\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2,snapshot_3\")\n);\n" - } - ], - "specification/snapshot/verify_repository/examples/request/SnapshotVerifyRepositoryExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.verify_repository(\n name=\"my_unverified_backup\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.verifyRepository({\n name: \"my_unverified_backup\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.verify_repository(\n repository: \"my_unverified_backup\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->verifyRepository([\n \"repository\" => \"my_unverified_backup\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_unverified_backup/_verify\"" - }, - { - "language": "Java", - "code": "client.snapshot().verifyRepository(v -> v\n .name(\"my_unverified_backup\")\n);\n" - } - ], - "specification/snapshot/get/examples/request/SnapshotGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.get(\n repository=\"my_repository\",\n snapshot=\"snapshot_*\",\n sort=\"start_time\",\n from_sort_value=\"1577833200000\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.get({\n repository: \"my_repository\",\n snapshot: \"snapshot_*\",\n sort: \"start_time\",\n from_sort_value: 1577833200000,\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.get(\n repository: \"my_repository\",\n snapshot: \"snapshot_*\",\n sort: \"start_time\",\n from_sort_value: \"1577833200000\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->get([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_*\",\n \"sort\" => \"start_time\",\n \"from_sort_value\" => \"1577833200000\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_*?sort=start_time&from_sort_value=1577833200000\"" - }, - { - "language": "Java", - "code": "client.snapshot().get(g -> g\n .fromSortValue(\"1577833200000\")\n .repository(\"my_repository\")\n .snapshot(\"snapshot_*\")\n .sort(SnapshotSort.StartTime)\n);\n" - } - ], - "specification/snapshot/repository_analyze/examples/request/SnapshotRepositoryAnalyzeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.repository_analyze(\n name=\"my_repository\",\n blob_count=\"10\",\n max_blob_size=\"1mb\",\n timeout=\"120s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.repositoryAnalyze({\n name: \"my_repository\",\n blob_count: 10,\n max_blob_size: \"1mb\",\n timeout: \"120s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.repository_analyze(\n repository: \"my_repository\",\n blob_count: \"10\",\n max_blob_size: \"1mb\",\n timeout: \"120s\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->repositoryAnalyze([\n \"repository\" => \"my_repository\",\n \"blob_count\" => \"10\",\n \"max_blob_size\" => \"1mb\",\n \"timeout\" => \"120s\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_analyze?blob_count=10&max_blob_size=1mb&timeout=120s\"" - }, - { - "language": "Java", - "code": "client.snapshot().repositoryAnalyze(r -> r\n .blobCount(10)\n .maxBlobSize(\"1mb\")\n .name(\"my_repository\")\n .timeout(t -> t\n .offset(120)\n )\n);\n" - } - ], - "specification/snapshot/status/examples/request/SnapshotStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.status(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.status({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.status(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->status([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_status\"" - }, - { - "language": "Java", - "code": "client.snapshot().status(s -> s\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n);\n" - } - ], - "specification/snapshot/cleanup_repository/examples/request/SnapshotCleanupRepositoryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.cleanup_repository(\n name=\"my_repository\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.cleanupRepository({\n name: \"my_repository\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.cleanup_repository(\n repository: \"my_repository\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->cleanupRepository([\n \"repository\" => \"my_repository\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_cleanup\"" - }, - { - "language": "Java", - "code": "client.snapshot().cleanupRepository(c -> c\n .name(\"my_repository\")\n);\n" - } - ], - "specification/snapshot/repository_verify_integrity/examples/request/SnapshotRepositoryVerifyIntegrityExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.repository_verify_integrity(\n name=\"my_repository\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.repositoryVerifyIntegrity({\n name: \"my_repository\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.repository_verify_integrity(\n repository: \"my_repository\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->repositoryVerifyIntegrity([\n \"repository\" => \"my_repository\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository/_verify_integrity\"" - }, - { - "language": "Java", - "code": "client.snapshot().repositoryVerifyIntegrity(r -> r\n .name(\"my_repository\")\n);\n" - } - ], - "specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.clone(\n repository=\"my_repository\",\n snapshot=\"source_snapshot\",\n target_snapshot=\"target_snapshot\",\n indices=\"index_a,index_b\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.clone({\n repository: \"my_repository\",\n snapshot: \"source_snapshot\",\n target_snapshot: \"target_snapshot\",\n indices: \"index_a,index_b\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.clone(\n repository: \"my_repository\",\n snapshot: \"source_snapshot\",\n target_snapshot: \"target_snapshot\",\n body: {\n \"indices\": \"index_a,index_b\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->clone([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"source_snapshot\",\n \"target_snapshot\" => \"target_snapshot\",\n \"body\" => [\n \"indices\" => \"index_a,index_b\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_a,index_b\"}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/source_snapshot/_clone/target_snapshot\"" - }, - { - "language": "Java", - "code": "client.snapshot().clone(c -> c\n .indices(\"index_a,index_b\")\n .repository(\"my_repository\")\n .snapshot(\"source_snapshot\")\n .targetSnapshot(\"target_snapshot\")\n);\n" - } - ], - "specification/snapshot/get_repository/examples/request/SnapshotGetRepositoryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.get_repository(\n name=\"my_repository\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.getRepository({\n name: \"my_repository\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.get_repository(\n repository: \"my_repository\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->getRepository([\n \"repository\" => \"my_repository\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_snapshot/my_repository\"" - }, - { - "language": "Java", - "code": "client.snapshot().getRepository(g -> g\n .name(\"my_repository\")\n);\n" - } - ], - "specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.create(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n wait_for_completion=True,\n indices=\"index_1,index_2\",\n ignore_unavailable=True,\n include_global_state=False,\n metadata={\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.create({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n indices: \"index_1,index_2\",\n ignore_unavailable: true,\n include_global_state: false,\n metadata: {\n taken_by: \"user123\",\n taken_because: \"backup before upgrading\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.create(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n body: {\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"metadata\": {\n \"taken_by\": \"user123\",\n \"taken_because\": \"backup before upgrading\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->create([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"indices\" => \"index_1,index_2\",\n \"ignore_unavailable\" => true,\n \"include_global_state\" => false,\n \"metadata\" => [\n \"taken_by\" => \"user123\",\n \"taken_because\" => \"backup before upgrading\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"metadata\":{\"taken_by\":\"user123\",\"taken_because\":\"backup before upgrading\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2?wait_for_completion=true\"" - }, - { - "language": "Java", - "code": "client.snapshot().create(c -> c\n .ignoreUnavailable(true)\n .includeGlobalState(false)\n .indices(\"index_1,index_2\")\n .metadata(Map.of(\"taken_by\", JsonData.fromJson(\"\\\"user123\\\"\"),\"taken_because\", JsonData.fromJson(\"\\\"backup before upgrading\\\"\")))\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n .waitForCompletion(true)\n);\n" - } - ], - "specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.put_settings(\n indices=\"index_1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.putSettings({\n indices: \"index_1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.put_settings(\n body: {\n \"indices\": \"index_1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"indices\" => \"index_1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1\"}' \"$ELASTICSEARCH_URL/_cluster/settings\"" - }, - { - "language": "Java", - "code": "client.cluster().putSettings();\n" - } - ], - "specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.snapshot.restore(\n repository=\"my_repository\",\n snapshot=\"snapshot_2\",\n wait_for_completion=True,\n indices=\"index_1,index_2\",\n ignore_unavailable=True,\n include_global_state=False,\n rename_pattern=\"index_(.+)\",\n rename_replacement=\"restored_index_$1\",\n include_aliases=False,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.snapshot.restore({\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n indices: \"index_1,index_2\",\n ignore_unavailable: true,\n include_global_state: false,\n rename_pattern: \"index_(.+)\",\n rename_replacement: \"restored_index_$1\",\n include_aliases: false,\n});" - }, - { - "language": "Ruby", - "code": "response = client.snapshot.restore(\n repository: \"my_repository\",\n snapshot: \"snapshot_2\",\n wait_for_completion: \"true\",\n body: {\n \"indices\": \"index_1,index_2\",\n \"ignore_unavailable\": true,\n \"include_global_state\": false,\n \"rename_pattern\": \"index_(.+)\",\n \"rename_replacement\": \"restored_index_$1\",\n \"include_aliases\": false\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->snapshot()->restore([\n \"repository\" => \"my_repository\",\n \"snapshot\" => \"snapshot_2\",\n \"wait_for_completion\" => \"true\",\n \"body\" => [\n \"indices\" => \"index_1,index_2\",\n \"ignore_unavailable\" => true,\n \"include_global_state\" => false,\n \"rename_pattern\" => \"index_(.+)\",\n \"rename_replacement\" => \"restored_index_$1\",\n \"include_aliases\" => false,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"rename_pattern\":\"index_(.+)\",\"rename_replacement\":\"restored_index_$1\",\"include_aliases\":false}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true\"" - }, - { - "language": "Java", - "code": "client.snapshot().restore(r -> r\n .ignoreUnavailable(true)\n .includeAliases(false)\n .includeGlobalState(false)\n .indices(\"index_1,index_2\")\n .renamePattern(\"index_(.+)\")\n .renameReplacement(\"restored_index_$1\")\n .repository(\"my_repository\")\n .snapshot(\"snapshot_2\")\n .waitForCompletion(true)\n);\n" - } - ], - "specification/cluster/delete_component_template/examples/request/ClusterDeleteComponentTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.delete_component_template(\n name=\"template_1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.deleteComponentTemplate({\n name: \"template_1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.delete_component_template(\n name: \"template_1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->deleteComponentTemplate([\n \"name\" => \"template_1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_component_template/template_1\"" - }, - { - "language": "Java", - "code": "client.cluster().deleteComponentTemplate(d -> d\n .name(\"template_1\")\n);\n" - } - ], - "specification/cluster/pending_tasks/examples/request/ClusterPendingTasksExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.pending_tasks()" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.pendingTasks();" - }, - { - "language": "Ruby", - "code": "response = client.cluster.pending_tasks" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->pendingTasks();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/pending_tasks\"" - }, - { - "language": "Java", - "code": "client.cluster().pendingTasks(p -> p);\n" - } - ], - "specification/cluster/put_component_template/examples/request/ClusterPutComponentTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.put_component_template(\n name=\"template_1\",\n template=None,\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"_source\": {\n \"enabled\": False\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.putComponentTemplate({\n name: \"template_1\",\n template: null,\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n _source: {\n enabled: false,\n },\n properties: {\n host_name: {\n type: \"keyword\",\n },\n created_at: {\n type: \"date\",\n format: \"EEE MMM dd HH:mm:ss Z yyyy\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "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 \"mappings\": {\n \"_source\": {\n \"enabled\": false\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->putComponentTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"template\" => null,\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"_source\" => [\n \"enabled\" => false,\n ],\n \"properties\" => [\n \"host_name\" => [\n \"type\" => \"keyword\",\n ],\n \"created_at\" => [\n \"type\" => \"date\",\n \"format\" => \"EEE MMM dd HH:mm:ss Z yyyy\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"template\":null,\"settings\":{\"number_of_shards\":1},\"mappings\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"keyword\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\"}}}}' \"$ELASTICSEARCH_URL/_component_template/template_1\"" - } - ], - "specification/cluster/put_component_template/examples/request/ClusterPutComponentTemplateRequestExample2.yaml": [ - { - "language": "Python", - "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)" - }, - { - "language": "JavaScript", - "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});" - }, - { - "language": "Ruby", - "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)" - }, - { - "language": "PHP", - "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]);" - }, - { - "language": "curl", - "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\"" - } - ], - "specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.get_settings(\n filter_path=\"persistent.cluster.remote\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.getSettings({\n filter_path: \"persistent.cluster.remote\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.get_settings(\n filter_path: \"persistent.cluster.remote\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->getSettings([\n \"filter_path\" => \"persistent.cluster.remote\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/settings?filter_path=persistent.cluster.remote\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/cluster/reroute/examples/request/ClusterRerouteRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.reroute(\n metric=\"none\",\n commands=[\n {\n \"move\": {\n \"index\": \"test\",\n \"shard\": 0,\n \"from_node\": \"node1\",\n \"to_node\": \"node2\"\n }\n },\n {\n \"allocate_replica\": {\n \"index\": \"test\",\n \"shard\": 1,\n \"node\": \"node3\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.reroute({\n metric: \"none\",\n commands: [\n {\n move: {\n index: \"test\",\n shard: 0,\n from_node: \"node1\",\n to_node: \"node2\",\n },\n },\n {\n allocate_replica: {\n index: \"test\",\n shard: 1,\n node: \"node3\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.reroute(\n metric: \"none\",\n body: {\n \"commands\": [\n {\n \"move\": {\n \"index\": \"test\",\n \"shard\": 0,\n \"from_node\": \"node1\",\n \"to_node\": \"node2\"\n }\n },\n {\n \"allocate_replica\": {\n \"index\": \"test\",\n \"shard\": 1,\n \"node\": \"node3\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->reroute([\n \"metric\" => \"none\",\n \"body\" => [\n \"commands\" => array(\n [\n \"move\" => [\n \"index\" => \"test\",\n \"shard\" => 0,\n \"from_node\" => \"node1\",\n \"to_node\" => \"node2\",\n ],\n ],\n [\n \"allocate_replica\" => [\n \"index\" => \"test\",\n \"shard\" => 1,\n \"node\" => \"node3\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "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\"" - } - ], - "specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.allocation_explain(\n index=\"my-index-000001\",\n shard=0,\n primary=False,\n current_node=\"my-node\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.allocationExplain({\n index: \"my-index-000001\",\n shard: 0,\n primary: false,\n current_node: \"my-node\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.allocation_explain(\n body: {\n \"index\": \"my-index-000001\",\n \"shard\": 0,\n \"primary\": false,\n \"current_node\": \"my-node\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->allocationExplain([\n \"body\" => [\n \"index\" => \"my-index-000001\",\n \"shard\" => 0,\n \"primary\" => false,\n \"current_node\" => \"my-node\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my-index-000001\",\"shard\":0,\"primary\":false,\"current_node\":\"my-node\"}' \"$ELASTICSEARCH_URL/_cluster/allocation/explain\"" - }, - { - "language": "Java", - "code": "client.cluster().allocationExplain(a -> a\n .currentNode(\"my-node\")\n .index(\"my-index-000001\")\n .primary(false)\n .shard(0)\n);\n" - } - ], - "specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.put_settings(\n persistent={\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.putSettings({\n persistent: {\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.put_settings(\n body: {\n \"persistent\": {\n \"action.auto_create_index\": \"my-index-000001,index10,-index1*,+ind*\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"persistent\" => [\n \"action.auto_create_index\" => \"my-index-000001,index10,-index1*,+ind*\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"persistent\":{\"action.auto_create_index\":\"my-index-000001,index10,-index1*,+ind*\"}}' \"$ELASTICSEARCH_URL/_cluster/settings\"" - }, - { - "language": "Java", - "code": "client.cluster().putSettings(p -> p\n .persistent(\"action.auto_create_index\", JsonData.fromJson(\"\\\"my-index-000001,index10,-index1*,+ind*\\\"\"))\n);\n" - } - ], - "specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.put_settings(\n persistent={\n \"indices.recovery.max_bytes_per_sec\": \"50mb\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.putSettings({\n persistent: {\n \"indices.recovery.max_bytes_per_sec\": \"50mb\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.put_settings(\n body: {\n \"persistent\": {\n \"indices.recovery.max_bytes_per_sec\": \"50mb\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->putSettings([\n \"body\" => [\n \"persistent\" => [\n \"indices.recovery.max_bytes_per_sec\" => \"50mb\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"persistent\":{\"indices.recovery.max_bytes_per_sec\":\"50mb\"}}' \"$ELASTICSEARCH_URL/_cluster/settings\"" - }, - { - "language": "Java", - "code": "client.cluster().putSettings(p -> p\n .persistent(\"indices.recovery.max_bytes_per_sec\", JsonData.fromJson(\"\\\"50mb\\\"\"))\n);\n" - } - ], - "specification/cluster/health/examples/request/ClusterHealthRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.health()" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.health();" - }, - { - "language": "Ruby", - "code": "response = client.cluster.health" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->health();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/health\"" - }, - { - "language": "Java", - "code": "client.cluster().health(h -> h);\n" - } - ], - "specification/cluster/state/examples/request/ClusterStateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.state(\n filter_path=\"metadata.cluster_coordination.last_committed_config\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.state({\n filter_path: \"metadata.cluster_coordination.last_committed_config\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.state(\n filter_path: \"metadata.cluster_coordination.last_committed_config\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->state([\n \"filter_path\" => \"metadata.cluster_coordination.last_committed_config\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/state?filter_path=metadata.cluster_coordination.last_committed_config\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/cluster/info/examples/request/ClusterInfoExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.info(\n target=\"_all\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.info({\n target: \"_all\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.info(\n target: \"_all\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->info([\n \"target\" => \"_all\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_info/_all\"" - }, - { - "language": "Java", - "code": "client.cluster().info(i -> i\n .target(\"_all\")\n);\n" - } - ], - "specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.remote_info()" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.remoteInfo();" - }, - { - "language": "Ruby", - "code": "response = client.cluster.remote_info" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->remoteInfo();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_remote/info\"" - }, - { - "language": "Java", - "code": "client.cluster().remoteInfo();\n" - } - ], - "specification/cluster/stats/examples/request/ClusterStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.stats(\n human=True,\n filter_path=\"indices.mappings.total_deduplicated_mapping_size*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.stats({\n human: \"true\",\n filter_path: \"indices.mappings.total_deduplicated_mapping_size*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.stats(\n human: \"true\",\n filter_path: \"indices.mappings.total_deduplicated_mapping_size*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->stats([\n \"human\" => \"true\",\n \"filter_path\" => \"indices.mappings.total_deduplicated_mapping_size*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_cluster/stats?human&filter_path=indices.mappings.total_deduplicated_mapping_size*\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/cluster/get_component_template/examples/request/ClusterGetComponentTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.get_component_template(\n name=\"template_1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.getComponentTemplate({\n name: \"template_1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.get_component_template(\n name: \"template_1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->getComponentTemplate([\n \"name\" => \"template_1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_component_template/template_1\"" - }, - { - "language": "Java", - "code": "client.cluster().getComponentTemplate(g -> g\n .name(\"template_1\")\n);\n" - } - ], - "specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ssl.certificates()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ssl.certificates();" - }, - { - "language": "Ruby", - "code": "response = client.ssl.certificates" - }, - { - "language": "PHP", - "code": "$resp = $client->ssl()->certificates();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ssl/certificates\"" - }, - { - "language": "Java", - "code": "client.ssl().certificates();\n" - } - ], - "specification/tasks/cancel/examples/request/TasksCancelExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.tasks.cancel(\n task_id=\"\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.tasks.cancel({\n task_id: \"\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.tasks.cancel(\n task_id: \"\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->tasks()->cancel([\n \"task_id\" => \"\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks//_cancel\"" - }, - { - "language": "Java", - "code": "client.tasks().cancel(c -> c\n .taskId(\"\")\n);\n" - } - ], - "specification/tasks/get/examples/request/GetTaskRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.tasks.list(\n detailed=True,\n actions=\"*/delete/byquery\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.tasks.list({\n detailed: \"true\",\n actions: \"*/delete/byquery\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.tasks.list(\n detailed: \"true\",\n actions: \"*/delete/byquery\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->tasks()->list([\n \"detailed\" => \"true\",\n \"actions\" => \"*/delete/byquery\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?detailed=true&actions=*/delete/byquery\"" - } - ], - "specification/tasks/list/examples/request/ListTasksRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.tasks.list(\n actions=\"*search\",\n detailed=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.tasks.list({\n actions: \"*search\",\n detailed: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.tasks.list(\n actions: \"*search\",\n detailed: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->tasks()->list([\n \"actions\" => \"*search\",\n \"detailed\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_tasks?actions=*search&detailed\"" - } - ], - "specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.simulate_template(\n index_patterns=[\n \"my-index-*\"\n ],\n composed_of=[\n \"ct2\"\n ],\n priority=10,\n template={\n \"settings\": {\n \"index.number_of_replicas\": 1\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.simulateTemplate({\n index_patterns: [\"my-index-*\"],\n composed_of: [\"ct2\"],\n priority: 10,\n template: {\n settings: {\n \"index.number_of_replicas\": 1,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.simulate_template(\n body: {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"ct2\"\n ],\n \"priority\": 10,\n \"template\": {\n \"settings\": {\n \"index.number_of_replicas\": 1\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->simulateTemplate([\n \"body\" => [\n \"index_patterns\" => array(\n \"my-index-*\",\n ),\n \"composed_of\" => array(\n \"ct2\",\n ),\n \"priority\" => 10,\n \"template\" => [\n \"settings\" => [\n \"index.number_of_replicas\" => 1,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"ct2\"],\"priority\":10,\"template\":{\"settings\":{\"index.number_of_replicas\":1}}}' \"$ELASTICSEARCH_URL/_index_template/_simulate\"" - }, - { - "language": "Java", - "code": "client.indices().simulateTemplate(s -> s\n .composedOf(\"ct2\")\n .indexPatterns(\"my-index-*\")\n .priority(10L)\n .template(t -> t\n .settings(se -> se\n .otherSettings(\"index.number_of_replicas\", JsonData.fromJson(\"1\"))\n )\n )\n);\n" - } - ], - "specification/indices/split/examples/request/indicesSplitRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.split(\n index=\"my-index-000001\",\n target=\"split-my-index-000001\",\n settings={\n \"index.number_of_shards\": 2\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.split({\n index: \"my-index-000001\",\n target: \"split-my-index-000001\",\n settings: {\n \"index.number_of_shards\": 2,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.split(\n index: \"my-index-000001\",\n target: \"split-my-index-000001\",\n body: {\n \"settings\": {\n \"index.number_of_shards\": 2\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->split([\n \"index\" => \"my-index-000001\",\n \"target\" => \"split-my-index-000001\",\n \"body\" => [\n \"settings\" => [\n \"index.number_of_shards\" => 2,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.number_of_shards\":2}}' \"$ELASTICSEARCH_URL/my-index-000001/_split/split-my-index-000001\"" - }, - { - "language": "Java", - "code": "client.indices().split(s -> s\n .index(\"my-index-000001\")\n .settings(\"index.number_of_shards\", JsonData.fromJson(\"2\"))\n .target(\"split-my-index-000001\")\n);\n" - } - ], - "specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.update_aliases(\n actions=[\n {\n \"add\": {\n \"index\": \"logs-nginx.access-prod\",\n \"alias\": \"logs\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.updateAliases({\n actions: [\n {\n add: {\n index: \"logs-nginx.access-prod\",\n alias: \"logs\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.update_aliases(\n body: {\n \"actions\": [\n {\n \"add\": {\n \"index\": \"logs-nginx.access-prod\",\n \"alias\": \"logs\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->updateAliases([\n \"body\" => [\n \"actions\" => array(\n [\n \"add\" => [\n \"index\" => \"logs-nginx.access-prod\",\n \"alias\" => \"logs\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"add\":{\"index\":\"logs-nginx.access-prod\",\"alias\":\"logs\"}}]}' \"$ELASTICSEARCH_URL/_aliases\"" - }, - { - "language": "Java", - "code": "client.indices().updateAliases(u -> u\n .actions(a -> a\n .add(ad -> ad\n .alias(\"logs\")\n .index(\"logs-nginx.access-prod\")\n )\n )\n);\n" - } - ], - "specification/indices/exists_alias/examples/request/IndicesExistsAliasExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.exists_alias(\n name=\"my-alias\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.existsAlias({\n name: \"my-alias\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.exists_alias(\n name: \"my-alias\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->existsAlias([\n \"name\" => \"my-alias\",\n]);" - }, - { - "language": "curl", - "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_alias/my-alias\"" - }, - { - "language": "Java", - "code": "client.indices().existsAlias(e -> e\n .name(\"my-alias\")\n);\n" - } - ], - "specification/indices/get_data_stream_mappings/examples/request/IndicesGetDataStreamMappingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_data_stream_mappings(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getDataStreamMappings({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_data_stream_mappings(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getDataStreamMappings([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings\"" - } - ], - "specification/indices/delete_template/examples/request/IndicesDeleteTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete_template(\n name=\".cloud-hot-warm-allocation-0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.deleteTemplate({\n name: \".cloud-hot-warm-allocation-0\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete_template(\n name: \".cloud-hot-warm-allocation-0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->deleteTemplate([\n \"name\" => \".cloud-hot-warm-allocation-0\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/.cloud-hot-warm-allocation-0\"" - }, - { - "language": "Java", - "code": "client.indices().deleteTemplate(d -> d\n .name(\".cloud-hot-warm-allocation-0\")\n);\n" - } - ], - "specification/indices/data_streams_stats/examples/request/indicesDataStreamStatsExampleRequest1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.data_streams_stats(\n name=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.dataStreamsStats({\n name: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.data_streams_stats(\n name: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->dataStreamsStats([\n \"name\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-index-000001/_stats\"" - }, - { - "language": "Java", - "code": "client.indices().dataStreamsStats(d -> d\n .name(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/delete_index_template/examples/request/IndicesDeleteIndexTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete_index_template(\n name=\"my-index-template\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.deleteIndexTemplate({\n name: \"my-index-template\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete_index_template(\n name: \"my-index-template\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->deleteIndexTemplate([\n \"name\" => \"my-index-template\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/my-index-template\"" - }, - { - "language": "Java", - "code": "client.indices().deleteIndexTemplate(d -> d\n .name(\"my-index-template\")\n);\n" - } - ], - "specification/indices/simulate_index_template/examples/request/indicesSimulateIndexTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.simulate_index_template(\n name=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.simulateIndexTemplate({\n name: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.simulate_index_template(\n name: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->simulateIndexTemplate([\n \"name\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/_simulate_index/my-index-000001\"" - }, - { - "language": "Java", - "code": "client.indices().simulateIndexTemplate(s -> s\n .name(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_template(\n name=\"template_1\",\n index_patterns=[\n \"te*\"\n ],\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)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putTemplate({\n name: \"template_1\",\n index_patterns: [\"te*\"],\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});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"te*\"\n ],\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)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"te*\",\n ),\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]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"te*\"],\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" - }, - { - "language": "Java", - "code": "client.indices().putTemplate(p -> p\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(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .routing(\"shard-1\"))))\n .indexPatterns(\"te*\")\n .name(\"template_1\")\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" - } - ], - "specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_template(\n name=\"template_1\",\n index_patterns=[\n \"te*\",\n \"bar*\"\n ],\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"_source\": {\n \"enabled\": False\n }\n },\n properties={\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putTemplate({\n name: \"template_1\",\n index_patterns: [\"te*\", \"bar*\"],\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n _source: {\n enabled: false,\n },\n },\n properties: {\n host_name: {\n type: \"keyword\",\n },\n created_at: {\n type: \"date\",\n format: \"EEE MMM dd HH:mm:ss Z yyyy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"te*\",\n \"bar*\"\n ],\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n \"_source\": {\n \"enabled\": false\n }\n },\n \"properties\": {\n \"host_name\": {\n \"type\": \"keyword\"\n },\n \"created_at\": {\n \"type\": \"date\",\n \"format\": \"EEE MMM dd HH:mm:ss Z yyyy\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"te*\",\n \"bar*\",\n ),\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"_source\" => [\n \"enabled\" => false,\n ],\n ],\n \"properties\" => [\n \"host_name\" => [\n \"type\" => \"keyword\",\n ],\n \"created_at\" => [\n \"type\" => \"date\",\n \"format\" => \"EEE MMM dd HH:mm:ss Z yyyy\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"te*\",\"bar*\"],\"settings\":{\"number_of_shards\":1},\"mappings\":{\"_source\":{\"enabled\":false}},\"properties\":{\"host_name\":{\"type\":\"keyword\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\"}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" - }, - { - "language": "Java", - "code": "client.indices().putTemplate(p -> p\n .indexPatterns(List.of(\"te*\",\"bar*\"))\n .mappings(m -> m\n .source(s -> s\n .enabled(false)\n )\n )\n .name(\"template_1\")\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" - } - ], - "specification/indices/put_data_stream_mappings/examples/request/IndicesPutDataStreamMappingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_data_stream_mappings(\n name=\"my-data-stream\",\n mappings={\n \"properties\": {\n \"field1\": {\n \"type\": \"ip\"\n },\n \"field3\": {\n \"type\": \"text\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putDataStreamMappings({\n name: \"my-data-stream\",\n mappings: {\n properties: {\n field1: {\n type: \"ip\",\n },\n field3: {\n type: \"text\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_data_stream_mappings(\n name: \"my-data-stream\",\n body: {\n \"properties\": {\n \"field1\": {\n \"type\": \"ip\"\n },\n \"field3\": {\n \"type\": \"text\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putDataStreamMappings([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"properties\" => [\n \"field1\" => [\n \"type\" => \"ip\",\n ],\n \"field3\" => [\n \"type\" => \"text\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"properties\":{\"field1\":{\"type\":\"ip\"},\"field3\":{\"type\":\"text\"}}}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_mappings\"" - } - ], - "specification/indices/delete_data_lifecycle/examples/request/IndicesDeleteDataLifecycleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete_data_lifecycle(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.deleteDataLifecycle({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete_data_lifecycle(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->deleteDataLifecycle([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_lifecycle\"" - }, - { - "language": "Java", - "code": "client.indices().deleteDataLifecycle(d -> d\n .name(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_create_from/my-index/my-new-index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n {},\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_create_from/my-index/my-new-index\",\n);\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_create_from/my-index/my-new-index\"" - }, - { - "language": "Java", - "code": "client.indices().createFrom(c -> c\n .dest(\"my-new-index\")\n .source(\"my-index\")\n .createFrom(cr -> cr)\n);\n" - } - ], - "specification/indices/close/examples/request/CloseIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.close(\n index=\"my-index-00001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.close({\n index: \"my-index-00001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.close(\n index: \"my-index-00001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->close([\n \"index\" => \"my-index-00001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-00001/_close\"" - }, - { - "language": "Java", - "code": "client.indices().close(c -> c\n .index(\"my-index-00001\")\n);\n" - } - ], - "specification/indices/get_migrate_reindex_status/examples/request/IndicesGetMigrateReindexStatusExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"GET\",\n path: \"/_migration/reindex/my-data-stream/_status\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n {},\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"GET\",\n \"/_migration/reindex/my-data-stream/_status\",\n);\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/reindex/my-data-stream/_status\"" - }, - { - "language": "Java", - "code": "client.indices().getMigrateReindexStatus(g -> g\n .index(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/get_settings/examples/request/IndicesGetSettingsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_settings(\n index=\"_all\",\n expand_wildcards=\"all\",\n filter_path=\"*.settings.index.*.slowlog\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getSettings({\n index: \"_all\",\n expand_wildcards: \"all\",\n filter_path: \"*.settings.index.*.slowlog\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_settings(\n index: \"_all\",\n expand_wildcards: \"all\",\n filter_path: \"*.settings.index.*.slowlog\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getSettings([\n \"index\" => \"_all\",\n \"expand_wildcards\" => \"all\",\n \"filter_path\" => \"*.settings.index.*.slowlog\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_all/_settings?expand_wildcards=all&filter_path=*.settings.index.*.slowlog\"" - } - ], - "specification/indices/promote_data_stream/examples/request/IndicesPromoteDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.promote_data_stream(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.promoteDataStream({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.promote_data_stream(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->promoteDataStream([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/_promote/my-data-stream\"" - }, - { - "language": "Java", - "code": "client.indices().promoteDataStream(p -> p\n .name(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/flush/examples/request/IndicesFlushExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.flush()" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.flush();" - }, - { - "language": "Ruby", - "code": "response = client.indices.flush" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->flush();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_flush\"" - }, - { - "language": "Java", - "code": "client.indices().flush(f -> f);\n" - } - ], - "specification/indices/delete/examples/request/IndicesDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete(\n index=\"books\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.delete({\n index: \"books\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete(\n index: \"books\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->delete([\n \"index\" => \"books\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/books\"" - }, - { - "language": "Java", - "code": "client.indices().delete(d -> d\n .index(\"books\")\n);\n" - } - ], - "specification/indices/refresh/examples/request/IndicesRefreshExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.refresh()" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.refresh();" - }, - { - "language": "Ruby", - "code": "response = client.indices.refresh" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->refresh();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_refresh\"" - }, - { - "language": "Java", - "code": "client.indices().refresh(r -> r);\n" - } - ], - "specification/indices/resolve_index/examples/request/ResolveIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.resolve_index(\n name=\"f*,remoteCluster1:bar*\",\n expand_wildcards=\"all\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.resolveIndex({\n name: \"f*,remoteCluster1:bar*\",\n expand_wildcards: \"all\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.resolve_index(\n name: \"f*,remoteCluster1:bar*\",\n expand_wildcards: \"all\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->resolveIndex([\n \"name\" => \"f*,remoteCluster1:bar*\",\n \"expand_wildcards\" => \"all\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_resolve/index/f*,remoteCluster1:bar*?expand_wildcards=all\"" - } - ], - "specification/indices/exists/examples/request/IndicesExistsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.exists(\n index=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.exists({\n index: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.exists(\n index: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->exists([\n \"index\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-data-stream\"" - }, - { - "language": "Java", - "code": "client.indices().exists(e -> e\n .index(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.recovery(\n human=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.recovery({\n human: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.recovery(\n human: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->recovery([\n \"human\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_recovery?human\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"analysis\": {\n \"analyzer\": {\n \"content\": {\n \"type\": \"custom\",\n \"tokenizer\": \"whitespace\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n analysis: {\n analyzer: {\n content: {\n type: \"custom\",\n tokenizer: \"whitespace\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"analysis\": {\n \"analyzer\": {\n \"content\": {\n \"type\": \"custom\",\n \"tokenizer\": \"whitespace\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"analysis\" => [\n \"analyzer\" => [\n \"content\" => [\n \"type\" => \"custom\",\n \"tokenizer\" => \"whitespace\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis\":{\"analyzer\":{\"content\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" - }, - { - "language": "Java", - "code": "client.indices().putSettings(p -> p\n .index(\"my-index-000001\")\n .settings(s -> s\n .analysis(a -> a\n .analyzer(\"content\", an -> an\n .custom(c -> c\n .tokenizer(\"whitespace\")\n )\n )\n )\n )\n);\n" - } - ], - "specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"index\": {\n \"refresh_interval\": None\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n index: {\n refresh_interval: null,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"index\": {\n \"refresh_interval\": nil\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"index\" => [\n \"refresh_interval\" => null,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":{\"refresh_interval\":null}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" - } - ], - "specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_settings(\n index=\"my-index-000001\",\n settings={\n \"index\": {\n \"number_of_replicas\": 2\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putSettings({\n index: \"my-index-000001\",\n settings: {\n index: {\n number_of_replicas: 2,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_settings(\n index: \"my-index-000001\",\n body: {\n \"index\": {\n \"number_of_replicas\": 2\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putSettings([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"index\" => [\n \"number_of_replicas\" => 2,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":{\"number_of_replicas\":2}}' \"$ELASTICSEARCH_URL/my-index-000001/_settings\"" - }, - { - "language": "Java", - "code": "client.indices().putSettings(p -> p\n .index(\"my-index-000001\")\n .settings(s -> s\n .index(i -> i\n .numberOfReplicas(\"2\")\n )\n )\n);\n" - } - ], - "specification/indices/clear_cache/examples/request/IndicesClearCacheExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.clear_cache(\n index=\"my-index-000001,my-index-000002\",\n request=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.clearCache({\n index: \"my-index-000001,my-index-000002\",\n request: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.clear_cache(\n index: \"my-index-000001,my-index-000002\",\n request: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->clearCache([\n \"index\" => \"my-index-000001,my-index-000002\",\n \"request\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001,my-index-000002/_cache/clear?request=true\"" - }, - { - "language": "Java", - "code": "client.indices().clearCache(c -> c\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n .request(true)\n);\n" - } - ], - "specification/indices/reload_search_analyzers/examples/request/ReloadSearchAnalyzersRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.reload_search_analyzers(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.reloadSearchAnalyzers({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.reload_search_analyzers(\n index: \"my-index-000001\",\n body: {\n \"_shards\": {\n \"total\": 2,\n \"successful\": 2,\n \"failed\": 0\n },\n \"reload_details\": [\n {\n \"index\": \"my-index-000001\",\n \"reloaded_analyzers\": [\n \"my_synonyms\"\n ],\n \"reloaded_node_ids\": [\n \"mfdqTXn_T7SGr2Ho2KT8uw\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->reloadSearchAnalyzers([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"_shards\" => [\n \"total\" => 2,\n \"successful\" => 2,\n \"failed\" => 0,\n ],\n \"reload_details\" => array(\n [\n \"index\" => \"my-index-000001\",\n \"reloaded_analyzers\" => array(\n \"my_synonyms\",\n ),\n \"reloaded_node_ids\" => array(\n \"mfdqTXn_T7SGr2Ho2KT8uw\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"_shards\":{\"total\":2,\"successful\":2,\"failed\":0},\"reload_details\":[{\"index\":\"my-index-000001\",\"reloaded_analyzers\":[\"my_synonyms\"],\"reloaded_node_ids\":[\"mfdqTXn_T7SGr2Ho2KT8uw\"]}]}' \"$ELASTICSEARCH_URL/my-index-000001/_reload_search_analyzers\"" - } - ], - "specification/indices/cancel_migrate_reindex/examples/request/IndicesCancelMigrateReindexExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_migration/reindex/my-data-stream/_cancel\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n {},\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_migration/reindex/my-data-stream/_cancel\",\n);\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/reindex/my-data-stream/_cancel\"" - }, - { - "language": "Java", - "code": "client.indices().cancelMigrateReindex(c -> c\n .index(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/delete_data_stream/examples/request/IndicesDeleteDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete_data_stream(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.deleteDataStream({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete_data_stream(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->deleteDataStream([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream\"" - }, - { - "language": "Java", - "code": "client.indices().deleteDataStream(d -> d\n .name(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/get/examples/request/IndicesGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.get({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->get([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001\"" - }, - { - "language": "Java", - "code": "client.indices().get(g -> g\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/disk_usage/examples/request/IndicesDiskUsageExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.disk_usage(\n index=\"my-index-000001\",\n run_expensive_tasks=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.diskUsage({\n index: \"my-index-000001\",\n run_expensive_tasks: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.disk_usage(\n index: \"my-index-000001\",\n run_expensive_tasks: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->diskUsage([\n \"index\" => \"my-index-000001\",\n \"run_expensive_tasks\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_disk_usage?run_expensive_tasks=true\"" - }, - { - "language": "Java", - "code": "client.indices().diskUsage(d -> d\n .index(\"my-index-000001\")\n .runExpensiveTasks(true)\n);\n" - } - ], - "specification/indices/create_data_stream/examples/request/IndicesCreateDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.create_data_stream(\n name=\"logs-foo-bar\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.createDataStream({\n name: \"logs-foo-bar\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.create_data_stream(\n name: \"logs-foo-bar\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->createDataStream([\n \"name\" => \"logs-foo-bar\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/logs-foo-bar\"" - }, - { - "language": "Java", - "code": "client.indices().createDataStream(c -> c\n .name(\"logs-foo-bar\")\n);\n" - } - ], - "specification/indices/delete_alias/examples/request/IndicesDeleteAliasExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.delete_alias(\n index=\"my-data-stream\",\n name=\"my-alias\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.deleteAlias({\n index: \"my-data-stream\",\n name: \"my-alias\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.delete_alias(\n index: \"my-data-stream\",\n name: \"my-alias\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->deleteAlias([\n \"index\" => \"my-data-stream\",\n \"name\" => \"my-alias\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-data-stream/_alias/my-alias\"" - }, - { - "language": "Java", - "code": "client.indices().deleteAlias(d -> d\n .index(\"my-data-stream\")\n .name(\"my-alias\")\n);\n" - } - ], - "specification/indices/forcemerge/examples/request/IndicesForcemergeExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.forcemerge(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.forcemerge({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.forcemerge(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->forcemerge([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_forcemerge\"" - }, - { - "language": "Java", - "code": "client.indices().forcemerge(f -> f\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.downsample(\n index=\"my-time-series-index\",\n target_index=\"my-downsampled-time-series-index\",\n config={\n \"fixed_interval\": \"1d\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.downsample({\n index: \"my-time-series-index\",\n target_index: \"my-downsampled-time-series-index\",\n config: {\n fixed_interval: \"1d\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.downsample(\n index: \"my-time-series-index\",\n target_index: \"my-downsampled-time-series-index\",\n body: {\n \"fixed_interval\": \"1d\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->downsample([\n \"index\" => \"my-time-series-index\",\n \"target_index\" => \"my-downsampled-time-series-index\",\n \"body\" => [\n \"fixed_interval\" => \"1d\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fixed_interval\":\"1d\"}' \"$ELASTICSEARCH_URL/my-time-series-index/_downsample/my-downsampled-time-series-index\"" - }, - { - "language": "Java", - "code": "client.indices().downsample(d -> d\n .index(\"my-time-series-index\")\n .targetIndex(\"my-downsampled-time-series-index\")\n .config(c -> c\n .fixedInterval(f -> f\n .time(\"1d\")\n )\n )\n);\n" - } - ], - "specification/indices/get_template/examples/request/IndicesGetTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_template(\n name=\".monitoring-*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getTemplate({\n name: \".monitoring-*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_template(\n name: \".monitoring-*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getTemplate([\n \"name\" => \".monitoring-*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/.monitoring-*\"" - }, - { - "language": "Java", - "code": "client.indices().getTemplate(g -> g\n .name(\".monitoring-*\")\n);\n" - } - ], - "specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.shrink(\n index=\"my_source_index\",\n target=\"my_target_index\",\n settings={\n \"index.routing.allocation.require._name\": None,\n \"index.blocks.write\": None\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.shrink({\n index: \"my_source_index\",\n target: \"my_target_index\",\n settings: {\n \"index.routing.allocation.require._name\": null,\n \"index.blocks.write\": null,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.shrink(\n index: \"my_source_index\",\n target: \"my_target_index\",\n body: {\n \"settings\": {\n \"index.routing.allocation.require._name\": nil,\n \"index.blocks.write\": nil\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->shrink([\n \"index\" => \"my_source_index\",\n \"target\" => \"my_target_index\",\n \"body\" => [\n \"settings\" => [\n \"index.routing.allocation.require._name\" => null,\n \"index.blocks.write\" => null,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.routing.allocation.require._name\":null,\"index.blocks.write\":null}}' \"$ELASTICSEARCH_URL/my_source_index/_shrink/my_target_index\"" - }, - { - "language": "Java", - "code": "client.indices().shrink(s -> s\n .index(\"my_source_index\")\n .settings(Map.of(\"index.blocks.write\", JsonData.fromJson(\"null\"),\"index.routing.allocation.require._name\", JsonData.fromJson(\"null\")))\n .target(\"my_target_index\")\n);\n" - } - ], - "specification/indices/explain_data_lifecycle/examples/request/IndicesExplainDataLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.explain_data_lifecycle(\n index=\".ds-metrics-2023.03.22-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.explainDataLifecycle({\n index: \".ds-metrics-2023.03.22-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.explain_data_lifecycle(\n index: \".ds-metrics-2023.03.22-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->explainDataLifecycle([\n \"index\" => \".ds-metrics-2023.03.22-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-metrics-2023.03.22-000001/_lifecycle/explain\"" - }, - { - "language": "Java", - "code": "client.indices().explainDataLifecycle(e -> e\n .index(\".ds-metrics-2023.03.22-000001\")\n);\n" - } - ], - "specification/indices/get_mapping/examples/request/IndicesGetMappingExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_mapping(\n index=\"books\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getMapping({\n index: \"books\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_mapping(\n index: \"books\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getMapping([\n \"index\" => \"books\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/books/_mapping\"" - }, - { - "language": "Java", - "code": "client.indices().getMapping(g -> g\n .index(\"books\")\n);\n" - } - ], - "specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_data_lifecycle_stats(\n human=True,\n pretty=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getDataLifecycleStats({\n human: \"true\",\n pretty: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_data_lifecycle_stats(\n human: \"true\",\n pretty: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getDataLifecycleStats([\n \"human\" => \"true\",\n \"pretty\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_lifecycle/stats?human&pretty\"" - }, - { - "language": "Java", - "code": "client.indices().getDataLifecycleStats();\n" - } - ], - "specification/indices/add_block/examples/request/IndicesAddBlockRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.add_block(\n index=\"my-index-000001\",\n block=\"write\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.addBlock({\n index: \"my-index-000001\",\n block: \"write\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.add_block(\n index: \"my-index-000001\",\n block: \"write\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->addBlock([\n \"index\" => \"my-index-000001\",\n \"block\" => \"write\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_block/write\"" - }, - { - "language": "Java", - "code": "client.indices().addBlock(a -> a\n .block(IndicesBlockOptions.Write)\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.rollover(\n alias=\"my-data-stream\",\n conditions={\n \"max_age\": \"7d\",\n \"max_docs\": 1000,\n \"max_primary_shard_size\": \"50gb\",\n \"max_primary_shard_docs\": \"2000\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.rollover({\n alias: \"my-data-stream\",\n conditions: {\n max_age: \"7d\",\n max_docs: 1000,\n max_primary_shard_size: \"50gb\",\n max_primary_shard_docs: \"2000\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.rollover(\n alias: \"my-data-stream\",\n body: {\n \"conditions\": {\n \"max_age\": \"7d\",\n \"max_docs\": 1000,\n \"max_primary_shard_size\": \"50gb\",\n \"max_primary_shard_docs\": \"2000\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->rollover([\n \"alias\" => \"my-data-stream\",\n \"body\" => [\n \"conditions\" => [\n \"max_age\" => \"7d\",\n \"max_docs\" => 1000,\n \"max_primary_shard_size\" => \"50gb\",\n \"max_primary_shard_docs\" => \"2000\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"conditions\":{\"max_age\":\"7d\",\"max_docs\":1000,\"max_primary_shard_size\":\"50gb\",\"max_primary_shard_docs\":\"2000\"}}' \"$ELASTICSEARCH_URL/my-data-stream/_rollover\"" - }, - { - "language": "Java", - "code": "client.indices().rollover(r -> r\n .alias(\"my-data-stream\")\n .conditions(c -> c\n .maxAge(m -> m\n .time(\"7d\")\n )\n .maxDocs(1000L)\n .maxPrimaryShardSize(\"50gb\")\n .maxPrimaryShardDocs(2000L)\n )\n);\n" - } - ], - "specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_data_lifecycle(\n name=\"my-data-stream\",\n data_retention=\"7d\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putDataLifecycle({\n name: \"my-data-stream\",\n data_retention: \"7d\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_data_lifecycle(\n name: \"my-data-stream\",\n body: {\n \"data_retention\": \"7d\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putDataLifecycle([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"data_retention\" => \"7d\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"data_retention\":\"7d\"}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_lifecycle\"" - }, - { - "language": "Java", - "code": "client.indices().putDataLifecycle(p -> p\n .dataRetention(d -> d\n .time(\"7d\")\n )\n .name(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_data_lifecycle(\n name=\"my-weather-sensor-data-stream\",\n downsampling=[\n {\n \"after\": \"1d\",\n \"fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \"fixed_interval\": \"1d\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putDataLifecycle({\n name: \"my-weather-sensor-data-stream\",\n downsampling: [\n {\n after: \"1d\",\n fixed_interval: \"10m\",\n },\n {\n after: \"7d\",\n fixed_interval: \"1d\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_data_lifecycle(\n name: \"my-weather-sensor-data-stream\",\n body: {\n \"downsampling\": [\n {\n \"after\": \"1d\",\n \"fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \"fixed_interval\": \"1d\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putDataLifecycle([\n \"name\" => \"my-weather-sensor-data-stream\",\n \"body\" => [\n \"downsampling\" => array(\n [\n \"after\" => \"1d\",\n \"fixed_interval\" => \"10m\",\n ],\n [\n \"after\" => \"7d\",\n \"fixed_interval\" => \"1d\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"downsampling\":[{\"after\":\"1d\",\"fixed_interval\":\"10m\"},{\"after\":\"7d\",\"fixed_interval\":\"1d\"}]}' \"$ELASTICSEARCH_URL/_data_stream/my-weather-sensor-data-stream/_lifecycle\"" - } - ], - "specification/indices/exists_template/examples/request/IndicesExistsTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.exists_template(\n name=\"template_1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.existsTemplate({\n name: \"template_1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.exists_template(\n name: \"template_1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->existsTemplate([\n \"name\" => \"template_1\",\n]);" - }, - { - "language": "curl", - "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_template/template_1\"" - }, - { - "language": "Java", - "code": "client.indices().existsTemplate(e -> e\n .name(\"template_1\")\n);\n" - } - ], - "specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.validate_query(\n index=\"my-index-000001\",\n q=\"user.id:kimchy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.validateQuery({\n index: \"my-index-000001\",\n q: \"user.id:kimchy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.validate_query(\n index: \"my-index-000001\",\n q: \"user.id:kimchy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->validateQuery([\n \"index\" => \"my-index-000001\",\n \"q\" => \"user.id:kimchy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_validate/query?q=user.id:kimchy\"" - }, - { - "language": "Java", - "code": "client.indices().validateQuery(v -> v\n .index(\"my-index-000001\")\n .q(\"user.id:kimchy\")\n);\n" - } - ], - "specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_index_template(\n name=\"template_1\",\n index_patterns=[\n \"template*\"\n ],\n priority=1,\n template={\n \"settings\": {\n \"number_of_shards\": 2\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putIndexTemplate({\n name: \"template_1\",\n index_patterns: [\"template*\"],\n priority: 1,\n template: {\n settings: {\n number_of_shards: 2,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_index_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"template*\"\n ],\n \"priority\": 1,\n \"template\": {\n \"settings\": {\n \"number_of_shards\": 2\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putIndexTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"template*\",\n ),\n \"priority\" => 1,\n \"template\" => [\n \"settings\" => [\n \"number_of_shards\" => 2,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"template*\"],\"priority\":1,\"template\":{\"settings\":{\"number_of_shards\":2}}}' \"$ELASTICSEARCH_URL/_index_template/template_1\"" - }, - { - "language": "Java", - "code": "client.indices().putIndexTemplate(p -> p\n .indexPatterns(\"template*\")\n .name(\"template_1\")\n .priority(1L)\n .template(t -> t\n .settings(s -> s\n .numberOfShards(\"2\")\n )\n )\n);\n" - } - ], - "specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_index_template(\n name=\"template_1\",\n index_patterns=[\n \"template*\"\n ],\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)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putIndexTemplate({\n name: \"template_1\",\n index_patterns: [\"template*\"],\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});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_index_template(\n name: \"template_1\",\n body: {\n \"index_patterns\": [\n \"template*\"\n ],\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)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putIndexTemplate([\n \"name\" => \"template_1\",\n \"body\" => [\n \"index_patterns\" => array(\n \"template*\",\n ),\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]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"template*\"],\"template\":{\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}}' \"$ELASTICSEARCH_URL/_index_template/template_1\"" - }, - { - "language": "Java", - "code": "client.indices().putIndexTemplate(p -> p\n .indexPatterns(\"template*\")\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 .settings(s -> s\n .numberOfShards(\"1\")\n )\n )\n);\n" - } - ], - "specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.clone(\n index=\"my_source_index\",\n target=\"my_target_index\",\n settings={\n \"index.refresh_interval\": \"2s\"\n },\n aliases={\n \"my_search_indices\": {}\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.clone({\n index: \"my_source_index\",\n target: \"my_target_index\",\n settings: {\n \"index.refresh_interval\": \"2s\",\n },\n aliases: {\n my_search_indices: {},\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.clone(\n index: \"my_source_index\",\n target: \"my_target_index\",\n body: {\n \"settings\": {\n \"index.refresh_interval\": \"2s\"\n },\n \"aliases\": {\n \"my_search_indices\": {}\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->clone([\n \"index\" => \"my_source_index\",\n \"target\" => \"my_target_index\",\n \"body\" => [\n \"settings\" => [\n \"index.refresh_interval\" => \"2s\",\n ],\n \"aliases\" => [\n \"my_search_indices\" => new ArrayObject([]),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"index.refresh_interval\":\"2s\"},\"aliases\":{\"my_search_indices\":{}}}' \"$ELASTICSEARCH_URL/my_source_index/_clone/my_target_index\"" - }, - { - "language": "Java", - "code": "client.indices().clone(c -> c\n .aliases(\"my_search_indices\", a -> a)\n .index(\"my_source_index\")\n .settings(\"index.number_of_shards\", JsonData.fromJson(\"5\"))\n .target(\"my_target_index\")\n);\n" - } - ], - "specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_index_template(\n name=\"*\",\n filter_path=\"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getIndexTemplate({\n name: \"*\",\n filter_path:\n \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_index_template(\n name: \"*\",\n filter_path: \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getIndexTemplate([\n \"name\" => \"*\",\n \"filter_path\" => \"index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_data_lifecycle(\n name=\"{name}\",\n human=True,\n pretty=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getDataLifecycle({\n name: \"{name}\",\n human: \"true\",\n pretty: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_data_lifecycle(\n name: \"{name}\",\n human: \"true\",\n pretty: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getDataLifecycle([\n \"name\" => \"{name}\",\n \"human\" => \"true\",\n \"pretty\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/%7Bname%7D/_lifecycle?human&pretty\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/indices/get_data_stream/examples/request/IndicesGetDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_data_stream(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getDataStream({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_data_stream(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getDataStream([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream\"" - }, - { - "language": "Java", - "code": "client.indices().getDataStream(g -> g\n .name(\"my-data-stream\")\n);\n" - } - ], - "specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.modify_data_stream(\n actions=[\n {\n \"remove_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001\"\n }\n },\n {\n \"add_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001-downsample\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.modifyDataStream({\n actions: [\n {\n remove_backing_index: {\n data_stream: \"my-data-stream\",\n index: \".ds-my-data-stream-2023.07.26-000001\",\n },\n },\n {\n add_backing_index: {\n data_stream: \"my-data-stream\",\n index: \".ds-my-data-stream-2023.07.26-000001-downsample\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.modify_data_stream(\n body: {\n \"actions\": [\n {\n \"remove_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001\"\n }\n },\n {\n \"add_backing_index\": {\n \"data_stream\": \"my-data-stream\",\n \"index\": \".ds-my-data-stream-2023.07.26-000001-downsample\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->modifyDataStream([\n \"body\" => [\n \"actions\" => array(\n [\n \"remove_backing_index\" => [\n \"data_stream\" => \"my-data-stream\",\n \"index\" => \".ds-my-data-stream-2023.07.26-000001\",\n ],\n ],\n [\n \"add_backing_index\" => [\n \"data_stream\" => \"my-data-stream\",\n \"index\" => \".ds-my-data-stream-2023.07.26-000001-downsample\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"remove_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001\"}},{\"add_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001-downsample\"}}]}' \"$ELASTICSEARCH_URL/_data_stream/_modify\"" - }, - { - "language": "Java", - "code": "client.indices().modifyDataStream(m -> m\n .actions(List.of(Action.of(a -> a\n .removeBackingIndex(r -> r\n .dataStream(\"my-data-stream\")\n .index(\".ds-my-data-stream-2023.07.26-000001\")\n )),Action.of(ac -> ac\n .addBackingIndex(ad -> ad\n .dataStream(\"my-data-stream\")\n .index(\".ds-my-data-stream-2023.07.26-000001-downsample\")\n ))))\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n tokenizer=\"keyword\",\n filter=[\n \"lowercase\"\n ],\n char_filter=[\n \"html_strip\"\n ],\n text=\"this is a test\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n tokenizer: \"keyword\",\n filter: [\"lowercase\"],\n char_filter: [\"html_strip\"],\n text: \"this is a test\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"keyword\",\n \"filter\": [\n \"lowercase\"\n ],\n \"char_filter\": [\n \"html_strip\"\n ],\n \"text\": \"this is a test\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"keyword\",\n \"filter\" => array(\n \"lowercase\",\n ),\n \"char_filter\" => array(\n \"html_strip\",\n ),\n \"text\" => \"this is a test\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"keyword\",\"filter\":[\"lowercase\"],\"char_filter\":[\"html_strip\"],\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .charFilter(c -> c\n .name(\"html_strip\")\n )\n .filter(f -> f\n .name(\"lowercase\")\n )\n .text(\"this is a test\")\n .tokenizer(t -> t\n .name(\"keyword\")\n )\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n analyzer=\"standard\",\n text=[\n \"this is a test\",\n \"the second text\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n analyzer: \"standard\",\n text: [\"this is a test\", \"the second text\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n body: {\n \"analyzer\": \"standard\",\n \"text\": [\n \"this is a test\",\n \"the second text\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"analyzer\" => \"standard\",\n \"text\" => array(\n \"this is a test\",\n \"the second text\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analyzer\":\"standard\",\"text\":[\"this is a test\",\"the second text\"]}' \"$ELASTICSEARCH_URL/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .analyzer(\"standard\")\n .text(List.of(\"this is a test\",\"the second text\"))\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n index=\"analyze_sample\",\n field=\"obj1.field1\",\n text=\"this is a test\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n index: \"analyze_sample\",\n field: \"obj1.field1\",\n text: \"this is a test\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n index: \"analyze_sample\",\n body: {\n \"field\": \"obj1.field1\",\n \"text\": \"this is a test\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"index\" => \"analyze_sample\",\n \"body\" => [\n \"field\" => \"obj1.field1\",\n \"text\" => \"this is a test\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"field\":\"obj1.field1\",\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/analyze_sample/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .field(\"obj1.field1\")\n .index(\"analyze_sample\")\n .text(\"this is a test\")\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n tokenizer=\"whitespace\",\n filter=[\n \"lowercase\",\n {\n \"type\": \"stop\",\n \"stopwords\": [\n \"a\",\n \"is\",\n \"this\"\n ]\n }\n ],\n text=\"this is a test\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n tokenizer: \"whitespace\",\n filter: [\n \"lowercase\",\n {\n type: \"stop\",\n stopwords: [\"a\", \"is\", \"this\"],\n },\n ],\n text: \"this is a test\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"whitespace\",\n \"filter\": [\n \"lowercase\",\n {\n \"type\": \"stop\",\n \"stopwords\": [\n \"a\",\n \"is\",\n \"this\"\n ]\n }\n ],\n \"text\": \"this is a test\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"whitespace\",\n \"filter\" => array(\n \"lowercase\",\n [\n \"type\" => \"stop\",\n \"stopwords\" => array(\n \"a\",\n \"is\",\n \"this\",\n ),\n ],\n ),\n \"text\" => \"this is a test\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"whitespace\",\"filter\":[\"lowercase\",{\"type\":\"stop\",\"stopwords\":[\"a\",\"is\",\"this\"]}],\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .filter(List.of(TokenFilter.of(t -> t\n .name(\"lowercase\"\n )),TokenFilter.of(to -> to\n .definition(d -> d\n .stop(s -> s\n .stopwords(List.of(\"a\",\"is\",\"this\"))\n )\n ))))\n .text(\"this is a test\")\n .tokenizer(tok -> tok\n .name(\"whitespace\")\n )\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n tokenizer=\"standard\",\n filter=[\n \"snowball\"\n ],\n text=\"detailed output\",\n explain=True,\n attributes=[\n \"keyword\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n tokenizer: \"standard\",\n filter: [\"snowball\"],\n text: \"detailed output\",\n explain: true,\n attributes: [\"keyword\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n body: {\n \"tokenizer\": \"standard\",\n \"filter\": [\n \"snowball\"\n ],\n \"text\": \"detailed output\",\n \"explain\": true,\n \"attributes\": [\n \"keyword\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"tokenizer\" => \"standard\",\n \"filter\" => array(\n \"snowball\",\n ),\n \"text\" => \"detailed output\",\n \"explain\" => true,\n \"attributes\" => array(\n \"keyword\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"standard\",\"filter\":[\"snowball\"],\"text\":\"detailed output\",\"explain\":true,\"attributes\":[\"keyword\"]}' \"$ELASTICSEARCH_URL/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .attributes(\"keyword\")\n .explain(true)\n .filter(f -> f\n .name(\"snowball\")\n )\n .text(\"detailed output\")\n .tokenizer(t -> t\n .name(\"standard\")\n )\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n index=\"analyze_sample\",\n normalizer=\"my_normalizer\",\n text=\"BaR\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n index: \"analyze_sample\",\n normalizer: \"my_normalizer\",\n text: \"BaR\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n index: \"analyze_sample\",\n body: {\n \"normalizer\": \"my_normalizer\",\n \"text\": \"BaR\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"index\" => \"analyze_sample\",\n \"body\" => [\n \"normalizer\" => \"my_normalizer\",\n \"text\" => \"BaR\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"normalizer\":\"my_normalizer\",\"text\":\"BaR\"}' \"$ELASTICSEARCH_URL/analyze_sample/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .index(\"analyze_sample\")\n .normalizer(\"my_normalizer\")\n .text(\"BaR\")\n);\n" - } - ], - "specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.analyze(\n analyzer=\"standard\",\n text=\"this is a test\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.analyze({\n analyzer: \"standard\",\n text: \"this is a test\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.analyze(\n body: {\n \"analyzer\": \"standard\",\n \"text\": \"this is a test\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->analyze([\n \"body\" => [\n \"analyzer\" => \"standard\",\n \"text\" => \"this is a test\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analyzer\":\"standard\",\"text\":\"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" - }, - { - "language": "Java", - "code": "client.indices().analyze(a -> a\n .analyzer(\"standard\")\n .text(\"this is a test\")\n);\n" - } - ], - "specification/indices/shard_stores/examples/request/indicesShardStoresRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.shard_stores(\n status=\"green\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.shardStores({\n status: \"green\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.shard_stores(\n status: \"green\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->shardStores([\n \"status\" => \"green\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_shard_stores?status=green\"" - } - ], - "specification/indices/get_data_stream_settings/examples/request/IndicesGetDataStreamSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_data_stream_settings(\n name=\"my-data-stream\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getDataStreamSettings({\n name: \"my-data-stream\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_data_stream_settings(\n name: \"my-data-stream\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getDataStreamSettings([\n \"name\" => \"my-data-stream\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_settings\"" - } - ], - "specification/indices/get_alias/examples/request/IndicesGetAliasExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_alias()" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getAlias();" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_alias" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getAlias();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_alias\"" - }, - { - "language": "Java", - "code": "client.indices().getAlias(g -> g);\n" - } - ], - "specification/indices/remove_block/examples/request/IndicesRemoveBlockRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.remove_block(\n index=\"my-index-000001\",\n block=\"write\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.removeBlock({\n index: \"my-index-000001\",\n block: \"write\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.remove_block(\n index: \"my-index-000001\",\n block: \"write\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->removeBlock([\n \"index\" => \"my-index-000001\",\n \"block\" => \"write\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_block/write\"" - }, - { - "language": "Java", - "code": "client.indices().removeBlock(a -> a\n .block(IndicesBlockOptions.Write)\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.update_aliases(\n actions=[\n {\n \"add\": {\n \"index\": \"my-data-stream\",\n \"alias\": \"my-alias\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.updateAliases({\n actions: [\n {\n add: {\n index: \"my-data-stream\",\n alias: \"my-alias\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.update_aliases(\n body: {\n \"actions\": [\n {\n \"add\": {\n \"index\": \"my-data-stream\",\n \"alias\": \"my-alias\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->updateAliases([\n \"body\" => [\n \"actions\" => array(\n [\n \"add\" => [\n \"index\" => \"my-data-stream\",\n \"alias\" => \"my-alias\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"actions\":[{\"add\":{\"index\":\"my-data-stream\",\"alias\":\"my-alias\"}}]}' \"$ELASTICSEARCH_URL/_aliases\"" - }, - { - "language": "Java", - "code": "client.indices().updateAliases(u -> u\n .actions(a -> a\n .add(ad -> ad\n .alias(\"my-alias\")\n .index(\"my-data-stream\")\n )\n )\n);\n" - } - ], - "specification/indices/put_data_stream_settings/examples/request/IndicesPutDataStreamSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_data_stream_settings(\n name=\"my-data-stream\",\n settings={\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putDataStreamSettings({\n name: \"my-data-stream\",\n settings: {\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_data_stream_settings(\n name: \"my-data-stream\",\n body: {\n \"index.lifecycle.name\": \"new-test-policy\",\n \"index.number_of_shards\": 11\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putDataStreamSettings([\n \"name\" => \"my-data-stream\",\n \"body\" => [\n \"index.lifecycle.name\" => \"new-test-policy\",\n \"index.number_of_shards\" => 11,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index.lifecycle.name\":\"new-test-policy\",\"index.number_of_shards\":11}' \"$ELASTICSEARCH_URL/_data_stream/my-data-stream/_settings\"" - } - ], - "specification/indices/get_field_mapping/examples/request/indicesGetFieldMappingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.get_field_mapping(\n index=\"publications\",\n fields=\"title\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.getFieldMapping({\n index: \"publications\",\n fields: \"title\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.get_field_mapping(\n index: \"publications\",\n fields: \"title\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->getFieldMapping([\n \"index\" => \"publications\",\n \"fields\" => \"title\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/publications/_mapping/field/title\"" - }, - { - "language": "Java", - "code": "client.indices().getFieldMapping(g -> g\n .fields(\"title\")\n .index(\"publications\")\n);\n" - } - ], - "specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"POST\",\n \"/_migration/reindex\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"source\": {\n \"index\": \"my-data-stream\"\n },\n \"mode\": \"upgrade\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_migration/reindex\",\n body: {\n source: {\n index: \"my-data-stream\",\n },\n mode: \"upgrade\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"POST\",\n \"/_migration/reindex\",\n {},\n {\n \"source\": {\n \"index\": \"my-data-stream\"\n },\n \"mode\": \"upgrade\"\n },\n { \"Content-Type\": \"application/json\" },\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_migration/reindex\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"source\" => [\n \"index\" => \"my-data-stream\",\n ],\n \"mode\" => \"upgrade\",\n ]),\n));\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-data-stream\"},\"mode\":\"upgrade\"}' \"$ELASTICSEARCH_URL/_migration/reindex\"" - }, - { - "language": "Java", - "code": "client.indices().migrateReindex(m -> m\n .reindex(r -> r\n .mode(ModeEnum.Upgrade)\n .source(s -> s\n .index(\"my-data-stream\")\n )\n )\n);\n" - } - ], - "specification/indices/create/examples/request/indicesCreateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.create(\n index=\"my-index-000001\",\n settings={\n \"number_of_shards\": 3,\n \"number_of_replicas\": 2\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.create({\n index: \"my-index-000001\",\n settings: {\n number_of_shards: 3,\n number_of_replicas: 2,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.create(\n index: \"my-index-000001\",\n body: {\n \"settings\": {\n \"number_of_shards\": 3,\n \"number_of_replicas\": 2\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->create([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"settings\" => [\n \"number_of_shards\" => 3,\n \"number_of_replicas\" => 2,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"number_of_shards\":3,\"number_of_replicas\":2}}' \"$ELASTICSEARCH_URL/my-index-000001\"" - }, - { - "language": "Java", - "code": "client.indices().create(c -> c\n .index(\"my-index-000001\")\n .settings(s -> s\n .numberOfShards(\"3\")\n .numberOfReplicas(\"2\")\n )\n);\n" - } - ], - "specification/indices/create/examples/request/indicesCreateRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.create(\n index=\"test\",\n settings={\n \"number_of_shards\": 1\n },\n mappings={\n \"properties\": {\n \"field1\": {\n \"type\": \"text\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.create({\n index: \"test\",\n settings: {\n number_of_shards: 1,\n },\n mappings: {\n properties: {\n field1: {\n type: \"text\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.create(\n index: \"test\",\n body: {\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n \"properties\": {\n \"field1\": {\n \"type\": \"text\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->create([\n \"index\" => \"test\",\n \"body\" => [\n \"settings\" => [\n \"number_of_shards\" => 1,\n ],\n \"mappings\" => [\n \"properties\" => [\n \"field1\" => [\n \"type\" => \"text\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"settings\":{\"number_of_shards\":1},\"mappings\":{\"properties\":{\"field1\":{\"type\":\"text\"}}}}' \"$ELASTICSEARCH_URL/test\"" - }, - { - "language": "Java", - "code": "client.indices().create(c -> c\n .index(\"test\")\n .mappings(m -> m\n .properties(\"field1\", p -> p\n .text(t -> t)\n )\n )\n .settings(s -> s\n .numberOfShards(\"1\")\n )\n);\n" - } - ], - "specification/indices/create/examples/request/indicesCreateRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.create(\n index=\"test\",\n aliases={\n \"alias_1\": {},\n \"alias_2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.create({\n index: \"test\",\n aliases: {\n alias_1: {},\n alias_2: {\n filter: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n routing: \"shard-1\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.create(\n index: \"test\",\n body: {\n \"aliases\": {\n \"alias_1\": {},\n \"alias_2\": {\n \"filter\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"routing\": \"shard-1\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->create([\n \"index\" => \"test\",\n \"body\" => [\n \"aliases\" => [\n \"alias_1\" => new ArrayObject([]),\n \"alias_2\" => [\n \"filter\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"routing\" => \"shard-1\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"aliases\":{\"alias_1\":{},\"alias_2\":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"}}}' \"$ELASTICSEARCH_URL/test\"" - }, - { - "language": "Java", - "code": "client.indices().create(c -> c\n .aliases(Map.of(\"alias_2\", Alias.of(a -> a\n .filter(f -> f\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .routing(\"shard-1\")),\"alias_1\", Alias.of(al -> al)))\n .index(\"test\")\n);\n" - } - ], - "specification/indices/field_usage_stats/examples/request/indicesFieldUsageStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.field_usage_stats(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.fieldUsageStats({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.field_usage_stats(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->fieldUsageStats([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_field_usage_stats\"" - }, - { - "language": "Java", - "code": "client.indices().fieldUsageStats(f -> f\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/migrate_to_data_stream/examples/request/IndicesMigrateToDataStreamExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.migrate_to_data_stream(\n name=\"my-time-series-data\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.migrateToDataStream({\n name: \"my-time-series-data\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.migrate_to_data_stream(\n name: \"my-time-series-data\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->migrateToDataStream([\n \"name\" => \"my-time-series-data\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_data_stream/_migrate/my-time-series-data\"" - }, - { - "language": "Java", - "code": "client.indices().migrateToDataStream(m -> m\n .name(\"my-time-series-data\")\n);\n" - } - ], - "specification/indices/open/examples/request/IndicesOpenExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.open(\n index=\".ds-my-data-stream-2099.03.07-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.open({\n index: \".ds-my-data-stream-2099.03.07-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.open(\n index: \".ds-my-data-stream-2099.03.07-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->open([\n \"index\" => \".ds-my-data-stream-2099.03.07-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-my-data-stream-2099.03.07-000001/_open/\"" - }, - { - "language": "Java", - "code": "client.indices().open(o -> o\n .index(\".ds-my-data-stream-2099.03.07-000001\")\n);\n" - } - ], - "specification/indices/stats/examples/request/IndicesStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.stats(\n metric=\"fielddata\",\n human=True,\n fields=\"my_join_field\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.stats({\n metric: \"fielddata\",\n human: \"true\",\n fields: \"my_join_field\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.stats(\n metric: \"fielddata\",\n human: \"true\",\n fields: \"my_join_field\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->stats([\n \"metric\" => \"fielddata\",\n \"human\" => \"true\",\n \"fields\" => \"my_join_field\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_stats/fielddata?human&fields=my_join_field#question\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/indices/segments/examples/request/IndicesSegmentsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.segments(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.segments({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.segments(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->segments([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_segments\"" - }, - { - "language": "Java", - "code": "client.indices().segments(s -> s\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.put_mapping(\n index=\"my-index-000001\",\n properties={\n \"user\": {\n \"properties\": {\n \"name\": {\n \"type\": \"keyword\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.putMapping({\n index: \"my-index-000001\",\n properties: {\n user: {\n properties: {\n name: {\n type: \"keyword\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.put_mapping(\n index: \"my-index-000001\",\n body: {\n \"properties\": {\n \"user\": {\n \"properties\": {\n \"name\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->putMapping([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"properties\" => [\n \"user\" => [\n \"properties\" => [\n \"name\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"properties\":{\"user\":{\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_mapping\"" - }, - { - "language": "Java", - "code": "client.indices().putMapping(p -> p\n .index(\"my-index-000001\")\n .properties(\"user\", pr -> pr\n .object(o -> o\n .properties(\"name\", pro -> pro\n .keyword(k -> k)\n )\n )\n )\n);\n" - } - ], - "specification/indices/resolve_cluster/examples/request/ResolveClusterRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.indices.resolve_cluster(\n name=\"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable=False,\n timeout=\"5s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.indices.resolveCluster({\n name: \"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable: \"false\",\n timeout: \"5s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.indices.resolve_cluster(\n name: \"not-present,clust*:my-index*,oldcluster:*\",\n ignore_unavailable: \"false\",\n timeout: \"5s\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->indices()->resolveCluster([\n \"name\" => \"not-present,clust*:my-index*,oldcluster:*\",\n \"ignore_unavailable\" => \"false\",\n \"timeout\" => \"5s\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_resolve/cluster/not-present,clust*:my-index*,oldcluster:*?ignore_unavailable=false&timeout=5s\"" - }, - { - "language": "Java", - "code": "client.indices().resolveCluster(r -> r\n .ignoreUnavailable(false)\n .name(List.of(\"not-present\",\"clust*:my-index*\",\"oldcluster:*\"))\n .timeout(t -> t\n .offset(5)\n )\n);\n" - } - ], - "specification/_global/get_source/examples/request/GetSourceRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.get_source(\n index=\"my-index-000001\",\n id=\"1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.getSource({\n index: \"my-index-000001\",\n id: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.get_source(\n index: \"my-index-000001\",\n id: \"1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->getSource([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_source/1\"" - }, - { - "language": "Java", - "code": "client.getSource(g -> g\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.get_script_languages()" - }, - { - "language": "JavaScript", - "code": "const response = await client.getScriptLanguages();" - }, - { - "language": "Ruby", - "code": "response = client.get_script_languages" - }, - { - "language": "PHP", - "code": "$resp = $client->getScriptLanguages();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_script_language\"" - }, - { - "language": "Java", - "code": "client.getScriptLanguages();\n" - } - ], - "specification/_global/update_by_query_rethrottle/examples/request/UpdateByQueryRethrottleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.update_by_query_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.updateByQueryRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.update_by_query_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->updateByQueryRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_update_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" - }, - { - "language": "Java", - "code": "client.updateByQueryRethrottle(u -> u\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" - } - ], - "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"doc['field'].value.length() <= params.max_length\",\n \"params\": {\n \"max_length\": 4\n }\n },\n context=\"filter\",\n context_setup={\n \"index\": \"my-index-000001\",\n \"document\": {\n \"field\": \"four\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"doc['field'].value.length() <= params.max_length\",\n params: {\n max_length: 4,\n },\n },\n context: \"filter\",\n context_setup: {\n index: \"my-index-000001\",\n document: {\n field: \"four\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"doc['field'].value.length() <= params.max_length\",\n \"params\": {\n \"max_length\": 4\n }\n },\n \"context\": \"filter\",\n \"context_setup\": {\n \"index\": \"my-index-000001\",\n \"document\": {\n \"field\": \"four\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"doc['field'].value.length() <= params.max_length\",\n \"params\" => [\n \"max_length\" => 4,\n ],\n ],\n \"context\" => \"filter\",\n \"context_setup\" => [\n \"index\" => \"my-index-000001\",\n \"document\" => [\n \"field\" => \"four\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"doc['\"'\"'field'\"'\"'].value.length() <= params.max_length\",\"params\":{\"max_length\":4}},\"context\":\"filter\",\"context_setup\":{\"index\":\"my-index-000001\",\"document\":{\"field\":\"four\"}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" - }, - { - "language": "Java", - "code": "client.scriptsPainlessExecute(s -> s\n .context(PainlessContext.Filter)\n .contextSetup(c -> c\n .document(JsonData.fromJson(\"{\\\"field\\\":\\\"four\\\"}\"))\n .index(\"my-index-000001\")\n )\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"doc['field'].value.length() <= params.max_length\")\n )\n .params(\"max_length\", JsonData.fromJson(\"4\"))\n )\n);\n" - } - ], - "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"doc['rank'].value / params.max_rank\",\n \"params\": {\n \"max_rank\": 5\n }\n },\n context=\"score\",\n context_setup={\n \"index\": \"my-index-000001\",\n \"document\": {\n \"rank\": 4\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"doc['rank'].value / params.max_rank\",\n params: {\n max_rank: 5,\n },\n },\n context: \"score\",\n context_setup: {\n index: \"my-index-000001\",\n document: {\n rank: 4,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"doc['rank'].value / params.max_rank\",\n \"params\": {\n \"max_rank\": 5\n }\n },\n \"context\": \"score\",\n \"context_setup\": {\n \"index\": \"my-index-000001\",\n \"document\": {\n \"rank\": 4\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"doc['rank'].value / params.max_rank\",\n \"params\" => [\n \"max_rank\" => 5,\n ],\n ],\n \"context\" => \"score\",\n \"context_setup\" => [\n \"index\" => \"my-index-000001\",\n \"document\" => [\n \"rank\" => 4,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"doc['\"'\"'rank'\"'\"'].value / params.max_rank\",\"params\":{\"max_rank\":5}},\"context\":\"score\",\"context_setup\":{\"index\":\"my-index-000001\",\"document\":{\"rank\":4}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" - }, - { - "language": "Java", - "code": "client.scriptsPainlessExecute(s -> s\n .context(PainlessContext.Score)\n .contextSetup(c -> c\n .document(JsonData.fromJson(\"{\\\"rank\\\":4}\"))\n .index(\"my-index-000001\")\n )\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"doc['rank'].value / params.max_rank\")\n )\n .params(\"max_rank\", JsonData.fromJson(\"5\"))\n )\n);\n" - } - ], - "specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.scripts_painless_execute(\n script={\n \"source\": \"params.count / params.total\",\n \"params\": {\n \"count\": 100,\n \"total\": 1000\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.scriptsPainlessExecute({\n script: {\n source: \"params.count / params.total\",\n params: {\n count: 100,\n total: 1000,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.scripts_painless_execute(\n body: {\n \"script\": {\n \"source\": \"params.count / params.total\",\n \"params\": {\n \"count\": 100,\n \"total\": 1000\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->scriptsPainlessExecute([\n \"body\" => [\n \"script\" => [\n \"source\" => \"params.count / params.total\",\n \"params\" => [\n \"count\" => 100,\n \"total\" => 1000,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"params.count / params.total\",\"params\":{\"count\":100,\"total\":1000}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" - }, - { - "language": "Java", - "code": "client.scriptsPainlessExecute(s -> s\n .script(sc -> sc\n .source(so -> so\n .scriptString(\"params.count / params.total\")\n )\n .params(Map.of(\"total\", JsonData.fromJson(\"1000\"),\"count\", JsonData.fromJson(\"100\")))\n )\n);\n" - } - ], - "specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.get_script_context()" - }, - { - "language": "JavaScript", - "code": "const response = await client.getScriptContext();" - }, - { - "language": "Ruby", - "code": "response = client.get_script_context" - }, - { - "language": "PHP", - "code": "$resp = $client->getScriptContext();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_script_context\"" - }, - { - "language": "Java", - "code": "client.getScriptContext();\n" - } - ], - "specification/_global/msearch_template/examples/request/MultiSearchTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.msearch_template(\n index=\"my-index\",\n search_templates=[\n {},\n {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n },\n {},\n {\n \"id\": \"my-other-search-template\",\n \"params\": {\n \"query_type\": \"match_all\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.msearchTemplate({\n index: \"my-index\",\n search_templates: [\n {},\n {\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 0,\n size: 10,\n },\n },\n {},\n {\n id: \"my-other-search-template\",\n params: {\n query_type: \"match_all\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.msearch_template(\n index: \"my-index\",\n body: [\n {},\n {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n },\n {},\n {\n \"id\": \"my-other-search-template\",\n \"params\": {\n \"query_type\": \"match_all\"\n }\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->msearchTemplate([\n \"index\" => \"my-index\",\n \"body\" => array(\n new ArrayObject([]),\n [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 0,\n \"size\" => 10,\n ],\n ],\n new ArrayObject([]),\n [\n \"id\" => \"my-other-search-template\",\n \"params\" => [\n \"query_type\" => \"match_all\",\n ],\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{},{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":0,\"size\":10}},{},{\"id\":\"my-other-search-template\",\"params\":{\"query_type\":\"match_all\"}}]' \"$ELASTICSEARCH_URL/my-index/_msearch/template\"" - } - ], - "specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.terms_enum(\n index=\"stackoverflow\",\n field=\"tags\",\n string=\"kiba\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termsEnum({\n index: \"stackoverflow\",\n field: \"tags\",\n string: \"kiba\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.terms_enum(\n index: \"stackoverflow\",\n body: {\n \"field\": \"tags\",\n \"string\": \"kiba\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termsEnum([\n \"index\" => \"stackoverflow\",\n \"body\" => [\n \"field\" => \"tags\",\n \"string\" => \"kiba\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"field\":\"tags\",\"string\":\"kiba\"}' \"$ELASTICSEARCH_URL/stackoverflow/_terms_enum\"" - }, - { - "language": "Java", - "code": "client.termsEnum(t -> t\n .field(\"tags\")\n .index(\"stackoverflow\")\n .string(\"kiba\")\n);\n" - } - ], - "specification/_global/bulk/examples/request/BulkRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.bulk(\n operations=[\n {\n \"index\": {\n \"_index\": \"my_index\",\n \"_id\": \"1\",\n \"dynamic_templates\": {\n \"work_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value1\",\n \"work_location\": \"41.12,-71.34\",\n \"raw_location\": \"41.12,-71.34\"\n },\n {\n \"create\": {\n \"_index\": \"my_index\",\n \"_id\": \"2\",\n \"dynamic_templates\": {\n \"home_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value2\",\n \"home_location\": \"41.12,-71.34\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.bulk({\n operations: [\n {\n index: {\n _index: \"my_index\",\n _id: \"1\",\n dynamic_templates: {\n work_location: \"geo_point\",\n },\n },\n },\n {\n field: \"value1\",\n work_location: \"41.12,-71.34\",\n raw_location: \"41.12,-71.34\",\n },\n {\n create: {\n _index: \"my_index\",\n _id: \"2\",\n dynamic_templates: {\n home_location: \"geo_point\",\n },\n },\n },\n {\n field: \"value2\",\n home_location: \"41.12,-71.34\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.bulk(\n body: [\n {\n \"index\": {\n \"_index\": \"my_index\",\n \"_id\": \"1\",\n \"dynamic_templates\": {\n \"work_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value1\",\n \"work_location\": \"41.12,-71.34\",\n \"raw_location\": \"41.12,-71.34\"\n },\n {\n \"create\": {\n \"_index\": \"my_index\",\n \"_id\": \"2\",\n \"dynamic_templates\": {\n \"home_location\": \"geo_point\"\n }\n }\n },\n {\n \"field\": \"value2\",\n \"home_location\": \"41.12,-71.34\"\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"index\" => [\n \"_index\" => \"my_index\",\n \"_id\" => \"1\",\n \"dynamic_templates\" => [\n \"work_location\" => \"geo_point\",\n ],\n ],\n ],\n [\n \"field\" => \"value1\",\n \"work_location\" => \"41.12,-71.34\",\n \"raw_location\" => \"41.12,-71.34\",\n ],\n [\n \"create\" => [\n \"_index\" => \"my_index\",\n \"_id\" => \"2\",\n \"dynamic_templates\" => [\n \"home_location\" => \"geo_point\",\n ],\n ],\n ],\n [\n \"field\" => \"value2\",\n \"home_location\" => \"41.12,-71.34\",\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"index\":{\"_index\":\"my_index\",\"_id\":\"1\",\"dynamic_templates\":{\"work_location\":\"geo_point\"}}},{\"field\":\"value1\",\"work_location\":\"41.12,-71.34\",\"raw_location\":\"41.12,-71.34\"},{\"create\":{\"_index\":\"my_index\",\"_id\":\"2\",\"dynamic_templates\":{\"home_location\":\"geo_point\"}}},{\"field\":\"value2\",\"home_location\":\"41.12,-71.34\"}]' \"$ELASTICSEARCH_URL/_bulk\"" - } - ], - "specification/_global/bulk/examples/request/BulkRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.bulk(\n operations=[\n {\n \"update\": {\n \"_id\": \"5\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"update\": {\n \"_id\": \"6\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"create\": {\n \"_id\": \"7\",\n \"_index\": \"index1\"\n }\n },\n {\n \"my_field\": \"foo\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.bulk({\n operations: [\n {\n update: {\n _id: \"5\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n my_field: \"foo\",\n },\n },\n {\n update: {\n _id: \"6\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n my_field: \"foo\",\n },\n },\n {\n create: {\n _id: \"7\",\n _index: \"index1\",\n },\n },\n {\n my_field: \"foo\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.bulk(\n body: [\n {\n \"update\": {\n \"_id\": \"5\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"update\": {\n \"_id\": \"6\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"my_field\": \"foo\"\n }\n },\n {\n \"create\": {\n \"_id\": \"7\",\n \"_index\": \"index1\"\n }\n },\n {\n \"my_field\": \"foo\"\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"update\" => [\n \"_id\" => \"5\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"my_field\" => \"foo\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"6\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"my_field\" => \"foo\",\n ],\n ],\n [\n \"create\" => [\n \"_id\" => \"7\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"my_field\" => \"foo\",\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"update\":{\"_id\":\"5\",\"_index\":\"index1\"}},{\"doc\":{\"my_field\":\"foo\"}},{\"update\":{\"_id\":\"6\",\"_index\":\"index1\"}},{\"doc\":{\"my_field\":\"foo\"}},{\"create\":{\"_id\":\"7\",\"_index\":\"index1\"}},{\"my_field\":\"foo\"}]' \"$ELASTICSEARCH_URL/_bulk\"" - } - ], - "specification/_global/bulk/examples/request/BulkRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.bulk(\n operations=[\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"0\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"script\": {\n \"source\": \"ctx._source.counter += params.param1\",\n \"lang\": \"painless\",\n \"params\": {\n \"param1\": 1\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n },\n {\n \"update\": {\n \"_id\": \"2\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"doc_as_upsert\": True\n },\n {\n \"update\": {\n \"_id\": \"3\",\n \"_index\": \"index1\",\n \"_source\": True\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"4\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"_source\": True\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.bulk({\n operations: [\n {\n update: {\n _id: \"1\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n },\n {\n update: {\n _id: \"0\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n script: {\n source: \"ctx._source.counter += params.param1\",\n lang: \"painless\",\n params: {\n param1: 1,\n },\n },\n upsert: {\n counter: 1,\n },\n },\n {\n update: {\n _id: \"2\",\n _index: \"index1\",\n retry_on_conflict: 3,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n doc_as_upsert: true,\n },\n {\n update: {\n _id: \"3\",\n _index: \"index1\",\n _source: true,\n },\n },\n {\n doc: {\n field: \"value\",\n },\n },\n {\n update: {\n _id: \"4\",\n _index: \"index1\",\n },\n },\n {\n doc: {\n field: \"value\",\n },\n _source: true,\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.bulk(\n body: [\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"0\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"script\": {\n \"source\": \"ctx._source.counter += params.param1\",\n \"lang\": \"painless\",\n \"params\": {\n \"param1\": 1\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n },\n {\n \"update\": {\n \"_id\": \"2\",\n \"_index\": \"index1\",\n \"retry_on_conflict\": 3\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"doc_as_upsert\": true\n },\n {\n \"update\": {\n \"_id\": \"3\",\n \"_index\": \"index1\",\n \"_source\": true\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n }\n },\n {\n \"update\": {\n \"_id\": \"4\",\n \"_index\": \"index1\"\n }\n },\n {\n \"doc\": {\n \"field\": \"value\"\n },\n \"_source\": true\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"update\" => [\n \"_id\" => \"1\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"0\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.param1\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"param1\" => 1,\n ],\n ],\n \"upsert\" => [\n \"counter\" => 1,\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"2\",\n \"_index\" => \"index1\",\n \"retry_on_conflict\" => 3,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n \"doc_as_upsert\" => true,\n ],\n [\n \"update\" => [\n \"_id\" => \"3\",\n \"_index\" => \"index1\",\n \"_source\" => true,\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n ],\n [\n \"update\" => [\n \"_id\" => \"4\",\n \"_index\" => \"index1\",\n ],\n ],\n [\n \"doc\" => [\n \"field\" => \"value\",\n ],\n \"_source\" => true,\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"update\":{\"_id\":\"1\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"doc\":{\"field\":\"value\"}},{\"update\":{\"_id\":\"0\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"script\":{\"source\":\"ctx._source.counter += params.param1\",\"lang\":\"painless\",\"params\":{\"param1\":1}},\"upsert\":{\"counter\":1}},{\"update\":{\"_id\":\"2\",\"_index\":\"index1\",\"retry_on_conflict\":3}},{\"doc\":{\"field\":\"value\"},\"doc_as_upsert\":true},{\"update\":{\"_id\":\"3\",\"_index\":\"index1\",\"_source\":true}},{\"doc\":{\"field\":\"value\"}},{\"update\":{\"_id\":\"4\",\"_index\":\"index1\"}},{\"doc\":{\"field\":\"value\"},\"_source\":true}]' \"$ELASTICSEARCH_URL/_bulk\"" - } - ], - "specification/_global/bulk/examples/request/BulkRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.bulk(\n operations=[\n {\n \"index\": {\n \"_index\": \"test\",\n \"_id\": \"1\"\n }\n },\n {\n \"field1\": \"value1\"\n },\n {\n \"delete\": {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n },\n {\n \"create\": {\n \"_index\": \"test\",\n \"_id\": \"3\"\n }\n },\n {\n \"field1\": \"value3\"\n },\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"test\"\n }\n },\n {\n \"doc\": {\n \"field2\": \"value2\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.bulk({\n operations: [\n {\n index: {\n _index: \"test\",\n _id: \"1\",\n },\n },\n {\n field1: \"value1\",\n },\n {\n delete: {\n _index: \"test\",\n _id: \"2\",\n },\n },\n {\n create: {\n _index: \"test\",\n _id: \"3\",\n },\n },\n {\n field1: \"value3\",\n },\n {\n update: {\n _id: \"1\",\n _index: \"test\",\n },\n },\n {\n doc: {\n field2: \"value2\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.bulk(\n body: [\n {\n \"index\": {\n \"_index\": \"test\",\n \"_id\": \"1\"\n }\n },\n {\n \"field1\": \"value1\"\n },\n {\n \"delete\": {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n },\n {\n \"create\": {\n \"_index\": \"test\",\n \"_id\": \"3\"\n }\n },\n {\n \"field1\": \"value3\"\n },\n {\n \"update\": {\n \"_id\": \"1\",\n \"_index\": \"test\"\n }\n },\n {\n \"doc\": {\n \"field2\": \"value2\"\n }\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->bulk([\n \"body\" => array(\n [\n \"index\" => [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n ],\n ],\n [\n \"field1\" => \"value1\",\n ],\n [\n \"delete\" => [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n ],\n ],\n [\n \"create\" => [\n \"_index\" => \"test\",\n \"_id\" => \"3\",\n ],\n ],\n [\n \"field1\" => \"value3\",\n ],\n [\n \"update\" => [\n \"_id\" => \"1\",\n \"_index\" => \"test\",\n ],\n ],\n [\n \"doc\" => [\n \"field2\" => \"value2\",\n ],\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"index\":{\"_index\":\"test\",\"_id\":\"1\"}},{\"field1\":\"value1\"},{\"delete\":{\"_index\":\"test\",\"_id\":\"2\"}},{\"create\":{\"_index\":\"test\",\"_id\":\"3\"}},{\"field1\":\"value3\"},{\"update\":{\"_id\":\"1\",\"_index\":\"test\"}},{\"doc\":{\"field2\":\"value2\"}}]' \"$ELASTICSEARCH_URL/_bulk\"" - } - ], - "specification/_global/explain/examples/request/ExplainRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.explain(\n index=\"my-index-000001\",\n id=\"0\",\n query={\n \"match\": {\n \"message\": \"elasticsearch\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.explain({\n index: \"my-index-000001\",\n id: 0,\n query: {\n match: {\n message: \"elasticsearch\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.explain(\n index: \"my-index-000001\",\n id: \"0\",\n body: {\n \"query\": {\n \"match\": {\n \"message\": \"elasticsearch\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->explain([\n \"index\" => \"my-index-000001\",\n \"id\" => \"0\",\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"elasticsearch\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"message\":\"elasticsearch\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_explain/0\"" - }, - { - "language": "Java", - "code": "client.explain(e -> e\n .id(\"0\")\n .index(\"my-index-000001\")\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"elasticsearch\"))\n )\n )\n);\n" - } - ], - "specification/_global/get_script/examples/request/GetScriptRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.get_script(\n id=\"my-search-template\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.getScript({\n id: \"my-search-template\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.get_script(\n id: \"my-search-template\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->getScript([\n \"id\" => \"my-search-template\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" - }, - { - "language": "Java", - "code": "client.getScript(g -> g\n .id(\"my-search-template\")\n);\n" - } - ], - "specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_template(\n index=\"my-index\",\n id=\"my-search-template\",\n params={\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchTemplate({\n index: \"my-index\",\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 0,\n size: 10,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_template(\n index: \"my-index\",\n body: {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchTemplate([\n \"index\" => \"my-index\",\n \"body\" => [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 0,\n \"size\" => 10,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":0,\"size\":10}}' \"$ELASTICSEARCH_URL/my-index/_search/template\"" - }, - { - "language": "Java", - "code": "client.searchTemplate(s -> s\n .id(\"my-search-template\")\n .index(\"my-index\")\n .params(Map.of(\"size\", JsonData.fromJson(\"10\"),\"from\", JsonData.fromJson(\"0\"),\"query_string\", JsonData.fromJson(\"\\\"hello world\\\"\")))\n);\n" - } - ], - "specification/_global/scroll/examples/request/ScrollRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.scroll(\n scroll_id=\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.scroll({\n scroll_id: \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.scroll(\n body: {\n \"scroll_id\": \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->scroll([\n \"body\" => [\n \"scroll_id\" => \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scroll_id\":\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"}' \"$ELASTICSEARCH_URL/_search/scroll\"" - }, - { - "language": "Java", - "code": "client.scroll(s -> s\n .scrollId(\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\")\n);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample7.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"green\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source:\n \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n lang: \"painless\",\n params: {\n tag: \"green\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"green\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"green\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"if (ctx._source.tags.contains(params.tag)) { ctx.op = '\"'\"'delete'\"'\"' } else { ctx.op = '\"'\"'noop'\"'\"' }\",\"lang\":\"painless\",\"params\":{\"tag\":\"green\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"green\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source['my-object'].remove('my-subfield')\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source['my-object'].remove('my-subfield')\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source['my-object'].remove('my-subfield')\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source['my-object'].remove('my-subfield')\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source['\"'\"'my-object'\"'\"'].remove('\"'\"'my-subfield'\"'\"')\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['my-object'].remove('my-subfield')\")\n )\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.counter += params.count\",\n lang: \"painless\",\n params: {\n count: 4,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.count\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.counter += params.count\",\"lang\":\"painless\",\"params\":{\"count\":4}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.counter += params.count\")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n .lang(\"painless\")\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source:\n \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n lang: \"painless\",\n params: {\n tag: \"blue\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"blue\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\",\"lang\":\"painless\",\"params\":{\"tag\":\"blue\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"blue\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.tags.add(params.tag)\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.tags.add(params.tag)\",\n lang: \"painless\",\n params: {\n tag: \"blue\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.tags.add(params.tag)\",\n \"lang\": \"painless\",\n \"params\": {\n \"tag\": \"blue\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.tags.add(params.tag)\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"tag\" => \"blue\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.tags.add(params.tag)\",\"lang\":\"painless\",\"params\":{\"tag\":\"blue\"}}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.tags.add(params.tag)\")\n )\n .params(\"tag\", JsonData.fromJson(\"\\\"blue\\\"\"))\n .lang(\"painless\")\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source.remove('new_field')\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source.remove('new_field')\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source.remove('new_field')\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source.remove('new_field')\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source.remove('\"'\"'new_field'\"'\"')\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.remove('new_field')\")\n )\n )\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample10.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n scripted_upsert=True,\n script={\n \"source\": \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\": {\n \"count\": 4\n }\n },\n upsert={},\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n scripted_upsert: true,\n script: {\n source:\n \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n params: {\n count: 4,\n },\n },\n upsert: {},\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"scripted_upsert\": true,\n \"script\": {\n \"source\": \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\": {\n \"count\": 4\n }\n },\n \"upsert\": {}\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"scripted_upsert\" => true,\n \"script\" => [\n \"source\" => \"\\n if ( ctx.op == 'create' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n \"upsert\" => new ArrayObject([]),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scripted_upsert\":true,\"script\":{\"source\":\"\\n if ( ctx.op == '\"'\"'create'\"'\"' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\"params\":{\"count\":4}},\"upsert\":{}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"\n if ( ctx.op == 'create' ) {\n ctx._source.counter = params.count\n } else {\n ctx._source.counter += params.count\n }\n \")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n )\n .scriptedUpsert(true)\n .upsert(JsonData.fromJson(\"{}\"))\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample9.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script={\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n upsert={\n \"counter\": 1\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: {\n source: \"ctx._source.counter += params.count\",\n lang: \"painless\",\n params: {\n count: 4,\n },\n },\n upsert: {\n counter: 1,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.counter += params.count\",\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n },\n \"upsert\": {\n \"counter\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.counter += params.count\",\n \"lang\" => \"painless\",\n \"params\" => [\n \"count\" => 4,\n ],\n ],\n \"upsert\" => [\n \"counter\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.counter += params.count\",\"lang\":\"painless\",\"params\":{\"count\":4}},\"upsert\":{\"counter\":1}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.counter += params.count\")\n )\n .params(\"count\", JsonData.fromJson(\"4\"))\n .lang(\"painless\")\n )\n .upsert(JsonData.fromJson(\"{\\\"counter\\\":1}\"))\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample8.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n doc={\n \"name\": \"new_name\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n doc: {\n name: \"new_name\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"doc\": {\n \"name\": \"new_name\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"doc\" => [\n \"name\" => \"new_name\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"name\":\"new_name\"}}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .doc(JsonData.fromJson(\"{\\\"name\\\":\\\"new_name\\\"}\"))\n .id(\"1\")\n .index(\"test\")\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample11.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n doc={\n \"name\": \"new_name\"\n },\n doc_as_upsert=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n doc: {\n name: \"new_name\",\n },\n doc_as_upsert: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"doc\": {\n \"name\": \"new_name\"\n },\n \"doc_as_upsert\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"doc\" => [\n \"name\" => \"new_name\",\n ],\n \"doc_as_upsert\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"name\":\"new_name\"},\"doc_as_upsert\":true}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .doc(JsonData.fromJson(\"{\\\"name\\\":\\\"new_name\\\"}\"))\n .docAsUpsert(true)\n .id(\"1\")\n .index(\"test\")\n,Void.class);\n" - } - ], - "specification/_global/update/examples/request/UpdateRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.update(\n index=\"test\",\n id=\"1\",\n script=\"ctx._source.new_field = 'value_of_new_field'\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.update({\n index: \"test\",\n id: 1,\n script: \"ctx._source.new_field = 'value_of_new_field'\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.update(\n index: \"test\",\n id: \"1\",\n body: {\n \"script\": \"ctx._source.new_field = 'value_of_new_field'\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->update([\n \"index\" => \"test\",\n \"id\" => \"1\",\n \"body\" => [\n \"script\" => \"ctx._source.new_field = 'value_of_new_field'\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":\"ctx._source.new_field = '\"'\"'value_of_new_field'\"'\"'\"}' \"$ELASTICSEARCH_URL/test/_update/1\"" - }, - { - "language": "Java", - "code": "client.update(u -> u\n .id(\"1\")\n .index(\"test\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.new_field = 'value_of_new_field'\")\n )\n )\n,Void.class);\n" - } - ], - "specification/_global/delete/examples/request/DeleteRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.delete(\n index=\"my-index-000001\",\n id=\"1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.delete({\n index: \"my-index-000001\",\n id: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete(\n index: \"my-index-000001\",\n id: \"1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->delete([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/1\"" - }, - { - "language": "Java", - "code": "client.delete(d -> d\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n refresh=True,\n slices=\"5\",\n script={\n \"source\": \"ctx._source['extra'] = 'test'\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: 5,\n script: {\n source: \"ctx._source['extra'] = 'test'\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: \"5\",\n body: {\n \"script\": {\n \"source\": \"ctx._source['extra'] = 'test'\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"refresh\" => \"true\",\n \"slices\" => \"5\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source['extra'] = 'test'\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source['\"'\"'extra'\"'\"'] = '\"'\"'test'\"'\"'\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query?refresh&slices=5\"" - }, - { - "language": "Java", - "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .refresh(true)\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['extra'] = 'test'\")\n )\n )\n .slices(sl -> sl\n .value(5)\n )\n);\n" - } - ], - "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n script={\n \"source\": \"ctx._source.count++\",\n \"lang\": \"painless\"\n },\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n script: {\n source: \"ctx._source.count++\",\n lang: \"painless\",\n },\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n body: {\n \"script\": {\n \"source\": \"ctx._source.count++\",\n \"lang\": \"painless\"\n },\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"script\" => [\n \"source\" => \"ctx._source.count++\",\n \"lang\" => \"painless\",\n ],\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"source\":\"ctx._source.count++\",\"lang\":\"painless\"},\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query\"" - }, - { - "language": "Java", - "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.count++\")\n )\n .lang(\"painless\")\n )\n);\n" - } - ], - "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n slice={\n \"id\": 0,\n \"max\": 2\n },\n script={\n \"source\": \"ctx._source['extra'] = 'test'\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n script: {\n source: \"ctx._source['extra'] = 'test'\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"script\": {\n \"source\": \"ctx._source['extra'] = 'test'\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"script\" => [\n \"source\" => \"ctx._source['extra'] = 'test'\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"script\":{\"source\":\"ctx._source['\"'\"'extra'\"'\"'] = '\"'\"'test'\"'\"'\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query\"" - }, - { - "language": "Java", - "code": "client.updateByQuery(u -> u\n .index(\"my-index-000001\")\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source['extra'] = 'test'\")\n )\n )\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n);\n" - } - ], - "specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.update_by_query(\n index=\"my-index-000001\",\n conflicts=\"proceed\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.updateByQuery({\n index: \"my-index-000001\",\n conflicts: \"proceed\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.update_by_query(\n index: \"my-index-000001\",\n conflicts: \"proceed\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->updateByQuery([\n \"index\" => \"my-index-000001\",\n \"conflicts\" => \"proceed\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_update_by_query?conflicts=proceed\"" - }, - { - "language": "Java", - "code": "client.updateByQuery(u -> u\n .conflicts(Conflicts.Proceed)\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" - } - ], - "specification/_global/exists/examples/request/DocumentExistsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.exists(\n index=\"my-index-000001\",\n id=\"0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.exists({\n index: \"my-index-000001\",\n id: 0,\n});" - }, - { - "language": "Ruby", - "code": "response = client.exists(\n index: \"my-index-000001\",\n id: \"0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->exists([\n \"index\" => \"my-index-000001\",\n \"id\" => \"0\",\n]);" - }, - { - "language": "curl", - "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/0\"" - }, - { - "language": "Java", - "code": "client.exists(e -> e\n .id(\"0\")\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/put_script/examples/request/PutScriptRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.put_script(\n id=\"my-search-template\",\n script={\n \"lang\": \"mustache\",\n \"source\": {\n \"query\": {\n \"match\": {\n \"message\": \"{{query_string}}\"\n }\n },\n \"from\": \"{{from}}\",\n \"size\": \"{{size}}\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.putScript({\n id: \"my-search-template\",\n script: {\n lang: \"mustache\",\n source: {\n query: {\n match: {\n message: \"{{query_string}}\",\n },\n },\n from: \"{{from}}\",\n size: \"{{size}}\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.put_script(\n id: \"my-search-template\",\n body: {\n \"script\": {\n \"lang\": \"mustache\",\n \"source\": {\n \"query\": {\n \"match\": {\n \"message\": \"{{query_string}}\"\n }\n },\n \"from\": \"{{from}}\",\n \"size\": \"{{size}}\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->putScript([\n \"id\" => \"my-search-template\",\n \"body\" => [\n \"script\" => [\n \"lang\" => \"mustache\",\n \"source\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"{{query_string}}\",\n ],\n ],\n \"from\" => \"{{from}}\",\n \"size\" => \"{{size}}\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"lang\":\"mustache\",\"source\":{\"query\":{\"match\":{\"message\":\"{{query_string}}\"}},\"from\":\"{{from}}\",\"size\":\"{{size}}\"}}}' \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" - } - ], - "specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.put_script(\n id=\"my-stored-script\",\n script={\n \"lang\": \"painless\",\n \"source\": \"Math.log(_score * 2) + params['my_modifier']\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.putScript({\n id: \"my-stored-script\",\n script: {\n lang: \"painless\",\n source: \"Math.log(_score * 2) + params['my_modifier']\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.put_script(\n id: \"my-stored-script\",\n body: {\n \"script\": {\n \"lang\": \"painless\",\n \"source\": \"Math.log(_score * 2) + params['my_modifier']\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->putScript([\n \"id\" => \"my-stored-script\",\n \"body\" => [\n \"script\" => [\n \"lang\" => \"painless\",\n \"source\" => \"Math.log(_score * 2) + params['my_modifier']\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"script\":{\"lang\":\"painless\",\"source\":\"Math.log(_score * 2) + params['\"'\"'my_modifier'\"'\"']\"}}' \"$ELASTICSEARCH_URL/_scripts/my-stored-script\"" - }, - { - "language": "Java", - "code": "client.putScript(p -> p\n .id(\"my-stored-script\")\n .script(s -> s\n .lang(\"painless\")\n .source(so -> so\n .scriptString(\"Math.log(_score * 2) + params['my_modifier']\")\n )\n )\n);\n" - } - ], - "specification/_global/reindex_rethrottle/examples/request/ReindexRethrottleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindexRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindexRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" - }, - { - "language": "Java", - "code": "client.reindexRethrottle(r -> r\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" - } - ], - "specification/_global/count/examples/request/CountRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.count(\n index=\"my-index-000001\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.count({\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.count(\n index: \"my-index-000001\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->count([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_count\"" - }, - { - "language": "Java", - "code": "client.count(c -> c\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" - } - ], - "specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.termvectors(\n index=\"imdb\",\n doc={\n \"plot\": \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"\n },\n term_statistics=True,\n field_statistics=True,\n positions=False,\n offsets=False,\n filter={\n \"max_num_terms\": 3,\n \"min_term_freq\": 1,\n \"min_doc_freq\": 1\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termvectors({\n index: \"imdb\",\n doc: {\n plot: \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\",\n },\n term_statistics: true,\n field_statistics: true,\n positions: false,\n offsets: false,\n filter: {\n max_num_terms: 3,\n min_term_freq: 1,\n min_doc_freq: 1,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.termvectors(\n index: \"imdb\",\n body: {\n \"doc\": {\n \"plot\": \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"\n },\n \"term_statistics\": true,\n \"field_statistics\": true,\n \"positions\": false,\n \"offsets\": false,\n \"filter\": {\n \"max_num_terms\": 3,\n \"min_term_freq\": 1,\n \"min_doc_freq\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termvectors([\n \"index\" => \"imdb\",\n \"body\" => [\n \"doc\" => [\n \"plot\" => \"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\",\n ],\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n \"positions\" => false,\n \"offsets\" => false,\n \"filter\" => [\n \"max_num_terms\" => 3,\n \"min_term_freq\" => 1,\n \"min_doc_freq\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"plot\":\"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"},\"term_statistics\":true,\"field_statistics\":true,\"positions\":false,\"offsets\":false,\"filter\":{\"max_num_terms\":3,\"min_term_freq\":1,\"min_doc_freq\":1}}' \"$ELASTICSEARCH_URL/imdb/_termvectors\"" - }, - { - "language": "Java", - "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"plot\\\":\\\"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\\\"}\"))\n .fieldStatistics(true)\n .filter(f -> f\n .maxNumTerms(3)\n .minDocFreq(1)\n .minTermFreq(1)\n )\n .index(\"imdb\")\n .offsets(false)\n .positions(false)\n .termStatistics(true)\n);\n" - } - ], - "specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n doc={\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n fields=[\n \"fullname\"\n ],\n per_field_analyzer={\n \"fullname\": \"keyword\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n doc: {\n fullname: \"John Doe\",\n text: \"test test test\",\n },\n fields: [\"fullname\"],\n per_field_analyzer: {\n fullname: \"keyword\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.termvectors(\n index: \"my-index-000001\",\n body: {\n \"doc\": {\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n \"fields\": [\n \"fullname\"\n ],\n \"per_field_analyzer\": {\n \"fullname\": \"keyword\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"doc\" => [\n \"fullname\" => \"John Doe\",\n \"text\" => \"test test test\",\n ],\n \"fields\" => array(\n \"fullname\",\n ),\n \"per_field_analyzer\" => [\n \"fullname\" => \"keyword\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"fullname\":\"John Doe\",\"text\":\"test test test\"},\"fields\":[\"fullname\"],\"per_field_analyzer\":{\"fullname\":\"keyword\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors\"" - }, - { - "language": "Java", - "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"fullname\\\":\\\"John Doe\\\",\\\"text\\\":\\\"test test test\\\"}\"))\n .fields(\"fullname\")\n .index(\"my-index-000001\")\n .perFieldAnalyzer(\"fullname\", \"keyword\")\n);\n" - } - ], - "specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n doc={\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n doc: {\n fullname: \"John Doe\",\n text: \"test test test\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.termvectors(\n index: \"my-index-000001\",\n body: {\n \"doc\": {\n \"fullname\": \"John Doe\",\n \"text\": \"test test test\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"doc\" => [\n \"fullname\" => \"John Doe\",\n \"text\" => \"test test test\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"doc\":{\"fullname\":\"John Doe\",\"text\":\"test test test\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors\"" - }, - { - "language": "Java", - "code": "client.termvectors(t -> t\n .doc(JsonData.fromJson(\"{\\\"fullname\\\":\\\"John Doe\\\",\\\"text\\\":\\\"test test test\\\"}\"))\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n id=\"1\",\n fields=[\n \"text\",\n \"some_field_without_term_vectors\"\n ],\n offsets=True,\n positions=True,\n term_statistics=True,\n field_statistics=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n id: 1,\n fields: [\"text\", \"some_field_without_term_vectors\"],\n offsets: true,\n positions: true,\n term_statistics: true,\n field_statistics: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.termvectors(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"fields\": [\n \"text\",\n \"some_field_without_term_vectors\"\n ],\n \"offsets\": true,\n \"positions\": true,\n \"term_statistics\": true,\n \"field_statistics\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"fields\" => array(\n \"text\",\n \"some_field_without_term_vectors\",\n ),\n \"offsets\" => true,\n \"positions\" => true,\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\",\"some_field_without_term_vectors\"],\"offsets\":true,\"positions\":true,\"term_statistics\":true,\"field_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" - }, - { - "language": "Java", - "code": "client.termvectors(t -> t\n .fieldStatistics(true)\n .fields(List.of(\"text\",\"some_field_without_term_vectors\"))\n .id(\"1\")\n .index(\"my-index-000001\")\n .offsets(true)\n .positions(true)\n .termStatistics(true)\n);\n" - } - ], - "specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.termvectors(\n index=\"my-index-000001\",\n id=\"1\",\n fields=[\n \"text\"\n ],\n offsets=True,\n payloads=True,\n positions=True,\n term_statistics=True,\n field_statistics=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.termvectors({\n index: \"my-index-000001\",\n id: 1,\n fields: [\"text\"],\n offsets: true,\n payloads: true,\n positions: true,\n term_statistics: true,\n field_statistics: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.termvectors(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"fields\": [\n \"text\"\n ],\n \"offsets\": true,\n \"payloads\": true,\n \"positions\": true,\n \"term_statistics\": true,\n \"field_statistics\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->termvectors([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"fields\" => array(\n \"text\",\n ),\n \"offsets\" => true,\n \"payloads\" => true,\n \"positions\" => true,\n \"term_statistics\" => true,\n \"field_statistics\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\"],\"offsets\":true,\"payloads\":true,\"positions\":true,\"term_statistics\":true,\"field_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" - }, - { - "language": "Java", - "code": "client.termvectors(t -> t\n .fieldStatistics(true)\n .fields(\"text\")\n .id(\"1\")\n .index(\"my-index-000001\")\n .offsets(true)\n .payloads(true)\n .positions(true)\n .termStatistics(true)\n);\n" - } - ], - "specification/_global/search_mvt/examples/request/SearchMvtRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_mvt(\n index=\"museums\",\n field=\"location\",\n zoom=\"13\",\n x=\"4207\",\n y=\"2692\",\n grid_agg=\"geotile\",\n grid_precision=2,\n fields=[\n \"name\",\n \"price\"\n ],\n query={\n \"term\": {\n \"included\": True\n }\n },\n aggs={\n \"min_price\": {\n \"min\": {\n \"field\": \"price\"\n }\n },\n \"max_price\": {\n \"max\": {\n \"field\": \"price\"\n }\n },\n \"avg_price\": {\n \"avg\": {\n \"field\": \"price\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchMvt({\n index: \"museums\",\n field: \"location\",\n zoom: 13,\n x: 4207,\n y: 2692,\n grid_agg: \"geotile\",\n grid_precision: 2,\n fields: [\"name\", \"price\"],\n query: {\n term: {\n included: true,\n },\n },\n aggs: {\n min_price: {\n min: {\n field: \"price\",\n },\n },\n max_price: {\n max: {\n field: \"price\",\n },\n },\n avg_price: {\n avg: {\n field: \"price\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_mvt(\n index: \"museums\",\n field: \"location\",\n zoom: \"13\",\n x: \"4207\",\n y: \"2692\",\n body: {\n \"grid_agg\": \"geotile\",\n \"grid_precision\": 2,\n \"fields\": [\n \"name\",\n \"price\"\n ],\n \"query\": {\n \"term\": {\n \"included\": true\n }\n },\n \"aggs\": {\n \"min_price\": {\n \"min\": {\n \"field\": \"price\"\n }\n },\n \"max_price\": {\n \"max\": {\n \"field\": \"price\"\n }\n },\n \"avg_price\": {\n \"avg\": {\n \"field\": \"price\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchMvt([\n \"index\" => \"museums\",\n \"field\" => \"location\",\n \"zoom\" => \"13\",\n \"x\" => \"4207\",\n \"y\" => \"2692\",\n \"body\" => [\n \"grid_agg\" => \"geotile\",\n \"grid_precision\" => 2,\n \"fields\" => array(\n \"name\",\n \"price\",\n ),\n \"query\" => [\n \"term\" => [\n \"included\" => true,\n ],\n ],\n \"aggs\" => [\n \"min_price\" => [\n \"min\" => [\n \"field\" => \"price\",\n ],\n ],\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"price\",\n ],\n ],\n \"avg_price\" => [\n \"avg\" => [\n \"field\" => \"price\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "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\"" - } - ], - "specification/_global/delete_by_query_rethrottle/examples/request/DeleteByQueryRethrottleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_by_query_rethrottle(\n task_id=\"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second=\"-1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteByQueryRethrottle({\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_by_query_rethrottle(\n task_id: \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n requests_per_second: \"-1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteByQueryRethrottle([\n \"task_id\" => \"r1A2WoRbTwKZ516z6NEs5A:36619\",\n \"requests_per_second\" => \"-1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_delete_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1\"" - }, - { - "language": "Java", - "code": "client.deleteByQueryRethrottle(d -> d\n .requestsPerSecond(-1.0F)\n .taskId(\"r1A2WoRbTwKZ516z6NEs5A:36619\")\n);\n" - } - ], - "specification/_global/get/examples/request/GetRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.get(\n index=\"my-index-000001\",\n id=\"1\",\n stored_fields=\"tags,counter\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.get({\n index: \"my-index-000001\",\n id: 1,\n stored_fields: \"tags,counter\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.get(\n index: \"my-index-000001\",\n id: \"1\",\n stored_fields: \"tags,counter\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->get([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"stored_fields\" => \"tags,counter\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_doc/1?stored_fields=tags,counter\"" - } - ], - "specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.render_search_template(\n id=\"my-search-template\",\n params={\n \"query_string\": \"hello world\",\n \"from\": 20,\n \"size\": 10\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.renderSearchTemplate({\n id: \"my-search-template\",\n params: {\n query_string: \"hello world\",\n from: 20,\n size: 10,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.render_search_template(\n body: {\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 20,\n \"size\": 10\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->renderSearchTemplate([\n \"body\" => [\n \"id\" => \"my-search-template\",\n \"params\" => [\n \"query_string\" => \"hello world\",\n \"from\" => 20,\n \"size\" => 10,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"my-search-template\",\"params\":{\"query_string\":\"hello world\",\"from\":20,\"size\":10}}' \"$ELASTICSEARCH_URL/_render/template\"" - }, - { - "language": "Java", - "code": "client.renderSearchTemplate(r -> r\n .id(\"my-search-template\")\n .params(Map.of(\"size\", JsonData.fromJson(\"10\"),\"from\", JsonData.fromJson(\"20\"),\"query_string\", JsonData.fromJson(\"\\\"hello world\\\"\")))\n);\n" - } - ], - "specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.open_point_in_time(\n index=\"my-index-000001\",\n keep_alive=\"1m\",\n allow_partial_search_results=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.openPointInTime({\n index: \"my-index-000001\",\n keep_alive: \"1m\",\n allow_partial_search_results: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.open_point_in_time(\n index: \"my-index-000001\",\n keep_alive: \"1m\",\n allow_partial_search_results: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->openPointInTime([\n \"index\" => \"my-index-000001\",\n \"keep_alive\" => \"1m\",\n \"allow_partial_search_results\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_pit?keep_alive=1m&allow_partial_search_results=true\"" - }, - { - "language": "Java", - "code": "client.openPointInTime(o -> o\n .allowPartialSearchResults(true)\n .index(\"my-index-000001\")\n .keepAlive(k -> k\n .offset(1)\n )\n);\n" - } - ], - "specification/_global/search_shards/examples/request/SearchShardsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_shards(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchShards({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_shards(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchShards([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_search_shards\"" - }, - { - "language": "Java", - "code": "client.searchShards(s -> s\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_by_query(\n index=\"my-index-000001,my-index-000002\",\n query={\n \"match_all\": {}\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001,my-index-000002\",\n query: {\n match_all: {},\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_by_query(\n index: \"my-index-000001,my-index-000002\",\n body: {\n \"query\": {\n \"match_all\": {}\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001,my-index-000002\",\n \"body\" => [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match_all\":{}}}' \"$ELASTICSEARCH_URL/my-index-000001,my-index-000002/_delete_by_query\"" - }, - { - "language": "Java", - "code": "client.deleteByQuery(d -> d\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n .query(q -> q\n .matchAll(m -> m)\n )\n);\n" - } - ], - "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n max_docs=1,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n max_docs: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n \"max_docs\": 1\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n \"max_docs\" => 1,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}},\"max_docs\":1}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query\"" - }, - { - "language": "Java", - "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .maxDocs(1L)\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n);\n" - } - ], - "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n slice={\n \"id\": 0,\n \"max\": 2\n },\n query={\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n query: {\n range: {\n \"http.response.bytes\": {\n lt: 2000000,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"query\": {\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"query\" => [\n \"range\" => [\n \"http.response.bytes\" => [\n \"lt\" => 2000000,\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"query\":{\"range\":{\"http.response.bytes\":{\"lt\":2000000}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query\"" - }, - { - "language": "Java", - "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"http.response.bytes\")\n .lt(JsonData.fromJson(\"2000000\"))\n )\n )\n )\n .slice(s -> s\n .id(\"0\")\n .max(2)\n )\n);\n" - } - ], - "specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_by_query(\n index=\"my-index-000001\",\n refresh=True,\n slices=\"5\",\n query={\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteByQuery({\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: 5,\n query: {\n range: {\n \"http.response.bytes\": {\n lt: 2000000,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_by_query(\n index: \"my-index-000001\",\n refresh: \"true\",\n slices: \"5\",\n body: {\n \"query\": {\n \"range\": {\n \"http.response.bytes\": {\n \"lt\": 2000000\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteByQuery([\n \"index\" => \"my-index-000001\",\n \"refresh\" => \"true\",\n \"slices\" => \"5\",\n \"body\" => [\n \"query\" => [\n \"range\" => [\n \"http.response.bytes\" => [\n \"lt\" => 2000000,\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"range\":{\"http.response.bytes\":{\"lt\":2000000}}}}' \"$ELASTICSEARCH_URL/my-index-000001/_delete_by_query?refresh&slices=5\"" - }, - { - "language": "Java", - "code": "client.deleteByQuery(d -> d\n .index(\"my-index-000001\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"http.response.bytes\")\n .lt(JsonData.fromJson(\"2000000\"))\n )\n )\n )\n .refresh(true)\n .slices(s -> s\n .value(5)\n )\n);\n" - } - ], - "specification/_global/health_report/examples/request/HealthReportRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.health_report()" - }, - { - "language": "JavaScript", - "code": "const response = await client.healthReport();" - }, - { - "language": "Ruby", - "code": "response = client.health_report" - }, - { - "language": "PHP", - "code": "$resp = $client->healthReport();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_health_report\"" - }, - { - "language": "Java", - "code": "client.healthReport(h -> h);\n" - } - ], - "specification/_global/field_caps/examples/request/FieldCapabilitiesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.field_caps(\n index=\"my-index-*\",\n fields=\"rating\",\n index_filter={\n \"range\": {\n \"@timestamp\": {\n \"gte\": \"2018\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.fieldCaps({\n index: \"my-index-*\",\n fields: \"rating\",\n index_filter: {\n range: {\n \"@timestamp\": {\n gte: \"2018\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.field_caps(\n index: \"my-index-*\",\n fields: \"rating\",\n body: {\n \"index_filter\": {\n \"range\": {\n \"@timestamp\": {\n \"gte\": \"2018\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->fieldCaps([\n \"index\" => \"my-index-*\",\n \"fields\" => \"rating\",\n \"body\" => [\n \"index_filter\" => [\n \"range\" => [\n \"@timestamp\" => [\n \"gte\" => \"2018\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "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\"" - } - ], - "specification/_global/search/examples/request/SearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search(\n index=\"my-index-000001\",\n from=\"40\",\n size=\"20\",\n query={\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.search({\n index: \"my-index-000001\",\n from: 40,\n size: 20,\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search(\n index: \"my-index-000001\",\n from: \"40\",\n size: \"20\",\n body: {\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->search([\n \"index\" => \"my-index-000001\",\n \"from\" => \"40\",\n \"size\" => \"20\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"user.id\":\"kimchy\"}}}' \"$ELASTICSEARCH_URL/my-index-000001/_search?from=40&size=20\"" - }, - { - "language": "Java", - "code": "client.search(s -> s\n .from(40)\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n .size(20)\n,Void.class);\n" - } - ], - "specification/_global/search/examples/request/SearchRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.search(\n size=100,\n query={\n \"match\": {\n \"title\": \"elasticsearch\"\n }\n },\n pit={\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\": \"1m\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.search({\n size: 100,\n query: {\n match: {\n title: \"elasticsearch\",\n },\n },\n pit: {\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n keep_alive: \"1m\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search(\n body: {\n \"size\": 100,\n \"query\": {\n \"match\": {\n \"title\": \"elasticsearch\"\n }\n },\n \"pit\": {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\": \"1m\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->search([\n \"body\" => [\n \"size\" => 100,\n \"query\" => [\n \"match\" => [\n \"title\" => \"elasticsearch\",\n ],\n ],\n \"pit\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n \"keep_alive\" => \"1m\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"size\":100,\"query\":{\"match\":{\"title\":\"elasticsearch\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\"keep_alive\":\"1m\"}}' \"$ELASTICSEARCH_URL/_search\"" - }, - { - "language": "Java", - "code": "client.search(s -> s\n .pit(p -> p\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n .keepAlive(k -> k\n .time(\"1m\")\n )\n )\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"elasticsearch\"))\n )\n )\n .size(100)\n,Void.class);\n" - } - ], - "specification/_global/search/examples/request/SearchRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.search(\n slice={\n \"id\": 0,\n \"max\": 2\n },\n query={\n \"match\": {\n \"message\": \"foo\"\n }\n },\n pit={\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.search({\n slice: {\n id: 0,\n max: 2,\n },\n query: {\n match: {\n message: \"foo\",\n },\n },\n pit: {\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search(\n body: {\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n },\n \"query\": {\n \"match\": {\n \"message\": \"foo\"\n }\n },\n \"pit\": {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->search([\n \"body\" => [\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n \"query\" => [\n \"match\" => [\n \"message\" => \"foo\",\n ],\n ],\n \"pit\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"slice\":{\"id\":0,\"max\":2},\"query\":{\"match\":{\"message\":\"foo\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"}}' \"$ELASTICSEARCH_URL/_search\"" - }, - { - "language": "Java", - "code": "client.search(s -> s\n .pit(p -> p\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n )\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n,Void.class);\n" - } - ], - "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.mtermvectors(\n index=\"my-index-000001\",\n docs=[\n {\n \"_id\": \"2\",\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": True\n },\n {\n \"_id\": \"1\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mtermvectors({\n index: \"my-index-000001\",\n docs: [\n {\n _id: \"2\",\n fields: [\"message\"],\n term_statistics: true,\n },\n {\n _id: \"1\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mtermvectors(\n index: \"my-index-000001\",\n body: {\n \"docs\": [\n {\n \"_id\": \"2\",\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n },\n {\n \"_id\": \"1\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mtermvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"2\",\n \"fields\" => array(\n \"message\",\n ),\n \"term_statistics\" => true,\n ],\n [\n \"_id\" => \"1\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"2\",\"fields\":[\"message\"],\"term_statistics\":true},{\"_id\":\"1\"}]}' \"$ELASTICSEARCH_URL/my-index-000001/_mtermvectors\"" - }, - { - "language": "Java", - "code": "client.mtermvectors(m -> m\n .docs(List.of(MultiTermVectorsOperation.of(mu -> mu\n .id(\"2\")\n .fields(\"message\")\n .termStatistics(true)),MultiTermVectorsOperation.of(mu -> mu\n .id(\"1\"))))\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.mtermvectors(\n index=\"my-index-000001\",\n ids=[\n \"1\",\n \"2\"\n ],\n fields=[\n \"message\"\n ],\n term_statistics=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mtermvectors({\n index: \"my-index-000001\",\n ids: [\"1\", \"2\"],\n fields: [\"message\"],\n term_statistics: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.mtermvectors(\n index: \"my-index-000001\",\n body: {\n \"ids\": [\n \"1\",\n \"2\"\n ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mtermvectors([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"ids\" => array(\n \"1\",\n \"2\",\n ),\n \"fields\" => array(\n \"message\",\n ),\n \"term_statistics\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"1\",\"2\"],\"fields\":[\"message\"],\"term_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_mtermvectors\"" - }, - { - "language": "Java", - "code": "client.mtermvectors(m -> m\n .ids(List.of(\"1\",\"2\"))\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.mtermvectors(\n docs=[\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"test test test\"\n }\n },\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"Another test ...\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mtermvectors({\n docs: [\n {\n _index: \"my-index-000001\",\n doc: {\n message: \"test test test\",\n },\n },\n {\n _index: \"my-index-000001\",\n doc: {\n message: \"Another test ...\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mtermvectors(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"test test test\"\n }\n },\n {\n \"_index\": \"my-index-000001\",\n \"doc\": {\n \"message\": \"Another test ...\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mtermvectors([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index-000001\",\n \"doc\" => [\n \"message\" => \"test test test\",\n ],\n ],\n [\n \"_index\" => \"my-index-000001\",\n \"doc\" => [\n \"message\" => \"Another test ...\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index-000001\",\"doc\":{\"message\":\"test test test\"}},{\"_index\":\"my-index-000001\",\"doc\":{\"message\":\"Another test ...\"}}]}' \"$ELASTICSEARCH_URL/_mtermvectors\"" - }, - { - "language": "Java", - "code": "client.mtermvectors(m -> m\n .docs(List.of(MultiTermVectorsOperation.of(mu -> mu\n .index(\"my-index-000001\")\n .doc(JsonData.fromJson(\"{\\\"message\\\":\\\"test test test\\\"}\"))),MultiTermVectorsOperation.of(mu -> mu\n .index(\"my-index-000001\")\n .doc(JsonData.fromJson(\"{\\\"message\\\":\\\"Another test ...\\\"}\")))))\n);\n" - } - ], - "specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.info()" - }, - { - "language": "JavaScript", - "code": "const response = await client.info();" - }, - { - "language": "Ruby", - "code": "response = client.info" - }, - { - "language": "PHP", - "code": "$resp = $client->info();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/\"" - }, - { - "language": "Java", - "code": "client.info();\n" - } - ], - "specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.clear_scroll(\n scroll_id=\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.clearScroll({\n scroll_id: \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.clear_scroll(\n body: {\n \"scroll_id\": \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->clearScroll([\n \"body\" => [\n \"scroll_id\" => \"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scroll_id\":\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\"}' \"$ELASTICSEARCH_URL/_search/scroll\"" - }, - { - "language": "Java", - "code": "client.clearScroll(c -> c\n .scrollId(\"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==\")\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample9.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n script={\n \"source\": \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n script: {\n source: 'ctx._source.tag = ctx._source.remove(\"flag\")',\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n },\n \"script\": {\n \"source\": \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n \"script\" => [\n \"source\" => \"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"},\"script\":{\"source\":\"ctx._source.tag = ctx._source.remove(\\\"flag\\\")\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._source.tag = ctx._source.remove(\"flag\")\")\n )\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"source\"\n },\n dest={\n \"index\": \"dest\",\n \"pipeline\": \"some_ingest_pipeline\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"source\",\n },\n dest: {\n index: \"dest\",\n pipeline: \"some_ingest_pipeline\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"source\"\n },\n \"dest\": {\n \"index\": \"dest\",\n \"pipeline\": \"some_ingest_pipeline\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"source\",\n ],\n \"dest\" => [\n \"index\" => \"dest\",\n \"pipeline\" => \"some_ingest_pipeline\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"source\"},\"dest\":{\"index\":\"dest\",\"pipeline\":\"some_ingest_pipeline\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"dest\")\n .pipeline(\"some_ingest_pipeline\")\n )\n .source(s -> s\n .index(\"source\")\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample11.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n max_docs=10,\n source={\n \"index\": \"my-index-000001\",\n \"query\": {\n \"function_score\": {\n \"random_score\": {},\n \"min_score\": 0.9\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n max_docs: 10,\n source: {\n index: \"my-index-000001\",\n query: {\n function_score: {\n random_score: {},\n min_score: 0.9,\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"max_docs\": 10,\n \"source\": {\n \"index\": \"my-index-000001\",\n \"query\": {\n \"function_score\": {\n \"random_score\": {},\n \"min_score\": 0.9\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"max_docs\" => 10,\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"function_score\" => [\n \"random_score\" => new ArrayObject([]),\n \"min_score\" => 0.9,\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_docs\":10,\"source\":{\"index\":\"my-index-000001\",\"query\":{\"function_score\":{\"random_score\":{},\"min_score\":0.9}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .maxDocs(10L)\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .functionScore(f -> f\n .minScore(0.9D)\n )\n )\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample10.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"metricbeat-*\"\n },\n dest={\n \"index\": \"metricbeat\"\n },\n script={\n \"lang\": \"painless\",\n \"source\": \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"metricbeat-*\",\n },\n dest: {\n index: \"metricbeat\",\n },\n script: {\n lang: \"painless\",\n source:\n \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"metricbeat-*\"\n },\n \"dest\": {\n \"index\": \"metricbeat\"\n },\n \"script\": {\n \"lang\": \"painless\",\n \"source\": \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"metricbeat-*\",\n ],\n \"dest\" => [\n \"index\" => \"metricbeat\",\n ],\n \"script\" => [\n \"lang\" => \"painless\",\n \"source\" => \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"metricbeat-*\"},\"dest\":{\"index\":\"metricbeat\"},\"script\":{\"lang\":\"painless\",\"source\":\"ctx._index = '\"'\"'metricbeat-'\"'\"' + (ctx._index.substring('\"'\"'metricbeat-'\"'\"'.length(), ctx._index.length())) + '\"'\"'-1'\"'\"'\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"metricbeat\")\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'\")\n )\n .lang(\"painless\")\n )\n .source(so -> so\n .index(\"metricbeat-*\")\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"source\",\n \"query\": {\n \"match\": {\n \"company\": \"cat\"\n }\n }\n },\n dest={\n \"index\": \"dest\",\n \"routing\": \"=cat\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"source\",\n query: {\n match: {\n company: \"cat\",\n },\n },\n },\n dest: {\n index: \"dest\",\n routing: \"=cat\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"source\",\n \"query\": {\n \"match\": {\n \"company\": \"cat\"\n }\n }\n },\n \"dest\": {\n \"index\": \"dest\",\n \"routing\": \"=cat\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"source\",\n \"query\" => [\n \"match\" => [\n \"company\" => \"cat\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"dest\",\n \"routing\" => \"=cat\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"source\",\"query\":{\"match\":{\"company\":\"cat\"}}},\"dest\":{\"index\":\"dest\",\"routing\":\"=cat\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"dest\")\n .routing(\"=cat\")\n )\n .source(s -> s\n .index(\"source\")\n .query(q -> q\n .match(m -> m\n .field(\"company\")\n .query(FieldValue.of(\"cat\"))\n )\n )\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample8.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"_source\": [\n \"user.id\",\n \"_doc\"\n ]\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n _source: [\"user.id\", \"_doc\"],\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"_source\": [\n \"user.id\",\n \"_doc\"\n ]\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"_source\" => array(\n \"user.id\",\n \"_doc\",\n ),\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"_source\":[\"user.id\",\"_doc\"]},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .sourceFields(List.of(\"user.id\",\"_doc\"))\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n slices=\"5\",\n refresh=True,\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n slices: 5,\n refresh: \"true\",\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n slices: \"5\",\n refresh: \"true\",\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"slices\" => \"5\",\n \"refresh\" => \"true\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex?slices=5&refresh\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .refresh(true)\n .slices(s -> s\n .value(5)\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n slice: {\n id: 0,\n max: 2,\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"slice\": {\n \"id\": 0,\n \"max\": 2\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"slice\" => [\n \"id\" => 0,\n \"max\" => 2,\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"slice\":{\"id\":0,\"max\":2}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .slice(sl -> sl\n .id(\"0\")\n .max(2)\n )\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": [\n \"my-index-000001\",\n \"my-index-000002\"\n ]\n },\n dest={\n \"index\": \"my-new-index-000002\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: [\"my-index-000001\", \"my-index-000002\"],\n },\n dest: {\n index: \"my-new-index-000002\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": [\n \"my-index-000001\",\n \"my-index-000002\"\n ]\n },\n \"dest\": {\n \"index\": \"my-new-index-000002\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => array(\n \"my-index-000001\",\n \"my-index-000002\",\n ),\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000002\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":[\"my-index-000001\",\"my-index-000002\"]},\"dest\":{\"index\":\"my-new-index-000002\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000002\")\n )\n .source(s -> s\n .index(List.of(\"my-index-000001\",\"my-index-000002\"))\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample13.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"remote\": {\n \"host\": \"http://otherhost:9200\",\n \"username\": \"user\",\n \"password\": \"pass\"\n },\n \"index\": \"my-index-000001\",\n \"query\": {\n \"match\": {\n \"test\": \"data\"\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n remote: {\n host: \"http://otherhost:9200\",\n username: \"user\",\n password: \"pass\",\n },\n index: \"my-index-000001\",\n query: {\n match: {\n test: \"data\",\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"remote\": {\n \"host\": \"http://otherhost:9200\",\n \"username\": \"user\",\n \"password\": \"pass\"\n },\n \"index\": \"my-index-000001\",\n \"query\": {\n \"match\": {\n \"test\": \"data\"\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"remote\" => [\n \"host\" => \"http://otherhost:9200\",\n \"username\" => \"user\",\n \"password\" => \"pass\",\n ],\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"match\" => [\n \"test\" => \"data\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"remote\":{\"host\":\"http://otherhost:9200\",\"username\":\"user\",\"password\":\"pass\"},\"index\":\"my-index-000001\",\"query\":{\"match\":{\"test\":\"data\"}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .match(m -> m\n .field(\"test\")\n .query(FieldValue.of(\"data\"))\n )\n )\n .remote(re -> re\n .host(\"http://otherhost:9200\")\n .username(\"user\")\n .password(\"pass\")\n )\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample7.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n max_docs=1,\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n max_docs: 1,\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"max_docs\": 1,\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"max_docs\" => 1,\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_docs\":1,\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .maxDocs(1L)\n .source(s -> s\n .index(\"my-index-000001\")\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\",\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n },\n dest={\n \"index\": \"my-new-index-000001\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n query: {\n term: {\n \"user.id\": \"kimchy\",\n },\n },\n },\n dest: {\n index: \"my-new-index-000001\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\",\n \"query\": {\n \"term\": {\n \"user.id\": \"kimchy\"\n }\n }\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n \"query\" => [\n \"term\" => [\n \"user.id\" => \"kimchy\",\n ],\n ],\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"query\":{\"term\":{\"user.id\":\"kimchy\"}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n )\n .source(s -> s\n .index(\"my-index-000001\")\n .query(q -> q\n .term(t -> t\n .field(\"user.id\")\n .value(FieldValue.of(\"kimchy\"))\n )\n )\n )\n);\n" - } - ], - "specification/_global/reindex/examples/request/ReindexRequestExample12.yaml": [ - { - "language": "Python", - "code": "resp = client.reindex(\n source={\n \"index\": \"my-index-000001\"\n },\n dest={\n \"index\": \"my-new-index-000001\",\n \"version_type\": \"external\"\n },\n script={\n \"source\": \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\": \"painless\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.reindex({\n source: {\n index: \"my-index-000001\",\n },\n dest: {\n index: \"my-new-index-000001\",\n version_type: \"external\",\n },\n script: {\n source:\n \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n lang: \"painless\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.reindex(\n body: {\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\": {\n \"index\": \"my-new-index-000001\",\n \"version_type\": \"external\"\n },\n \"script\": {\n \"source\": \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\": \"painless\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->reindex([\n \"body\" => [\n \"source\" => [\n \"index\" => \"my-index-000001\",\n ],\n \"dest\" => [\n \"index\" => \"my-new-index-000001\",\n \"version_type\" => \"external\",\n ],\n \"script\" => [\n \"source\" => \"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\",\n \"lang\" => \"painless\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\",\"version_type\":\"external\"},\"script\":{\"source\":\"if (ctx._source.foo == '\"'\"'bar'\"'\"') {ctx._version++; ctx._source.remove('\"'\"'foo'\"'\"')}\",\"lang\":\"painless\"}}' \"$ELASTICSEARCH_URL/_reindex\"" - }, - { - "language": "Java", - "code": "client.reindex(r -> r\n .dest(d -> d\n .index(\"my-new-index-000001\")\n .versionType(VersionType.External)\n )\n .script(s -> s\n .source(so -> so\n .scriptString(\"if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}\")\n )\n .lang(\"painless\")\n )\n .source(so -> so\n .index(\"my-index-000001\")\n )\n);\n" - } - ], - "specification/_global/index/examples/request/IndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.index(\n index=\"my-index-000001\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.index({\n index: \"my-index-000001\",\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.index(\n index: \"my-index-000001\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->index([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_doc/\"" - }, - { - "language": "Java", - "code": "client.index(i -> i\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" - } - ], - "specification/_global/index/examples/request/IndexRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.index(\n index=\"my-index-000001\",\n id=\"1\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.index({\n index: \"my-index-000001\",\n id: 1,\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.index(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->index([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_doc/1\"" - }, - { - "language": "Java", - "code": "client.index(i -> i\n .id(\"1\")\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" - } - ], - "specification/_global/msearch/examples/request/MsearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.msearch(\n index=\"my-index-000001\",\n searches=[\n {},\n {\n \"query\": {\n \"match\": {\n \"message\": \"this is a test\"\n }\n }\n },\n {\n \"index\": \"my-index-000002\"\n },\n {\n \"query\": {\n \"match_all\": {}\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.msearch({\n index: \"my-index-000001\",\n searches: [\n {},\n {\n query: {\n match: {\n message: \"this is a test\",\n },\n },\n },\n {\n index: \"my-index-000002\",\n },\n {\n query: {\n match_all: {},\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.msearch(\n index: \"my-index-000001\",\n body: [\n {},\n {\n \"query\": {\n \"match\": {\n \"message\": \"this is a test\"\n }\n }\n },\n {\n \"index\": \"my-index-000002\"\n },\n {\n \"query\": {\n \"match_all\": {}\n }\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->msearch([\n \"index\" => \"my-index-000001\",\n \"body\" => array(\n new ArrayObject([]),\n [\n \"query\" => [\n \"match\" => [\n \"message\" => \"this is a test\",\n ],\n ],\n ],\n [\n \"index\" => \"my-index-000002\",\n ],\n [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{},{\"query\":{\"match\":{\"message\":\"this is a test\"}}},{\"index\":\"my-index-000002\"},{\"query\":{\"match_all\":{}}}]' \"$ELASTICSEARCH_URL/my-index-000001/_msearch\"" - } - ], - "specification/_global/delete_script/examples/request/DeleteScriptRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.delete_script(\n id=\"my-search-template\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.deleteScript({\n id: \"my-search-template\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.delete_script(\n id: \"my-search-template\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->deleteScript([\n \"id\" => \"my-search-template\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_scripts/my-search-template\"" - }, - { - "language": "Java", - "code": "client.deleteScript(d -> d\n .id(\"my-search-template\")\n);\n" - } - ], - "specification/_global/mget/examples/request/MultiGetRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.mget(\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"_source\": False\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"_source\": [\n \"field3\",\n \"field4\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"3\",\n \"_source\": {\n \"include\": [\n \"user\"\n ],\n \"exclude\": [\n \"user.location\"\n ]\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mget({\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n _source: false,\n },\n {\n _index: \"test\",\n _id: \"2\",\n _source: [\"field3\", \"field4\"],\n },\n {\n _index: \"test\",\n _id: \"3\",\n _source: {\n include: [\"user\"],\n exclude: [\"user.location\"],\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mget(\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"_source\": false\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"_source\": [\n \"field3\",\n \"field4\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"3\",\n \"_source\": {\n \"include\": [\n \"user\"\n ],\n \"exclude\": [\n \"user.location\"\n ]\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mget([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"_source\" => false,\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n \"_source\" => array(\n \"field3\",\n \"field4\",\n ),\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"3\",\n \"_source\" => [\n \"include\" => array(\n \"user\",\n ),\n \"exclude\" => array(\n \"user.location\",\n ),\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"_source\":false},{\"_index\":\"test\",\"_id\":\"2\",\"_source\":[\"field3\",\"field4\"]},{\"_index\":\"test\",\"_id\":\"3\",\"_source\":{\"include\":[\"user\"],\"exclude\":[\"user.location\"]}}]}' \"$ELASTICSEARCH_URL/_mget\"" - } - ], - "specification/_global/mget/examples/request/MultiGetRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.mget(\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"stored_fields\": [\n \"field1\",\n \"field2\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"stored_fields\": [\n \"field3\",\n \"field4\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mget({\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n stored_fields: [\"field1\", \"field2\"],\n },\n {\n _index: \"test\",\n _id: \"2\",\n stored_fields: [\"field3\", \"field4\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mget(\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"stored_fields\": [\n \"field1\",\n \"field2\"\n ]\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\",\n \"stored_fields\": [\n \"field3\",\n \"field4\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mget([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"stored_fields\" => array(\n \"field1\",\n \"field2\",\n ),\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n \"stored_fields\" => array(\n \"field3\",\n \"field4\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"stored_fields\":[\"field1\",\"field2\"]},{\"_index\":\"test\",\"_id\":\"2\",\"stored_fields\":[\"field3\",\"field4\"]}]}' \"$ELASTICSEARCH_URL/_mget\"" - }, - { - "language": "Java", - "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")\n .index(\"test\")\n .storedFields(List.of(\"field1\",\"field2\"))),MultiGetOperation.of(mu -> mu\n .id(\"2\")\n .index(\"test\")\n .storedFields(List.of(\"field3\",\"field4\")))))\n);\n" - } - ], - "specification/_global/mget/examples/request/MultiGetRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.mget(\n routing=\"key1\",\n docs=[\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"routing\": \"key2\"\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mget({\n routing: \"key1\",\n docs: [\n {\n _index: \"test\",\n _id: \"1\",\n routing: \"key2\",\n },\n {\n _index: \"test\",\n _id: \"2\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mget(\n routing: \"key1\",\n body: {\n \"docs\": [\n {\n \"_index\": \"test\",\n \"_id\": \"1\",\n \"routing\": \"key2\"\n },\n {\n \"_index\": \"test\",\n \"_id\": \"2\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mget([\n \"routing\" => \"key1\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"test\",\n \"_id\" => \"1\",\n \"routing\" => \"key2\",\n ],\n [\n \"_index\" => \"test\",\n \"_id\" => \"2\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"routing\":\"key2\"},{\"_index\":\"test\",\"_id\":\"2\"}]}' \"$ELASTICSEARCH_URL/_mget?routing=key1\"" - }, - { - "language": "Java", - "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")\n .index(\"test\")\n .routing(\"key2\")),MultiGetOperation.of(mu -> mu\n .id(\"2\")\n .index(\"test\"))))\n .routing(\"key1\")\n);\n" - } - ], - "specification/_global/mget/examples/request/MultiGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.mget(\n index=\"my-index-000001\",\n docs=[\n {\n \"_id\": \"1\"\n },\n {\n \"_id\": \"2\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.mget({\n index: \"my-index-000001\",\n docs: [\n {\n _id: \"1\",\n },\n {\n _id: \"2\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.mget(\n index: \"my-index-000001\",\n body: {\n \"docs\": [\n {\n \"_id\": \"1\"\n },\n {\n \"_id\": \"2\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->mget([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"1\",\n ],\n [\n \"_id\" => \"2\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"1\"},{\"_id\":\"2\"}]}' \"$ELASTICSEARCH_URL/my-index-000001/_mget\"" - }, - { - "language": "Java", - "code": "client.mget(m -> m\n .docs(List.of(MultiGetOperation.of(mu -> mu\n .id(\"1\")),MultiGetOperation.of(mu -> mu\n .id(\"2\"))))\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/create/examples/request/CreateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.create(\n index=\"my-index-000001\",\n id=\"1\",\n document={\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.create({\n index: \"my-index-000001\",\n id: 1,\n document: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n message: \"GET /search HTTP/1.1 200 1070000\",\n user: {\n id: \"kimchy\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.create(\n index: \"my-index-000001\",\n id: \"1\",\n body: {\n \"@timestamp\": \"2099-11-15T13:12:00\",\n \"message\": \"GET /search HTTP/1.1 200 1070000\",\n \"user\": {\n \"id\": \"kimchy\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->create([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n \"body\" => [\n \"@timestamp\" => \"2099-11-15T13:12:00\",\n \"message\" => \"GET /search HTTP/1.1 200 1070000\",\n \"user\" => [\n \"id\" => \"kimchy\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}' \"$ELASTICSEARCH_URL/my-index-000001/_create/1\"" - }, - { - "language": "Java", - "code": "client.create(c -> c\n .id(\"1\")\n .index(\"my-index-000001\")\n .document(JsonData.fromJson(\"{\\\"@timestamp\\\":\\\"2099-11-15T13:12:00\\\",\\\"message\\\":\\\"GET /search HTTP/1.1 200 1070000\\\",\\\"user\\\":{\\\"id\\\":\\\"kimchy\\\"}}\"))\n);\n" - } - ], - "specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rank_eval(\n index=\"my-index-000001\",\n requests=[\n {\n \"id\": \"JFK query\",\n \"request\": {\n \"query\": {\n \"match_all\": {}\n }\n },\n \"ratings\": []\n }\n ],\n metric={\n \"precision\": {\n \"k\": 20,\n \"relevant_rating_threshold\": 1,\n \"ignore_unlabeled\": False\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rankEval({\n index: \"my-index-000001\",\n requests: [\n {\n id: \"JFK query\",\n request: {\n query: {\n match_all: {},\n },\n },\n ratings: [],\n },\n ],\n metric: {\n precision: {\n k: 20,\n relevant_rating_threshold: 1,\n ignore_unlabeled: false,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.rank_eval(\n index: \"my-index-000001\",\n body: {\n \"requests\": [\n {\n \"id\": \"JFK query\",\n \"request\": {\n \"query\": {\n \"match_all\": {}\n }\n },\n \"ratings\": []\n }\n ],\n \"metric\": {\n \"precision\": {\n \"k\": 20,\n \"relevant_rating_threshold\": 1,\n \"ignore_unlabeled\": false\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rankEval([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"requests\" => array(\n [\n \"id\" => \"JFK query\",\n \"request\" => [\n \"query\" => [\n \"match_all\" => new ArrayObject([]),\n ],\n ],\n \"ratings\" => array(\n ),\n ],\n ),\n \"metric\" => [\n \"precision\" => [\n \"k\" => 20,\n \"relevant_rating_threshold\" => 1,\n \"ignore_unlabeled\" => false,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"requests\":[{\"id\":\"JFK query\",\"request\":{\"query\":{\"match_all\":{}}},\"ratings\":[]}],\"metric\":{\"precision\":{\"k\":20,\"relevant_rating_threshold\":1,\"ignore_unlabeled\":false}}}' \"$ELASTICSEARCH_URL/my-index-000001/_rank_eval\"" - }, - { - "language": "Java", - "code": "client.rankEval(r -> r\n .index(\"my-index-000001\")\n .metric(m -> m\n .precision(p -> p\n .ignoreUnlabeled(false)\n .relevantRatingThreshold(1)\n .k(20)\n )\n )\n .requests(re -> re\n .id(\"JFK query\")\n .request(req -> req\n .query(q -> q\n .matchAll(m -> m)\n )\n )\n )\n);\n" - } - ], - "specification/_global/exists_source/examples/request/ExistsSourceRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.exists_source(\n index=\"my-index-000001\",\n id=\"1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.existsSource({\n index: \"my-index-000001\",\n id: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.exists_source(\n index: \"my-index-000001\",\n id: \"1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->existsSource([\n \"index\" => \"my-index-000001\",\n \"id\" => \"1\",\n]);" - }, - { - "language": "curl", - "code": "curl --head -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_source/1\"" - }, - { - "language": "Java", - "code": "client.existsSource(e -> e\n .id(\"1\")\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.close_point_in_time(\n id=\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.closePointInTime({\n id: \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.close_point_in_time(\n body: {\n \"id\": \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->closePointInTime([\n \"body\" => [\n \"id\" => \"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"}' \"$ELASTICSEARCH_URL/_pit\"" - }, - { - "language": "Java", - "code": "client.closePointInTime(c -> c\n .id(\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\")\n);\n" - } - ], - "specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.shutdown.put_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n type=\"restart\",\n reason=\"Demonstrating how the node shutdown API works\",\n allocation_delay=\"20m\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.shutdown.putNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n type: \"restart\",\n reason: \"Demonstrating how the node shutdown API works\",\n allocation_delay: \"20m\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.shutdown.put_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n body: {\n \"type\": \"restart\",\n \"reason\": \"Demonstrating how the node shutdown API works\",\n \"allocation_delay\": \"20m\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->shutdown()->putNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n \"body\" => [\n \"type\" => \"restart\",\n \"reason\" => \"Demonstrating how the node shutdown API works\",\n \"allocation_delay\" => \"20m\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"type\":\"restart\",\"reason\":\"Demonstrating how the node shutdown API works\",\"allocation_delay\":\"20m\"}' \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" - }, - { - "language": "Java", - "code": "client.shutdown().putNode(p -> p\n .allocationDelay(\"20m\")\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n .reason(\"Demonstrating how the node shutdown API works\")\n .type(Type.Restart)\n);\n" - } - ], - "specification/shutdown/delete_node/examples/request/ShutdownDeleteNodeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.shutdown.delete_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.shutdown.deleteNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.shutdown.delete_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->shutdown()->deleteNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" - }, - { - "language": "Java", - "code": "client.shutdown().deleteNode(d -> d\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n);\n" - } - ], - "specification/shutdown/get_node/examples/request/ShutdownGetNodeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.shutdown.get_node(\n node_id=\"USpTGYaBSIKbgSUJR2Z9lg\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.shutdown.getNode({\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.shutdown.get_node(\n node_id: \"USpTGYaBSIKbgSUJR2Z9lg\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->shutdown()->getNode([\n \"node_id\" => \"USpTGYaBSIKbgSUJR2Z9lg\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown\"" - }, - { - "language": "Java", - "code": "client.shutdown().getNode(g -> g\n .nodeId(\"USpTGYaBSIKbgSUJR2Z9lg\")\n);\n" - } - ], - "specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.update_settings(\n index.auto_expand_replicas=\"0-4\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.updateSettings({\n \"index.auto_expand_replicas\": \"0-4\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.update_settings(\n body: {\n \"index.auto_expand_replicas\": \"0-4\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->updateSettings([\n \"body\" => [\n \"index.auto_expand_replicas\" => \"0-4\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index.auto_expand_replicas\":\"0-4\"}' \"$ELASTICSEARCH_URL/_watcher/settings\"" - }, - { - "language": "Java", - "code": "client.watcher().updateSettings(u -> u\n .indexAutoExpandReplicas(\"0-4\")\n);\n" - } - ], - "specification/watcher/activate_watch/examples/request/WatcherActivateWatchExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.activate_watch(\n watch_id=\"my_watch\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.activateWatch({\n watch_id: \"my_watch\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.activate_watch(\n watch_id: \"my_watch\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->activateWatch([\n \"watch_id\" => \"my_watch\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_activate\"" - }, - { - "language": "Java", - "code": "client.watcher().activateWatch(a -> a\n .watchId(\"my_watch\")\n);\n" - } - ], - "specification/watcher/get_settings/examples/request/WatcherGetSettingsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.get_settings()" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.getSettings();" - }, - { - "language": "Ruby", - "code": "response = client.watcher.get_settings" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->getSettings();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/settings\"" - }, - { - "language": "Java", - "code": "client.watcher().getSettings(g -> g);\n" - } - ], - "specification/watcher/deactivate_watch/examples/request/WatcherDeactivateWatchExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.deactivate_watch(\n watch_id=\"my_watch\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.deactivateWatch({\n watch_id: \"my_watch\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.deactivate_watch(\n watch_id: \"my_watch\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->deactivateWatch([\n \"watch_id\" => \"my_watch\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_deactivate\"" - }, - { - "language": "Java", - "code": "client.watcher().deactivateWatch(d -> d\n .watchId(\"my_watch\")\n);\n" - } - ], - "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.execute_watch(\n id=\"my_watch\",\n trigger_data={\n \"triggered_time\": \"now\",\n \"scheduled_time\": \"now\"\n },\n alternative_input={\n \"foo\": \"bar\"\n },\n ignore_condition=True,\n action_modes={\n \"my-action\": \"force_simulate\"\n },\n record_execution=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.executeWatch({\n id: \"my_watch\",\n trigger_data: {\n triggered_time: \"now\",\n scheduled_time: \"now\",\n },\n alternative_input: {\n foo: \"bar\",\n },\n ignore_condition: true,\n action_modes: {\n \"my-action\": \"force_simulate\",\n },\n record_execution: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.execute_watch(\n id: \"my_watch\",\n body: {\n \"trigger_data\": {\n \"triggered_time\": \"now\",\n \"scheduled_time\": \"now\"\n },\n \"alternative_input\": {\n \"foo\": \"bar\"\n },\n \"ignore_condition\": true,\n \"action_modes\": {\n \"my-action\": \"force_simulate\"\n },\n \"record_execution\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->executeWatch([\n \"id\" => \"my_watch\",\n \"body\" => [\n \"trigger_data\" => [\n \"triggered_time\" => \"now\",\n \"scheduled_time\" => \"now\",\n ],\n \"alternative_input\" => [\n \"foo\" => \"bar\",\n ],\n \"ignore_condition\" => true,\n \"action_modes\" => [\n \"my-action\" => \"force_simulate\",\n ],\n \"record_execution\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"trigger_data\":{\"triggered_time\":\"now\",\"scheduled_time\":\"now\"},\"alternative_input\":{\"foo\":\"bar\"},\"ignore_condition\":true,\"action_modes\":{\"my-action\":\"force_simulate\"},\"record_execution\":true}' \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute\"" - }, - { - "language": "Java", - "code": "client.watcher().executeWatch(e -> e\n .actionModes(\"my-action\", ActionExecutionMode.ForceSimulate)\n .alternativeInput(\"foo\", JsonData.fromJson(\"\\\"bar\\\"\"))\n .id(\"my_watch\")\n .ignoreCondition(true)\n .recordExecution(true)\n .triggerData(t -> t\n .scheduledTime(DateTime.of(\"now\"))\n .triggeredTime(DateTime.of(\"now\"))\n )\n);\n" - } - ], - "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.execute_watch(\n id=\"my_watch\",\n action_modes={\n \"action1\": \"force_simulate\",\n \"action2\": \"skip\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.executeWatch({\n id: \"my_watch\",\n action_modes: {\n action1: \"force_simulate\",\n action2: \"skip\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.execute_watch(\n id: \"my_watch\",\n body: {\n \"action_modes\": {\n \"action1\": \"force_simulate\",\n \"action2\": \"skip\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->executeWatch([\n \"id\" => \"my_watch\",\n \"body\" => [\n \"action_modes\" => [\n \"action1\" => \"force_simulate\",\n \"action2\" => \"skip\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"action_modes\":{\"action1\":\"force_simulate\",\"action2\":\"skip\"}}' \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute\"" - }, - { - "language": "Java", - "code": "client.watcher().executeWatch(e -> e\n .actionModes(Map.of(\"action1\", ActionExecutionMode.ForceSimulate,\"action2\", ActionExecutionMode.Skip))\n .id(\"my_watch\")\n);\n" - } - ], - "specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.execute_watch(\n watch={\n \"trigger\": {\n \"schedule\": {\n \"interval\": \"10s\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logs\"\n ],\n \"body\": {\n \"query\": {\n \"match\": {\n \"message\": \"error\"\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"log_error\": {\n \"logging\": {\n \"text\": \"Found {{ctx.payload.hits.total}} errors in the logs\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.executeWatch({\n watch: {\n trigger: {\n schedule: {\n interval: \"10s\",\n },\n },\n input: {\n search: {\n request: {\n indices: [\"logs\"],\n body: {\n query: {\n match: {\n message: \"error\",\n },\n },\n },\n },\n },\n },\n condition: {\n compare: {\n \"ctx.payload.hits.total\": {\n gt: 0,\n },\n },\n },\n actions: {\n log_error: {\n logging: {\n text: \"Found {{ctx.payload.hits.total}} errors in the logs\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.execute_watch(\n body: {\n \"watch\": {\n \"trigger\": {\n \"schedule\": {\n \"interval\": \"10s\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logs\"\n ],\n \"body\": {\n \"query\": {\n \"match\": {\n \"message\": \"error\"\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"log_error\": {\n \"logging\": {\n \"text\": \"Found {{ctx.payload.hits.total}} errors in the logs\"\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->executeWatch([\n \"body\" => [\n \"watch\" => [\n \"trigger\" => [\n \"schedule\" => [\n \"interval\" => \"10s\",\n ],\n ],\n \"input\" => [\n \"search\" => [\n \"request\" => [\n \"indices\" => array(\n \"logs\",\n ),\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"message\" => \"error\",\n ],\n ],\n ],\n ],\n ],\n ],\n \"condition\" => [\n \"compare\" => [\n \"ctx.payload.hits.total\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"actions\" => [\n \"log_error\" => [\n \"logging\" => [\n \"text\" => \"Found {{ctx.payload.hits.total}} errors in the logs\",\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"watch\":{\"trigger\":{\"schedule\":{\"interval\":\"10s\"}},\"input\":{\"search\":{\"request\":{\"indices\":[\"logs\"],\"body\":{\"query\":{\"match\":{\"message\":\"error\"}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\"actions\":{\"log_error\":{\"logging\":{\"text\":\"Found {{ctx.payload.hits.total}} errors in the logs\"}}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/_execute\"" - }, - { - "language": "Java", - "code": "client.watcher().executeWatch(e -> e\n .watch(w -> w\n .actions(\"log_error\", a -> a\n .logging(l -> l\n .text(\"Found {{ctx.payload.hits.total}} errors in the logs\")\n )\n )\n .condition(c -> c\n .compare(NamedValue.of(\"ctx.payload.hits.total\",Pair.of(ConditionOp.Gt,FieldValue.of(0))))\n )\n .input(i -> i\n .search(s -> s\n .request(r -> r\n .body(b -> b\n .query(q -> q\n .match(m -> m\n .field(\"message\")\n .query(FieldValue.of(\"error\"))\n )\n )\n )\n .indices(\"logs\")\n )\n )\n )\n .trigger(t -> t\n .schedule(sc -> sc\n .interval(in -> in\n .time(\"10s\")\n )\n )\n )\n )\n);\n" - } - ], - "specification/watcher/start/examples/request/WatcherStartRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.start()" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.start();" - }, - { - "language": "Ruby", - "code": "response = client.watcher.start" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->start();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_start\"" - }, - { - "language": "Java", - "code": "client.watcher().start(s -> s);\n" - } - ], - "specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.query_watches()" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.queryWatches();" - }, - { - "language": "Ruby", - "code": "response = client.watcher.query_watches" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->queryWatches();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_query/watches\"" - }, - { - "language": "Java", - "code": "client.watcher().queryWatches();\n" - } - ], - "specification/watcher/stop/examples/request/WatcherStopRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.stop()" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.stop();" - }, - { - "language": "Ruby", - "code": "response = client.watcher.stop" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->stop();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/_stop\"" - }, - { - "language": "Java", - "code": "client.watcher().stop(s -> s);\n" - } - ], - "specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.put_watch(\n id=\"my-watch\",\n trigger={\n \"schedule\": {\n \"cron\": \"0 0/1 * * * ?\"\n }\n },\n input={\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logstash*\"\n ],\n \"body\": {\n \"query\": {\n \"bool\": {\n \"must\": {\n \"match\": {\n \"response\": 404\n }\n },\n \"filter\": {\n \"range\": {\n \"@timestamp\": {\n \"from\": \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\": \"{{ctx.trigger.triggered_time}}\"\n }\n }\n }\n }\n }\n }\n }\n }\n },\n condition={\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n actions={\n \"email_admin\": {\n \"email\": {\n \"to\": \"admin@domain.host.com\",\n \"subject\": \"404 recently encountered\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.putWatch({\n id: \"my-watch\",\n trigger: {\n schedule: {\n cron: \"0 0/1 * * * ?\",\n },\n },\n input: {\n search: {\n request: {\n indices: [\"logstash*\"],\n body: {\n query: {\n bool: {\n must: {\n match: {\n response: 404,\n },\n },\n filter: {\n range: {\n \"@timestamp\": {\n from: \"{{ctx.trigger.scheduled_time}}||-5m\",\n to: \"{{ctx.trigger.triggered_time}}\",\n },\n },\n },\n },\n },\n },\n },\n },\n },\n condition: {\n compare: {\n \"ctx.payload.hits.total\": {\n gt: 0,\n },\n },\n },\n actions: {\n email_admin: {\n email: {\n to: \"admin@domain.host.com\",\n subject: \"404 recently encountered\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.put_watch(\n id: \"my-watch\",\n body: {\n \"trigger\": {\n \"schedule\": {\n \"cron\": \"0 0/1 * * * ?\"\n }\n },\n \"input\": {\n \"search\": {\n \"request\": {\n \"indices\": [\n \"logstash*\"\n ],\n \"body\": {\n \"query\": {\n \"bool\": {\n \"must\": {\n \"match\": {\n \"response\": 404\n }\n },\n \"filter\": {\n \"range\": {\n \"@timestamp\": {\n \"from\": \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\": \"{{ctx.trigger.triggered_time}}\"\n }\n }\n }\n }\n }\n }\n }\n }\n },\n \"condition\": {\n \"compare\": {\n \"ctx.payload.hits.total\": {\n \"gt\": 0\n }\n }\n },\n \"actions\": {\n \"email_admin\": {\n \"email\": {\n \"to\": \"admin@domain.host.com\",\n \"subject\": \"404 recently encountered\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->putWatch([\n \"id\" => \"my-watch\",\n \"body\" => [\n \"trigger\" => [\n \"schedule\" => [\n \"cron\" => \"0 0/1 * * * ?\",\n ],\n ],\n \"input\" => [\n \"search\" => [\n \"request\" => [\n \"indices\" => array(\n \"logstash*\",\n ),\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => [\n \"match\" => [\n \"response\" => 404,\n ],\n ],\n \"filter\" => [\n \"range\" => [\n \"@timestamp\" => [\n \"from\" => \"{{ctx.trigger.scheduled_time}}||-5m\",\n \"to\" => \"{{ctx.trigger.triggered_time}}\",\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n \"condition\" => [\n \"compare\" => [\n \"ctx.payload.hits.total\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"actions\" => [\n \"email_admin\" => [\n \"email\" => [\n \"to\" => \"admin@domain.host.com\",\n \"subject\" => \"404 recently encountered\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"trigger\":{\"schedule\":{\"cron\":\"0 0/1 * * * ?\"}},\"input\":{\"search\":{\"request\":{\"indices\":[\"logstash*\"],\"body\":{\"query\":{\"bool\":{\"must\":{\"match\":{\"response\":404}},\"filter\":{\"range\":{\"@timestamp\":{\"from\":\"{{ctx.trigger.scheduled_time}}||-5m\",\"to\":\"{{ctx.trigger.triggered_time}}\"}}}}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\"actions\":{\"email_admin\":{\"email\":{\"to\":\"admin@domain.host.com\",\"subject\":\"404 recently encountered\"}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/my-watch\"" - }, - { - "language": "Java", - "code": "client.watcher().putWatch(p -> p\n .actions(\"email_admin\", a -> a\n .email(e -> e\n .subject(\"404 recently encountered\")\n .to(\"admin@domain.host.com\")\n )\n )\n .condition(c -> c\n .compare(NamedValue.of(\"ctx.payload.hits.total\",Pair.of(ConditionOp.Gt,FieldValue.of(0))))\n )\n .id(\"my-watch\")\n .input(i -> i\n .search(s -> s\n .request(r -> r\n .body(b -> b\n .query(q -> q\n .bool(bo -> bo\n .filter(f -> f\n .range(ra -> ra\n .untyped(u -> u\n .field(\"@timestamp\")\n )\n )\n )\n .must(m -> m\n .match(ma -> ma\n .field(\"response\")\n .query(FieldValue.of(404))\n )\n )\n )\n )\n )\n .indices(\"logstash*\")\n )\n )\n )\n .trigger(t -> t\n .schedule(sc -> sc\n .cron(\"0 0/1 * * * ?\")\n )\n )\n);\n" - } - ], - "specification/watcher/get_watch/examples/request/GetWatchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.get_watch(\n id=\"my_watch\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.getWatch({\n id: \"my_watch\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.get_watch(\n id: \"my_watch\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->getWatch([\n \"id\" => \"my_watch\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch\"" - }, - { - "language": "Java", - "code": "client.watcher().getWatch(g -> g\n .id(\"my_watch\")\n);\n" - } - ], - "specification/watcher/ack_watch/examples/request/WatcherAckWatchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.ack_watch(\n watch_id=\"my_watch\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.ackWatch({\n watch_id: \"my_watch\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.ack_watch(\n watch_id: \"my_watch\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->ackWatch([\n \"watch_id\" => \"my_watch\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_ack\"" - }, - { - "language": "Java", - "code": "client.watcher().ackWatch(a -> a\n .watchId(\"my_watch\")\n);\n" - } - ], - "specification/watcher/delete_watch/examples/request/DeleteWatchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.delete_watch(\n id=\"my_watch\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.deleteWatch({\n id: \"my_watch\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.watcher.delete_watch(\n id: \"my_watch\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->deleteWatch([\n \"id\" => \"my_watch\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/watch/my_watch\"" - }, - { - "language": "Java", - "code": "client.watcher().deleteWatch(d -> d\n .id(\"my_watch\")\n);\n" - } - ], - "specification/watcher/stats/examples/request/WatcherStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.watcher.stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.watcher.stats();" - }, - { - "language": "Ruby", - "code": "response = client.watcher.stats" - }, - { - "language": "PHP", - "code": "$resp = $client->watcher()->stats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_watcher/stats\"" - }, - { - "language": "Java", - "code": "client.watcher().stats(s -> s);\n" - } - ], - "specification/license/post/examples/request/PostLicenseRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.post(\n licenses=[\n {\n \"uid\": \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\": \"basic\",\n \"issue_date_in_millis\": 1411948800000,\n \"expiry_date_in_millis\": 1914278399999,\n \"max_nodes\": 1,\n \"issued_to\": \"issuedTo\",\n \"issuer\": \"issuer\",\n \"signature\": \"xx\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.post({\n licenses: [\n {\n uid: \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n type: \"basic\",\n issue_date_in_millis: 1411948800000,\n expiry_date_in_millis: 1914278399999,\n max_nodes: 1,\n issued_to: \"issuedTo\",\n issuer: \"issuer\",\n signature: \"xx\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.license.post(\n body: {\n \"licenses\": [\n {\n \"uid\": \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\": \"basic\",\n \"issue_date_in_millis\": 1411948800000,\n \"expiry_date_in_millis\": 1914278399999,\n \"max_nodes\": 1,\n \"issued_to\": \"issuedTo\",\n \"issuer\": \"issuer\",\n \"signature\": \"xx\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->post([\n \"body\" => [\n \"licenses\" => array(\n [\n \"uid\" => \"893361dc-9749-4997-93cb-802e3d7fa4xx\",\n \"type\" => \"basic\",\n \"issue_date_in_millis\" => 1411948800000,\n \"expiry_date_in_millis\" => 1914278399999,\n \"max_nodes\" => 1,\n \"issued_to\" => \"issuedTo\",\n \"issuer\" => \"issuer\",\n \"signature\" => \"xx\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"licenses\":[{\"uid\":\"893361dc-9749-4997-93cb-802e3d7fa4xx\",\"type\":\"basic\",\"issue_date_in_millis\":1411948800000,\"expiry_date_in_millis\":1914278399999,\"max_nodes\":1,\"issued_to\":\"issuedTo\",\"issuer\":\"issuer\",\"signature\":\"xx\"}]}' \"$ELASTICSEARCH_URL/_license\"" - }, - { - "language": "Java", - "code": "client.license().post(p -> p\n .licenses(l -> l\n .expiryDateInMillis(1914278399999L)\n .issueDateInMillis(1411948800000L)\n .issuedTo(\"issuedTo\")\n .issuer(\"issuer\")\n .maxNodes(1L)\n .signature(\"xx\")\n .type(LicenseType.Basic)\n .uid(\"893361dc-9749-4997-93cb-802e3d7fa4xx\")\n )\n);\n" - } - ], - "specification/license/delete/examples/request/LicenseDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.delete()" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.delete();" - }, - { - "language": "Ruby", - "code": "response = client.license.delete" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->delete();" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license\"" - }, - { - "language": "Java", - "code": "client.license().delete(d -> d);\n" - } - ], - "specification/license/get/examples/request/GetLicenseRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.get()" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.get();" - }, - { - "language": "Ruby", - "code": "response = client.license.get" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->get();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license\"" - }, - { - "language": "Java", - "code": "client.license().get(g -> g);\n" - } - ], - "specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.get_trial_status()" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.getTrialStatus();" - }, - { - "language": "Ruby", - "code": "response = client.license.get_trial_status" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->getTrialStatus();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/trial_status\"" - }, - { - "language": "Java", - "code": "client.license().getTrialStatus();\n" - } - ], - "specification/license/post_start_trial/examples/request/StartTrialLicenseRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.post_start_trial(\n acknowledge=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.postStartTrial({\n acknowledge: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.license.post_start_trial(\n acknowledge: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->postStartTrial([\n \"acknowledge\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/start_trial?acknowledge=true\"" - }, - { - "language": "Java", - "code": "client.license().postStartTrial(p -> p\n .acknowledge(true)\n);\n" - } - ], - "specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.get_basic_status()" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.getBasicStatus();" - }, - { - "language": "Ruby", - "code": "response = client.license.get_basic_status" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->getBasicStatus();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/basic_status\"" - }, - { - "language": "Java", - "code": "client.license().getBasicStatus();\n" - } - ], - "specification/license/post_start_basic/examples/request/StartBasicLicenseRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.license.post_start_basic(\n acknowledge=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.license.postStartBasic({\n acknowledge: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.license.post_start_basic(\n acknowledge: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->license()->postStartBasic([\n \"acknowledge\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_license/start_basic?acknowledge=true\"" - }, - { - "language": "Java", - "code": "client.license().postStartBasic(p -> p\n .acknowledge(true)\n);\n" - } - ], - "specification/logstash/get_pipeline/examples/request/LogstashGetPipelineRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.logstash.get_pipeline(\n id=\"my_pipeline\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.logstash.getPipeline({\n id: \"my_pipeline\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.logstash.get_pipeline(\n id: \"my_pipeline\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->logstash()->getPipeline([\n \"id\" => \"my_pipeline\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" - }, - { - "language": "Java", - "code": "client.logstash().getPipeline(g -> g\n .id(\"my_pipeline\")\n);\n" - } - ], - "specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.logstash.put_pipeline(\n id=\"my_pipeline\",\n pipeline={\n \"description\": \"Sample pipeline for illustration purposes\",\n \"last_modified\": \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\": {\n \"type\": \"logstash_pipeline\",\n \"version\": 1\n },\n \"username\": \"elastic\",\n \"pipeline\": \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\": {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.logstash.putPipeline({\n id: \"my_pipeline\",\n pipeline: {\n description: \"Sample pipeline for illustration purposes\",\n last_modified: \"2021-01-02T02:50:51.250Z\",\n pipeline_metadata: {\n type: \"logstash_pipeline\",\n version: 1,\n },\n username: \"elastic\",\n pipeline: \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n pipeline_settings: {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.logstash.put_pipeline(\n id: \"my_pipeline\",\n body: {\n \"description\": \"Sample pipeline for illustration purposes\",\n \"last_modified\": \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\": {\n \"type\": \"logstash_pipeline\",\n \"version\": 1\n },\n \"username\": \"elastic\",\n \"pipeline\": \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\": {\n \"pipeline.workers\": 1,\n \"pipeline.batch.size\": 125,\n \"pipeline.batch.delay\": 50,\n \"queue.type\": \"memory\",\n \"queue.max_bytes\": \"1gb\",\n \"queue.checkpoint.writes\": 1024\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->logstash()->putPipeline([\n \"id\" => \"my_pipeline\",\n \"body\" => [\n \"description\" => \"Sample pipeline for illustration purposes\",\n \"last_modified\" => \"2021-01-02T02:50:51.250Z\",\n \"pipeline_metadata\" => [\n \"type\" => \"logstash_pipeline\",\n \"version\" => 1,\n ],\n \"username\" => \"elastic\",\n \"pipeline\" => \"input {}\\\\n filter { grok {} }\\\\n output {}\",\n \"pipeline_settings\" => [\n \"pipeline.workers\" => 1,\n \"pipeline.batch.size\" => 125,\n \"pipeline.batch.delay\" => 50,\n \"queue.type\" => \"memory\",\n \"queue.max_bytes\" => \"1gb\",\n \"queue.checkpoint.writes\" => 1024,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Sample pipeline for illustration purposes\",\"last_modified\":\"2021-01-02T02:50:51.250Z\",\"pipeline_metadata\":{\"type\":\"logstash_pipeline\",\"version\":1},\"username\":\"elastic\",\"pipeline\":\"input {}\\\\n filter { grok {} }\\\\n output {}\",\"pipeline_settings\":{\"pipeline.workers\":1,\"pipeline.batch.size\":125,\"pipeline.batch.delay\":50,\"queue.type\":\"memory\",\"queue.max_bytes\":\"1gb\",\"queue.checkpoint.writes\":1024}}' \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" - }, - { - "language": "Java", - "code": "client.logstash().putPipeline(p -> p\n .id(\"my_pipeline\")\n .pipeline(pi -> pi\n .description(\"Sample pipeline for illustration purposes\")\n .lastModified(DateTime.of(\"2021-01-02T02:50:51.250Z\"))\n .pipeline(\"input {}\\n filter { grok {} }\\n output {}\")\n .pipelineMetadata(pip -> pip\n .type(\"logstash_pipeline\")\n .version(\"1\")\n )\n .pipelineSettings(pip -> pip\n .pipelineWorkers(1)\n .pipelineBatchSize(125)\n .pipelineBatchDelay(50)\n .queueType(\"memory\")\n .queueMaxBytes(\"1gb\")\n .queueCheckpointWrites(1024)\n )\n .username(\"elastic\")\n )\n);\n" - } - ], - "specification/logstash/delete_pipeline/examples/request/LogstashDeletePipelineExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.logstash.delete_pipeline(\n id=\"my_pipeline\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.logstash.deletePipeline({\n id: \"my_pipeline\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.logstash.delete_pipeline(\n id: \"my_pipeline\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->logstash()->deletePipeline([\n \"id\" => \"my_pipeline\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" - }, - { - "language": "Java", - "code": "client.logstash().deletePipeline(d -> d\n .id(\"my_pipeline\")\n);\n" - } - ], - "specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_complete_logout(\n realm=\"saml1\",\n ids=[\n \"_1c368075e0b3...\"\n ],\n content=\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlCompleteLogout({\n realm: \"saml1\",\n ids: [\"_1c368075e0b3...\"],\n content: \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_complete_logout(\n body: {\n \"realm\": \"saml1\",\n \"ids\": [\n \"_1c368075e0b3...\"\n ],\n \"content\": \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlCompleteLogout([\n \"body\" => [\n \"realm\" => \"saml1\",\n \"ids\" => array(\n \"_1c368075e0b3...\",\n ),\n \"content\" => \"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\",\"ids\":[\"_1c368075e0b3...\"],\"content\":\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\"}' \"$ELASTICSEARCH_URL/_security/saml/complete_logout\"" - }, - { - "language": "Java", - "code": "client.security().samlCompleteLogout(s -> s\n .content(\"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...\")\n .ids(\"_1c368075e0b3...\")\n .realm(\"saml1\")\n);\n" - } - ], - "specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_complete_logout(\n realm=\"saml1\",\n ids=[\n \"_1c368075e0b3...\"\n ],\n query_string=\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlCompleteLogout({\n realm: \"saml1\",\n ids: [\"_1c368075e0b3...\"],\n query_string:\n \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_complete_logout(\n body: {\n \"realm\": \"saml1\",\n \"ids\": [\n \"_1c368075e0b3...\"\n ],\n \"query_string\": \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlCompleteLogout([\n \"body\" => [\n \"realm\" => \"saml1\",\n \"ids\" => array(\n \"_1c368075e0b3...\",\n ),\n \"query_string\" => \"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\",\"ids\":[\"_1c368075e0b3...\"],\"query_string\":\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\"}' \"$ELASTICSEARCH_URL/_security/saml/complete_logout\"" - }, - { - "language": "Java", - "code": "client.security().samlCompleteLogout(s -> s\n .ids(\"_1c368075e0b3...\")\n .queryString(\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\")\n .realm(\"saml1\")\n);\n" - } - ], - "specification/security/disable_user/examples/request/SecurityDisableUserExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.disable_user(\n username=\"jacknich\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.disableUser({\n username: \"jacknich\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.disable_user(\n username: \"jacknich\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->disableUser([\n \"username\" => \"jacknich\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich/_disable\"" - }, - { - "language": "Java", - "code": "client.security().disableUser(d -> d\n .username(\"jacknich\")\n);\n" - } - ], - "specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_settings(\n security={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n security-tokens={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n security-profile={\n \"index.auto_expand_replicas\": \"0-all\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateSettings({\n security: {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n \"security-tokens\": {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n \"security-profile\": {\n \"index.auto_expand_replicas\": \"0-all\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_settings(\n body: {\n \"security\": {\n \"index.auto_expand_replicas\": \"0-all\"\n },\n \"security-tokens\": {\n \"index.auto_expand_replicas\": \"0-all\"\n },\n \"security-profile\": {\n \"index.auto_expand_replicas\": \"0-all\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateSettings([\n \"body\" => [\n \"security\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n \"security-tokens\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n \"security-profile\" => [\n \"index.auto_expand_replicas\" => \"0-all\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"security\":{\"index.auto_expand_replicas\":\"0-all\"},\"security-tokens\":{\"index.auto_expand_replicas\":\"0-all\"},\"security-profile\":{\"index.auto_expand_replicas\":\"0-all\"}}' \"$ELASTICSEARCH_URL/_security/settings\"" - }, - { - "language": "Java", - "code": "client.security().updateSettings(u -> u\n .security(s -> s)\n .securityProfile(s -> s)\n .securityTokens(s -> s)\n);\n" - } - ], - "specification/security/get_user_profile/examples/request/GetUserProfileRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"" - }, - { - "language": "Java", - "code": "client.security().getUserProfile(g -> g\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" - } - ], - "specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.create_api_key(\n name=\"my-api-key\",\n expiration=\"1d\",\n role_descriptors={\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n metadata={\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.createApiKey({\n name: \"my-api-key\",\n expiration: \"1d\",\n role_descriptors: {\n \"role-a\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-a*\"],\n privileges: [\"read\"],\n },\n ],\n },\n \"role-b\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-b*\"],\n privileges: [\"all\"],\n },\n ],\n },\n },\n metadata: {\n application: \"my-application\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.create_api_key(\n body: {\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->createApiKey([\n \"body\" => [\n \"name\" => \"my-api-key\",\n \"expiration\" => \"1d\",\n \"role_descriptors\" => [\n \"role-a\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-a*\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n ),\n ],\n \"role-b\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-b*\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"application\" => \"my-application\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-a*\"],\"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"privileges\":[\"all\"]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().createApiKey(c -> c\n .expiration(e -> e\n .time(\"1d\")\n )\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"application\", JsonData.fromJson(\"\\\"my-application\\\"\")))\n .name(\"my-api-key\")\n .roleDescriptors(Map.of(\"role-b\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-b*\")\n .privileges(\"all\")\n )),\"role-a\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-a*\")\n .privileges(\"read\")\n ))))\n);\n" - } - ], - "specification/security/get_privileges/examples/request/SecurityGetPrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_privileges(\n application=\"myapp\",\n name=\"read\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getPrivileges({\n application: \"myapp\",\n name: \"read\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_privileges(\n application: \"myapp\",\n name: \"read\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getPrivileges([\n \"application\" => \"myapp\",\n \"name\" => \"read\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/read\"" - }, - { - "language": "Java", - "code": "client.security().getPrivileges(g -> g\n .application(\"myapp\")\n .name(\"read\")\n);\n" - } - ], - "specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_cross_cluster_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n access={\n \"replication\": [\n {\n \"names\": [\n \"archive\"\n ]\n }\n ]\n },\n metadata={\n \"application\": \"replication\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateCrossClusterApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n access: {\n replication: [\n {\n names: [\"archive\"],\n },\n ],\n },\n metadata: {\n application: \"replication\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_cross_cluster_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"access\": {\n \"replication\": [\n {\n \"names\": [\n \"archive\"\n ]\n }\n ]\n },\n \"metadata\": {\n \"application\": \"replication\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateCrossClusterApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"access\" => [\n \"replication\" => array(\n [\n \"names\" => array(\n \"archive\",\n ),\n ],\n ),\n ],\n \"metadata\" => [\n \"application\" => \"replication\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"access\":{\"replication\":[{\"names\":[\"archive\"]}]},\"metadata\":{\"application\":\"replication\"}}' \"$ELASTICSEARCH_URL/_security/cross_cluster/api_key/VuaCfGcBCdbkQm-e5aOx\"" - }, - { - "language": "Java", - "code": "client.security().updateCrossClusterApiKey(u -> u\n .access(a -> a\n .replication(r -> r\n .names(\"archive\")\n )\n )\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n .metadata(\"application\", JsonData.fromJson(\"\\\"replication\\\"\"))\n);\n" - } - ], - "specification/security/get_settings/examples/request/SecurityGetSettingsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_settings()" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getSettings();" - }, - { - "language": "Ruby", - "code": "response = client.security.get_settings" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getSettings();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/settings\"" - }, - { - "language": "Java", - "code": "client.security().getSettings(g -> g);\n" - } - ], - "specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_builtin_privileges()" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getBuiltinPrivileges();" - }, - { - "language": "Ruby", - "code": "response = client.security.get_builtin_privileges" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getBuiltinPrivileges();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/_builtin\"" - }, - { - "language": "Java", - "code": "client.security().getBuiltinPrivileges();\n" - } - ], - "specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.has_privileges_user_profile(\n uids=[\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\"\n ],\n privileges={\n \"cluster\": [\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"create_doc\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.hasPrivilegesUserProfile({\n uids: [\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\",\n ],\n privileges: {\n cluster: [\"monitor\", \"create_snapshot\", \"manage_ml\"],\n index: [\n {\n names: [\"suppliers\", \"products\"],\n privileges: [\"create_doc\"],\n },\n {\n names: [\"inventory\"],\n privileges: [\"read\", \"write\"],\n },\n ],\n application: [\n {\n application: \"inventory_manager\",\n privileges: [\"read\", \"data:write/inventory\"],\n resources: [\"product/1852563\"],\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.has_privileges_user_profile(\n body: {\n \"uids\": [\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\"\n ],\n \"privileges\": {\n \"cluster\": [\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"create_doc\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->hasPrivilegesUserProfile([\n \"body\" => [\n \"uids\" => array(\n \"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\n \"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\n \"u_does-not-exist_0\",\n ),\n \"privileges\" => [\n \"cluster\" => array(\n \"monitor\",\n \"create_snapshot\",\n \"manage_ml\",\n ),\n \"index\" => array(\n [\n \"names\" => array(\n \"suppliers\",\n \"products\",\n ),\n \"privileges\" => array(\n \"create_doc\",\n ),\n ],\n [\n \"names\" => array(\n \"inventory\",\n ),\n \"privileges\" => array(\n \"read\",\n \"write\",\n ),\n ],\n ),\n \"application\" => array(\n [\n \"application\" => \"inventory_manager\",\n \"privileges\" => array(\n \"read\",\n \"data:write/inventory\",\n ),\n \"resources\" => array(\n \"product/1852563\",\n ),\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"uids\":[\"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\"u_does-not-exist_0\"],\"privileges\":{\"cluster\":[\"monitor\",\"create_snapshot\",\"manage_ml\"],\"index\":[{\"names\":[\"suppliers\",\"products\"],\"privileges\":[\"create_doc\"]},{\"names\":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"application\":[{\"application\":\"inventory_manager\",\"privileges\":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/1852563\"]}]}}' \"$ELASTICSEARCH_URL/_security/profile/_has_privileges\"" - }, - { - "language": "Java", - "code": "client.security().hasPrivilegesUserProfile(h -> h\n .privileges(p -> p\n .application(a -> a\n .application(\"inventory_manager\")\n .privileges(List.of(\"read\",\"data:write/inventory\"))\n .resources(\"product/1852563\")\n )\n .cluster(List.of(\"monitor\",\"create_snapshot\",\"manage_ml\"))\n .index(List.of(IndexPrivilegesCheck.of(i -> i\n .names(List.of(\"suppliers\",\"products\"))\n .privileges(\"create_doc\")),IndexPrivilegesCheck.of(i -> i\n .names(\"inventory\")\n .privileges(List.of(\"read\",\"write\")))))\n )\n .uids(List.of(\"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0\",\"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1\",\"u_does-not-exist_0\"))\n);\n" - } - ], - "specification/security/clear_cached_roles/examples/request/SecurityClearCachedRolesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.clear_cached_roles(\n name=\"my_admin_role\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.clearCachedRoles({\n name: \"my_admin_role\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.clear_cached_roles(\n name: \"my_admin_role\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->clearCachedRoles([\n \"name\" => \"my_admin_role\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role/_clear_cache\"" - }, - { - "language": "Java", - "code": "client.security().clearCachedRoles(c -> c\n .name(\"my_admin_role\")\n);\n" - } - ], - "specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.authenticate()" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.authenticate();" - }, - { - "language": "Ruby", - "code": "response = client.security.authenticate" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->authenticate();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/_authenticate\"" - }, - { - "language": "Java", - "code": "client.security().authenticate();\n" - } - ], - "specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.activate_user_profile(\n grant_type=\"password\",\n username=\"jacknich\",\n password=\"l0ng-r4nd0m-p@ssw0rd\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.activateUserProfile({\n grant_type: \"password\",\n username: \"jacknich\",\n password: \"l0ng-r4nd0m-p@ssw0rd\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.activate_user_profile(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"jacknich\",\n \"password\": \"l0ng-r4nd0m-p@ssw0rd\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->activateUserProfile([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"jacknich\",\n \"password\" => \"l0ng-r4nd0m-p@ssw0rd\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"jacknich\",\"password\":\"l0ng-r4nd0m-p@ssw0rd\"}' \"$ELASTICSEARCH_URL/_security/profile/_activate\"" - }, - { - "language": "Java", - "code": "client.security().activateUserProfile(a -> a\n .grantType(GrantType.Password)\n .password(\"l0ng-r4nd0m-p@ssw0rd\")\n .username(\"jacknich\")\n);\n" - } - ], - "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.oidc_prepare_authentication(\n realm=\"oidc1\",\n state=\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n nonce=\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.oidcPrepareAuthentication({\n realm: \"oidc1\",\n state: \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n nonce: \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"realm\": \"oidc1\",\n \"state\": \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n \"nonce\": \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"oidc1\",\n \"state\" => \"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\n \"nonce\" => \"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"oidc1\",\"state\":\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\"nonce\":\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" - }, - { - "language": "Java", - "code": "client.security().oidcPrepareAuthentication(o -> o\n .nonce(\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5\")\n .realm(\"oidc1\")\n .state(\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\")\n);\n" - } - ], - "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.oidc_prepare_authentication(\n iss=\"http://127.0.0.1:8080\",\n login_hint=\"this_is_an_opaque_string\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.oidcPrepareAuthentication({\n iss: \"http://127.0.0.1:8080\",\n login_hint: \"this_is_an_opaque_string\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"iss\": \"http://127.0.0.1:8080\",\n \"login_hint\": \"this_is_an_opaque_string\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"iss\" => \"http://127.0.0.1:8080\",\n \"login_hint\" => \"this_is_an_opaque_string\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"iss\":\"http://127.0.0.1:8080\",\"login_hint\":\"this_is_an_opaque_string\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" - }, - { - "language": "Java", - "code": "client.security().oidcPrepareAuthentication(o -> o\n .iss(\"http://127.0.0.1:8080\")\n .loginHint(\"this_is_an_opaque_string\")\n);\n" - } - ], - "specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.oidc_prepare_authentication(\n realm=\"oidc1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.oidcPrepareAuthentication({\n realm: \"oidc1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.oidc_prepare_authentication(\n body: {\n \"realm\": \"oidc1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->oidcPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"oidc1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"oidc1\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" - }, - { - "language": "Java", - "code": "client.security().oidcPrepareAuthentication(o -> o\n .realm(\"oidc1\")\n);\n" - } - ], - "specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.has_privileges(\n cluster=[\n \"monitor\",\n \"manage\"\n ],\n index=[\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"read\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n application=[\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.hasPrivileges({\n cluster: [\"monitor\", \"manage\"],\n index: [\n {\n names: [\"suppliers\", \"products\"],\n privileges: [\"read\"],\n },\n {\n names: [\"inventory\"],\n privileges: [\"read\", \"write\"],\n },\n ],\n application: [\n {\n application: \"inventory_manager\",\n privileges: [\"read\", \"data:write/inventory\"],\n resources: [\"product/1852563\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.has_privileges(\n body: {\n \"cluster\": [\n \"monitor\",\n \"manage\"\n ],\n \"index\": [\n {\n \"names\": [\n \"suppliers\",\n \"products\"\n ],\n \"privileges\": [\n \"read\"\n ]\n },\n {\n \"names\": [\n \"inventory\"\n ],\n \"privileges\": [\n \"read\",\n \"write\"\n ]\n }\n ],\n \"application\": [\n {\n \"application\": \"inventory_manager\",\n \"privileges\": [\n \"read\",\n \"data:write/inventory\"\n ],\n \"resources\": [\n \"product/1852563\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->hasPrivileges([\n \"body\" => [\n \"cluster\" => array(\n \"monitor\",\n \"manage\",\n ),\n \"index\" => array(\n [\n \"names\" => array(\n \"suppliers\",\n \"products\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n [\n \"names\" => array(\n \"inventory\",\n ),\n \"privileges\" => array(\n \"read\",\n \"write\",\n ),\n ],\n ),\n \"application\" => array(\n [\n \"application\" => \"inventory_manager\",\n \"privileges\" => array(\n \"read\",\n \"data:write/inventory\",\n ),\n \"resources\" => array(\n \"product/1852563\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cluster\":[\"monitor\",\"manage\"],\"index\":[{\"names\":[\"suppliers\",\"products\"],\"privileges\":[\"read\"]},{\"names\":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"application\":[{\"application\":\"inventory_manager\",\"privileges\":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/1852563\"]}]}' \"$ELASTICSEARCH_URL/_security/user/_has_privileges\"" - }, - { - "language": "Java", - "code": "client.security().hasPrivileges(h -> h\n .application(a -> a\n .application(\"inventory_manager\")\n .privileges(List.of(\"read\",\"data:write/inventory\"))\n .resources(\"product/1852563\")\n )\n .cluster(List.of(\"monitor\",\"manage\"))\n .index(List.of(IndexPrivilegesCheck.of(i -> i\n .names(List.of(\"suppliers\",\"products\"))\n .privileges(\"read\")),IndexPrivilegesCheck.of(i -> i\n .names(\"inventory\")\n .privileges(List.of(\"read\",\"write\")))))\n);\n" - } - ], - "specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.oidc_logout(\n token=\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n refresh_token=\"vLBPvmAB6KvwvJZr27cS\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.oidcLogout({\n token:\n \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n refresh_token: \"vLBPvmAB6KvwvJZr27cS\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.oidc_logout(\n body: {\n \"token\": \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n \"refresh_token\": \"vLBPvmAB6KvwvJZr27cS\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->oidcLogout([\n \"body\" => [\n \"token\" => \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n \"refresh_token\" => \"vLBPvmAB6KvwvJZr27cS\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\"refresh_token\":\"vLBPvmAB6KvwvJZr27cS\"}' \"$ELASTICSEARCH_URL/_security/oidc/logout\"" - }, - { - "language": "Java", - "code": "client.security().oidcLogout(o -> o\n .refreshToken(\"vLBPvmAB6KvwvJZr27cS\")\n .token(\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\")\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\"]}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .ids(\"VuaCfGcBCdbkQm-e5aOx\")\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n username=\"myuser\",\n realm_name=\"native1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n username: \"myuser\",\n realm_name: \"native1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"username\": \"myuser\",\n \"realm_name\": \"native1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"username\" => \"myuser\",\n \"realm_name\" => \"native1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\",\"realm_name\":\"native1\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .realmName(\"native1\")\n .username(\"myuser\")\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n owner=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\"],\n owner: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ],\n \"owner\": \"true\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n \"owner\" => \"true\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\"],\"owner\":\"true\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .ids(\"VuaCfGcBCdbkQm-e5aOx\")\n .owner(true)\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n username=\"myuser\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n username: \"myuser\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"username\": \"myuser\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"username\" => \"myuser\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .username(\"myuser\")\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n realm_name=\"native1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n realm_name: \"native1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"realm_name\": \"native1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"realm_name\" => \"native1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm_name\":\"native1\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .realmName(\"native1\")\n);\n" - } - ], - "specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_api_key(\n name=\"my-api-key\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateApiKey({\n name: \"my-api-key\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_api_key(\n body: {\n \"name\": \"my-api-key\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateApiKey([\n \"body\" => [\n \"name\" => \"my-api-key\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-api-key\"}' \"$ELASTICSEARCH_URL/_security/api_key\"" - }, - { - "language": "Java", - "code": "client.security().invalidateApiKey(i -> i\n .name(\"my-api-key\")\n);\n" - } - ], - "specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.bulk_update_api_keys(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n role_descriptors={\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n metadata={\n \"environment\": {\n \"level\": 2,\n \"trusted\": True,\n \"tags\": [\n \"production\"\n ]\n }\n },\n expiration=\"30d\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.bulkUpdateApiKeys({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\", \"H3_AhoIBA9hmeQJdg7ij\"],\n role_descriptors: {\n \"role-a\": {\n indices: [\n {\n names: [\"*\"],\n privileges: [\"write\"],\n },\n ],\n },\n },\n metadata: {\n environment: {\n level: 2,\n trusted: true,\n tags: [\"production\"],\n },\n },\n expiration: \"30d\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.bulk_update_api_keys(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n \"role_descriptors\": {\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"environment\": {\n \"level\": 2,\n \"trusted\": true,\n \"tags\": [\n \"production\"\n ]\n }\n },\n \"expiration\": \"30d\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->bulkUpdateApiKeys([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\",\n ),\n \"role_descriptors\" => [\n \"role-a\" => [\n \"indices\" => array(\n [\n \"names\" => array(\n \"*\",\n ),\n \"privileges\" => array(\n \"write\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"environment\" => [\n \"level\" => 2,\n \"trusted\" => true,\n \"tags\" => array(\n \"production\",\n ),\n ],\n ],\n \"expiration\" => \"30d\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"],\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}},\"expiration\":\"30d\"}' \"$ELASTICSEARCH_URL/_security/api_key/_bulk_update\"" - }, - { - "language": "Java", - "code": "client.security().bulkUpdateApiKeys(b -> b\n .expiration(e -> e\n .time(\"30d\")\n )\n .ids(List.of(\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"))\n .metadata(\"environment\", JsonData.fromJson(\"{\\\"level\\\":2,\\\"trusted\\\":true,\\\"tags\\\":[\\\"production\\\"]}\"))\n .roleDescriptors(\"role-a\", r -> r\n .indices(i -> i\n .names(\"*\")\n .privileges(\"write\")\n )\n )\n);\n" - } - ], - "specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.bulk_update_api_keys(\n ids=[\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n role_descriptors={},\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.bulkUpdateApiKeys({\n ids: [\"VuaCfGcBCdbkQm-e5aOx\", \"H3_AhoIBA9hmeQJdg7ij\"],\n role_descriptors: {},\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.bulk_update_api_keys(\n body: {\n \"ids\": [\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\"\n ],\n \"role_descriptors\": {}\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->bulkUpdateApiKeys([\n \"body\" => [\n \"ids\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n \"H3_AhoIBA9hmeQJdg7ij\",\n ),\n \"role_descriptors\" => new ArrayObject([]),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"],\"role_descriptors\":{}}' \"$ELASTICSEARCH_URL/_security/api_key/_bulk_update\"" - }, - { - "language": "Java", - "code": "client.security().bulkUpdateApiKeys(b -> b\n .ids(List.of(\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"))\n);\n" - } - ], - "specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.suggest_user_profiles(\n name=\"jack\",\n hint={\n \"uids\": [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n ],\n \"labels\": {\n \"direction\": [\n \"north\",\n \"east\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.suggestUserProfiles({\n name: \"jack\",\n hint: {\n uids: [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n ],\n labels: {\n direction: [\"north\", \"east\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.suggest_user_profiles(\n body: {\n \"name\": \"jack\",\n \"hint\": {\n \"uids\": [\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n ],\n \"labels\": {\n \"direction\": [\n \"north\",\n \"east\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->suggestUserProfiles([\n \"body\" => [\n \"name\" => \"jack\",\n \"hint\" => [\n \"uids\" => array(\n \"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\n \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n ),\n \"labels\" => [\n \"direction\" => array(\n \"north\",\n \"east\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"jack\",\"hint\":{\"uids\":[\"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"],\"labels\":{\"direction\":[\"north\",\"east\"]}}}' \"$ELASTICSEARCH_URL/_security/profile/_suggest\"" - }, - { - "language": "Java", - "code": "client.security().suggestUserProfiles(s -> s\n .hint(h -> h\n .uids(List.of(\"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"))\n .labels(\"direction\", List.of(\"north\",\"east\"))\n )\n .name(\"jack\")\n);\n" - } - ], - "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_api_keys(\n query={\n \"term\": {\n \"name\": {\n \"value\": \"application-key-1\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryApiKeys({\n query: {\n term: {\n name: {\n value: \"application-key-1\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_api_keys(\n body: {\n \"query\": {\n \"term\": {\n \"name\": {\n \"value\": \"application-key-1\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryApiKeys([\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"name\" => [\n \"value\" => \"application-key-1\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"name\":{\"value\":\"application-key-1\"}}}}' \"$ELASTICSEARCH_URL/_security/_query/api_key\"" - }, - { - "language": "Java", - "code": "client.security().queryApiKeys(q -> q\n .query(qu -> qu\n .term(t -> t\n .field(\"name\")\n .value(FieldValue.of(\"application-key-1\"))\n )\n )\n);\n" - } - ], - "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_api_keys(\n query={\n \"bool\": {\n \"must\": [\n {\n \"prefix\": {\n \"name\": \"app1-key-\"\n }\n },\n {\n \"term\": {\n \"invalidated\": \"false\"\n }\n }\n ],\n \"must_not\": [\n {\n \"term\": {\n \"name\": \"app1-key-01\"\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"username\": \"org-*-user\"\n }\n },\n {\n \"term\": {\n \"metadata.environment\": \"production\"\n }\n }\n ]\n }\n },\n from=20,\n size=10,\n sort=[\n {\n \"creation\": {\n \"order\": \"desc\",\n \"format\": \"date_time\"\n }\n },\n \"name\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryApiKeys({\n query: {\n bool: {\n must: [\n {\n prefix: {\n name: \"app1-key-\",\n },\n },\n {\n term: {\n invalidated: \"false\",\n },\n },\n ],\n must_not: [\n {\n term: {\n name: \"app1-key-01\",\n },\n },\n ],\n filter: [\n {\n wildcard: {\n username: \"org-*-user\",\n },\n },\n {\n term: {\n \"metadata.environment\": \"production\",\n },\n },\n ],\n },\n },\n from: 20,\n size: 10,\n sort: [\n {\n creation: {\n order: \"desc\",\n format: \"date_time\",\n },\n },\n \"name\",\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_api_keys(\n body: {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"prefix\": {\n \"name\": \"app1-key-\"\n }\n },\n {\n \"term\": {\n \"invalidated\": \"false\"\n }\n }\n ],\n \"must_not\": [\n {\n \"term\": {\n \"name\": \"app1-key-01\"\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"username\": \"org-*-user\"\n }\n },\n {\n \"term\": {\n \"metadata.environment\": \"production\"\n }\n }\n ]\n }\n },\n \"from\": 20,\n \"size\": 10,\n \"sort\": [\n {\n \"creation\": {\n \"order\": \"desc\",\n \"format\": \"date_time\"\n }\n },\n \"name\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryApiKeys([\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"prefix\" => [\n \"name\" => \"app1-key-\",\n ],\n ],\n [\n \"term\" => [\n \"invalidated\" => \"false\",\n ],\n ],\n ),\n \"must_not\" => array(\n [\n \"term\" => [\n \"name\" => \"app1-key-01\",\n ],\n ],\n ),\n \"filter\" => array(\n [\n \"wildcard\" => [\n \"username\" => \"org-*-user\",\n ],\n ],\n [\n \"term\" => [\n \"metadata.environment\" => \"production\",\n ],\n ],\n ),\n ],\n ],\n \"from\" => 20,\n \"size\" => 10,\n \"sort\" => array(\n [\n \"creation\" => [\n \"order\" => \"desc\",\n \"format\" => \"date_time\",\n ],\n ],\n \"name\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"bool\":{\"must\":[{\"prefix\":{\"name\":\"app1-key-\"}},{\"term\":{\"invalidated\":\"false\"}}],\"must_not\":[{\"term\":{\"name\":\"app1-key-01\"}}],\"filter\":[{\"wildcard\":{\"username\":\"org-*-user\"}},{\"term\":{\"metadata.environment\":\"production\"}}]}},\"from\":20,\"size\":10,\"sort\":[{\"creation\":{\"order\":\"desc\",\"format\":\"date_time\"}},\"name\"]}' \"$ELASTICSEARCH_URL/_security/_query/api_key\"" - }, - { - "language": "Java", - "code": "client.security().queryApiKeys(q -> q\n .from(20)\n .query(qu -> qu\n .bool(b -> b\n .filter(List.of(Query.of(que -> que\n .wildcard(w -> w\n .field(\"username\")\n .value(\"org-*-user\")\n )),Query.of(quer -> quer\n .term(t -> t\n .field(\"metadata.environment\")\n .value(FieldValue.of(\"production\"))\n ))))\n .must(List.of(Query.of(query -> query\n .prefix(p -> p\n .field(\"name\")\n .value(\"app1-key-\")\n )),Query.of(query1 -> query1\n .term(t -> t\n .field(\"invalidated\")\n .value(FieldValue.of(\"false\"))\n ))))\n .mustNot(m -> m\n .term(t -> t\n .field(\"name\")\n .value(FieldValue.of(\"app1-key-01\"))\n )\n )\n )\n )\n .size(10)\n .sort(List.of(SortOptions.of(s -> s\n .field(f -> f\n .field(\"creation\")\n .order(SortOrder.Desc)\n .format(\"date_time\")\n )),SortOptions.of(so -> so\n .field(f -> f\n .field(\"name\")\n ))))\n);\n" - } - ], - "specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_api_keys(\n with_limited_by=True,\n query={\n \"ids\": {\n \"values\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryApiKeys({\n with_limited_by: \"true\",\n query: {\n ids: {\n values: [\"VuaCfGcBCdbkQm-e5aOx\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_api_keys(\n with_limited_by: \"true\",\n body: {\n \"query\": {\n \"ids\": {\n \"values\": [\n \"VuaCfGcBCdbkQm-e5aOx\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryApiKeys([\n \"with_limited_by\" => \"true\",\n \"body\" => [\n \"query\" => [\n \"ids\" => [\n \"values\" => array(\n \"VuaCfGcBCdbkQm-e5aOx\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"ids\":{\"values\":[\"VuaCfGcBCdbkQm-e5aOx\"]}}}' \"$ELASTICSEARCH_URL/_security/_query/api_key?with_limited_by=true\"" - }, - { - "language": "Java", - "code": "client.security().queryApiKeys(q -> q\n .query(qu -> qu\n .ids(i -> i\n .values(\"VuaCfGcBCdbkQm-e5aOx\")\n )\n )\n .withLimitedBy(true)\n);\n" - } - ], - "specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.create_cross_cluster_api_key(\n name=\"my-cross-cluster-api-key\",\n expiration=\"1d\",\n access={\n \"search\": [\n {\n \"names\": [\n \"logs*\"\n ]\n }\n ],\n \"replication\": [\n {\n \"names\": [\n \"archive*\"\n ]\n }\n ]\n },\n metadata={\n \"description\": \"phase one\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.createCrossClusterApiKey({\n name: \"my-cross-cluster-api-key\",\n expiration: \"1d\",\n access: {\n search: [\n {\n names: [\"logs*\"],\n },\n ],\n replication: [\n {\n names: [\"archive*\"],\n },\n ],\n },\n metadata: {\n description: \"phase one\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.create_cross_cluster_api_key(\n body: {\n \"name\": \"my-cross-cluster-api-key\",\n \"expiration\": \"1d\",\n \"access\": {\n \"search\": [\n {\n \"names\": [\n \"logs*\"\n ]\n }\n ],\n \"replication\": [\n {\n \"names\": [\n \"archive*\"\n ]\n }\n ]\n },\n \"metadata\": {\n \"description\": \"phase one\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->createCrossClusterApiKey([\n \"body\" => [\n \"name\" => \"my-cross-cluster-api-key\",\n \"expiration\" => \"1d\",\n \"access\" => [\n \"search\" => array(\n [\n \"names\" => array(\n \"logs*\",\n ),\n ],\n ),\n \"replication\" => array(\n [\n \"names\" => array(\n \"archive*\",\n ),\n ],\n ),\n ],\n \"metadata\" => [\n \"description\" => \"phase one\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"my-cross-cluster-api-key\",\"expiration\":\"1d\",\"access\":{\"search\":[{\"names\":[\"logs*\"]}],\"replication\":[{\"names\":[\"archive*\"]}]},\"metadata\":{\"description\":\"phase one\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/cross_cluster/api_key\"" - }, - { - "language": "Java", - "code": "client.security().createCrossClusterApiKey(c -> c\n .access(a -> a\n .replication(r -> r\n .names(\"archive*\")\n )\n .search(s -> s\n .names(\"logs*\")\n )\n )\n .expiration(e -> e\n .time(\"1d\")\n )\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"description\", JsonData.fromJson(\"\\\"phase one\\\"\")))\n .name(\"my-cross-cluster-api-key\")\n);\n" - } - ], - "specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_authenticate(\n content=\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n ids=[\n \"4fee3b046395c4e751011e97f8900b5273d56685\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlAuthenticate({\n content:\n \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n ids: [\"4fee3b046395c4e751011e97f8900b5273d56685\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_authenticate(\n body: {\n \"content\": \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n \"ids\": [\n \"4fee3b046395c4e751011e97f8900b5273d56685\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlAuthenticate([\n \"body\" => [\n \"content\" => \"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\n \"ids\" => array(\n \"4fee3b046395c4e751011e97f8900b5273d56685\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"content\":\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\"ids\":[\"4fee3b046395c4e751011e97f8900b5273d56685\"]}' \"$ELASTICSEARCH_URL/_security/saml/authenticate\"" - }, - { - "language": "Java", - "code": "client.security().samlAuthenticate(s -> s\n .content(\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\")\n .ids(\"4fee3b046395c4e751011e97f8900b5273d56685\")\n);\n" - } - ], - "specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.change_password(\n username=\"jacknich\",\n password=\"new-test-password\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.changePassword({\n username: \"jacknich\",\n password: \"new-test-password\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.change_password(\n username: \"jacknich\",\n body: {\n \"password\": \"new-test-password\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->changePassword([\n \"username\" => \"jacknich\",\n \"body\" => [\n \"password\" => \"new-test-password\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"password\":\"new-test-password\"}' \"$ELASTICSEARCH_URL/_security/user/jacknich/_password\"" - }, - { - "language": "Java", - "code": "client.security().changePassword(c -> c\n .password(\"new-test-password\")\n .username(\"jacknich\")\n);\n" - } - ], - "specification/security/get_service_credentials/examples/request/GetServiceCredentialsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_service_credentials(\n namespace=\"elastic\",\n service=\"fleet-server\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getServiceCredentials({\n namespace: \"elastic\",\n service: \"fleet-server\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_service_credentials(\n namespace: \"elastic\",\n service: \"fleet-server\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getServiceCredentials([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential\"" - }, - { - "language": "Java", - "code": "client.security().getServiceCredentials(g -> g\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" - } - ], - "specification/security/get_role_mapping/examples/request/SecurityGetRoleMappingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_role_mapping(\n name=\"mapping1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getRoleMapping({\n name: \"mapping1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_role_mapping(\n name: \"mapping1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getRoleMapping([\n \"name\" => \"mapping1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" - }, - { - "language": "Java", - "code": "client.security().getRoleMapping(g -> g\n .name(\"mapping1\")\n);\n" - } - ], - "specification/security/disable_user_profile/examples/request/SecurityDisableUserProfileExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.disable_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.disableUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.disable_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->disableUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0/_disable\"" - }, - { - "language": "Java", - "code": "client.security().disableUserProfile(d -> d\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" - } - ], - "specification/security/get_user_privileges/examples/request/SecurityGetUserPrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_user_privileges()" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getUserPrivileges();" - }, - { - "language": "Ruby", - "code": "response = client.security.get_user_privileges" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getUserPrivileges();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/_privileges\"" - }, - { - "language": "Java", - "code": "client.security().getUserPrivileges(g -> g);\n" - } - ], - "specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_role(\n query={\n \"match\": {\n \"description\": {\n \"query\": \"user access\"\n }\n }\n },\n size=1,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryRole({\n query: {\n match: {\n description: {\n query: \"user access\",\n },\n },\n },\n size: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_role(\n body: {\n \"query\": {\n \"match\": {\n \"description\": {\n \"query\": \"user access\"\n }\n }\n },\n \"size\": 1\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryRole([\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"description\" => [\n \"query\" => \"user access\",\n ],\n ],\n ],\n \"size\" => 1,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"description\":{\"query\":\"user access\"}}},\"size\":1}' \"$ELASTICSEARCH_URL/_security/_query/role\"" - }, - { - "language": "Java", - "code": "client.security().queryRole(q -> q\n .query(qu -> qu\n .match(m -> m\n .field(\"description\")\n .query(FieldValue.of(\"user access\"))\n )\n )\n .size(1)\n);\n" - } - ], - "specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_role(\n sort=[\n \"name\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryRole({\n sort: [\"name\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_role(\n body: {\n \"sort\": [\n \"name\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryRole([\n \"body\" => [\n \"sort\" => array(\n \"name\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":[\"name\"]}' \"$ELASTICSEARCH_URL/_security/_query/role\"" - }, - { - "language": "Java", - "code": "client.security().queryRole(q -> q\n .sort(s -> s\n .field(f -> f\n .field(\"name\")\n )\n )\n);\n" - } - ], - "specification/security/delete_privileges/examples/request/SecurityDeletePrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.delete_privileges(\n application=\"myapp\",\n name=\"read\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.deletePrivileges({\n application: \"myapp\",\n name: \"read\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.delete_privileges(\n application: \"myapp\",\n name: \"read\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->deletePrivileges([\n \"application\" => \"myapp\",\n \"name\" => \"read\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/read\"" - }, - { - "language": "Java", - "code": "client.security().deletePrivileges(d -> d\n .application(\"myapp\")\n .name(\"read\")\n);\n" - } - ], - "specification/security/clear_cached_privileges/examples/request/SecurityClearCachedPrivilegesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.clear_cached_privileges(\n application=\"myapp\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.clearCachedPrivileges({\n application: \"myapp\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.clear_cached_privileges(\n application: \"myapp\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->clearCachedPrivileges([\n \"application\" => \"myapp\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/privilege/myapp/_clear_cache\"" - }, - { - "language": "Java", - "code": "client.security().clearCachedPrivileges(c -> c\n .application(\"myapp\")\n);\n" - } - ], - "specification/security/create_service_token/examples/request/CreateServiceTokenRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.create_service_token(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.createServiceToken({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.create_service_token(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->createServiceToken([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token1\"" - }, - { - "language": "Java", - "code": "client.security().createServiceToken(c -> c\n .name(\"token1\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" - } - ], - "specification/security/delete_user/examples/request/SecurityDeleteUserRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.delete_user(\n username=\"jacknich\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.deleteUser({\n username: \"jacknich\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.delete_user(\n username: \"jacknich\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->deleteUser([\n \"username\" => \"jacknich\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich\"" - }, - { - "language": "Java", - "code": "client.security().deleteUser(d -> d\n .username(\"jacknich\")\n);\n" - } - ], - "specification/security/clear_cached_realms/examples/request/SecurityClearCachedRealmsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.clear_cached_realms(\n realms=\"default_file\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.clearCachedRealms({\n realms: \"default_file\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.clear_cached_realms(\n realms: \"default_file\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->clearCachedRealms([\n \"realms\" => \"default_file\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/realm/default_file/_clear_cache\"" - }, - { - "language": "Java", - "code": "client.security().clearCachedRealms(c -> c\n .realms(\"default_file\")\n);\n" - } - ], - "specification/security/get_user/examples/request/SecurityGetUserRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_user(\n username=\"jacknich\",\n with_profile_uid=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getUser({\n username: \"jacknich\",\n with_profile_uid: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_user(\n username: \"jacknich\",\n with_profile_uid: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getUser([\n \"username\" => \"jacknich\",\n \"with_profile_uid\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/jacknich?with_profile_uid=true\"" - }, - { - "language": "Java", - "code": "client.security().getUser(g -> g\n .username(\"jacknich\")\n .withProfileUid(true)\n);\n" - } - ], - "specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_user_profile_data(\n uid=\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n labels={\n \"direction\": \"east\"\n },\n data={\n \"app1\": {\n \"theme\": \"default\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateUserProfileData({\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n labels: {\n direction: \"east\",\n },\n data: {\n app1: {\n theme: \"default\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_user_profile_data(\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n body: {\n \"labels\": {\n \"direction\": \"east\"\n },\n \"data\": {\n \"app1\": {\n \"theme\": \"default\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateUserProfileData([\n \"uid\" => \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n \"body\" => [\n \"labels\" => [\n \"direction\" => \"east\",\n ],\n \"data\" => [\n \"app1\" => [\n \"theme\" => \"default\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"labels\":{\"direction\":\"east\"},\"data\":{\"app1\":{\"theme\":\"default\"}}}' \"$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data\"" - }, - { - "language": "Java", - "code": "client.security().updateUserProfileData(u -> u\n .data(\"app1\", JsonData.fromJson(\"{\\\"theme\\\":\\\"default\\\"}\"))\n .labels(\"direction\", JsonData.fromJson(\"\\\"east\\\"\"))\n .uid(\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\")\n);\n" - } - ], - "specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"POST\",\n \"/_security/delegate_pki\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"x509_certificate_chain\": [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"POST\",\n path: \"/_security/delegate_pki\",\n body: {\n x509_certificate_chain: [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\",\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"POST\",\n \"/_security/delegate_pki\",\n {},\n {\n \"x509_certificate_chain\": [\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"\n ]\n },\n { \"Content-Type\": \"application/json\" },\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"POST\",\n \"/_security/delegate_pki\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"x509_certificate_chain\" => array(\n \"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\",\n ),\n ]),\n));\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"x509_certificate_chain\":[\"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"]}' \"$ELASTICSEARCH_URL/_security/delegate_pki\"" - }, - { - "language": "Java", - "code": "client.security().delegatePki(d -> d\n .x509CertificateChain(\"MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\")\n);\n" - } - ], - "specification/security/enable_user/examples/request/SecurityEnableUserExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.enable_user(\n username=\"logstash_system\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.enableUser({\n username: \"logstash_system\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.enable_user(\n username: \"logstash_system\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->enableUser([\n \"username\" => \"logstash_system\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/user/logstash_system/_enable\"" - }, - { - "language": "Java", - "code": "client.security().enableUser(e -> e\n .username(\"logstash_system\")\n);\n" - } - ], - "specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_user(\n username=\"jacknich\",\n password=\"l0ng-r4nd0m-p@ssw0rd\",\n roles=[\n \"admin\",\n \"other_role1\"\n ],\n full_name=\"Jack Nicholson\",\n email=\"jacknich@example.com\",\n metadata={\n \"intelligence\": 7\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putUser({\n username: \"jacknich\",\n password: \"l0ng-r4nd0m-p@ssw0rd\",\n roles: [\"admin\", \"other_role1\"],\n full_name: \"Jack Nicholson\",\n email: \"jacknich@example.com\",\n metadata: {\n intelligence: 7,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_user(\n username: \"jacknich\",\n body: {\n \"password\": \"l0ng-r4nd0m-p@ssw0rd\",\n \"roles\": [\n \"admin\",\n \"other_role1\"\n ],\n \"full_name\": \"Jack Nicholson\",\n \"email\": \"jacknich@example.com\",\n \"metadata\": {\n \"intelligence\": 7\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putUser([\n \"username\" => \"jacknich\",\n \"body\" => [\n \"password\" => \"l0ng-r4nd0m-p@ssw0rd\",\n \"roles\" => array(\n \"admin\",\n \"other_role1\",\n ),\n \"full_name\" => \"Jack Nicholson\",\n \"email\" => \"jacknich@example.com\",\n \"metadata\" => [\n \"intelligence\" => 7,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"password\":\"l0ng-r4nd0m-p@ssw0rd\",\"roles\":[\"admin\",\"other_role1\"],\"full_name\":\"Jack Nicholson\",\"email\":\"jacknich@example.com\",\"metadata\":{\"intelligence\":7}}' \"$ELASTICSEARCH_URL/_security/user/jacknich\"" - }, - { - "language": "Java", - "code": "client.security().putUser(p -> p\n .email(\"jacknich@example.com\")\n .fullName(\"Jack Nicholson\")\n .metadata(\"intelligence\", JsonData.fromJson(\"7\"))\n .password(\"l0ng-r4nd0m-p@ssw0rd\")\n .roles(List.of(\"admin\",\"other_role1\"))\n .username(\"jacknich\")\n);\n" - } - ], - "specification/security/clear_api_key_cache/examples/request/SecurityClearApiKeyCacheExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.clear_api_key_cache(\n ids=\"yVGMr3QByxdh1MSaicYx\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.clearApiKeyCache({\n ids: \"yVGMr3QByxdh1MSaicYx\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.clear_api_key_cache(\n ids: \"yVGMr3QByxdh1MSaicYx\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->clearApiKeyCache([\n \"ids\" => \"yVGMr3QByxdh1MSaicYx\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/api_key/yVGMr3QByxdh1MSaicYx/_clear_cache\"" - }, - { - "language": "Java", - "code": "client.security().clearApiKeyCache(c -> c\n .ids(\"yVGMr3QByxdh1MSaicYx\")\n);\n" - } - ], - "specification/security/get_api_key/examples/request/SecurityGetApiKeyRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_api_key(\n username=\"myuser\",\n realm_name=\"native1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getApiKey({\n username: \"myuser\",\n realm_name: \"native1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_api_key(\n username: \"myuser\",\n realm_name: \"native1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getApiKey([\n \"username\" => \"myuser\",\n \"realm_name\" => \"native1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/api_key?username=myuser&realm_name=native1\"" - }, - { - "language": "Java", - "code": "client.security().getApiKey(g -> g\n .realmName(\"native1\")\n .username(\"myuser\")\n);\n" - } - ], - "specification/security/clear_cached_service_tokens/examples/request/SecurityClearCachedServiceTokensExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.clear_cached_service_tokens(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.clearCachedServiceTokens({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.clear_cached_service_tokens(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->clearCachedServiceTokens([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token1/_clear_cache\"" - }, - { - "language": "Java", - "code": "client.security().clearCachedServiceTokens(c -> c\n .name(\"token1\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" - } - ], - "specification/security/enable_user_profile/examples/request/SecurityEnableUserProfileExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.enable_user_profile(\n uid=\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.enableUserProfile({\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.enable_user_profile(\n uid: \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->enableUserProfile([\n \"uid\" => \"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0/_enable\"" - }, - { - "language": "Java", - "code": "client.security().enableUserProfile(e -> e\n .uid(\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0\")\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping7\",\n roles=[\n \"ldap-example-user\"\n ],\n enabled=True,\n rules={\n \"all\": [\n {\n \"field\": {\n \"dn\": \"*,ou=subtree,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping7\",\n roles: [\"ldap-example-user\"],\n enabled: true,\n rules: {\n all: [\n {\n field: {\n dn: \"*,ou=subtree,dc=example,dc=com\",\n },\n },\n {\n field: {\n \"realm.name\": \"ldap1\",\n },\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping7\",\n body: {\n \"roles\": [\n \"ldap-example-user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"all\": [\n {\n \"field\": {\n \"dn\": \"*,ou=subtree,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping7\",\n \"body\" => [\n \"roles\" => array(\n \"ldap-example-user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"all\" => array(\n [\n \"field\" => [\n \"dn\" => \"*,ou=subtree,dc=example,dc=com\",\n ],\n ],\n [\n \"field\" => [\n \"realm.name\" => \"ldap1\",\n ],\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"ldap-example-user\"],\"enabled\":true,\"rules\":{\"all\":[{\"field\":{\"dn\":\"*,ou=subtree,dc=example,dc=com\"}},{\"field\":{\"realm.name\":\"ldap1\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping7\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping7\")\n .roles(\"ldap-example-user\")\n .rules(r -> r\n .all(List.of(RoleMappingRule.of(ro -> ro\n .field(NamedValue.of(\"dn\",List.of(FieldValue.of(\"*,ou=subtree,dc=example,dc=com\"))\n ))), RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"ldap1\"))\n )))\n )\n )\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping6\",\n role_templates=[\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n rules={\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n enabled=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping6\",\n role_templates: [\n {\n template: {\n source: \"{{#tojson}}groups{{/tojson}}\",\n },\n format: \"json\",\n },\n ],\n rules: {\n field: {\n \"realm.name\": \"saml1\",\n },\n },\n enabled: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping6\",\n body: {\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n \"rules\": {\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n \"enabled\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping6\",\n \"body\" => [\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"{{#tojson}}groups{{/tojson}}\",\n ],\n \"format\" => \"json\",\n ],\n ),\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"saml1\",\n ],\n ],\n \"enabled\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping6\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping6\")\n .roleTemplates(r -> r\n .format(TemplateFormat.Json)\n .template(t -> t\n .source(s -> s\n .scriptString(\"{{#tojson}}groups{{/tojson}}\")\n )\n )\n )\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"saml1\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping1\",\n roles=[\n \"user\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"username\": \"*\"\n }\n },\n metadata={\n \"version\": 1\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping1\",\n roles: [\"user\"],\n enabled: true,\n rules: {\n field: {\n username: \"*\",\n },\n },\n metadata: {\n version: 1,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping1\",\n body: {\n \"roles\": [\n \"user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"username\": \"*\"\n }\n },\n \"metadata\": {\n \"version\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping1\",\n \"body\" => [\n \"roles\" => array(\n \"user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"username\" => \"*\",\n ],\n ],\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"user\"],\"enabled\":true,\"rules\":{\"field\":{\"username\":\"*\"}},\"metadata\":{\"version\":1}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .name(\"mapping1\")\n .roles(\"user\")\n .rules(r -> r\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"*\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping3\",\n roles=[\n \"ldap-user\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping3\",\n roles: [\"ldap-user\"],\n enabled: true,\n rules: {\n field: {\n \"realm.name\": \"ldap1\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping3\",\n body: {\n \"roles\": [\n \"ldap-user\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"realm.name\": \"ldap1\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping3\",\n \"body\" => [\n \"roles\" => array(\n \"ldap-user\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"ldap1\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"ldap-user\"],\"enabled\":true,\"rules\":{\"field\":{\"realm.name\":\"ldap1\"}}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping3\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping3\")\n .roles(\"ldap-user\")\n .rules(r -> r\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"ldap1\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping2\",\n roles=[\n \"user\",\n \"admin\"\n ],\n enabled=True,\n rules={\n \"field\": {\n \"username\": [\n \"esadmin01\",\n \"esadmin02\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping2\",\n roles: [\"user\", \"admin\"],\n enabled: true,\n rules: {\n field: {\n username: [\"esadmin01\", \"esadmin02\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping2\",\n body: {\n \"roles\": [\n \"user\",\n \"admin\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"field\": {\n \"username\": [\n \"esadmin01\",\n \"esadmin02\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping2\",\n \"body\" => [\n \"roles\" => array(\n \"user\",\n \"admin\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"field\" => [\n \"username\" => array(\n \"esadmin01\",\n \"esadmin02\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"user\",\"admin\"],\"enabled\":true,\"rules\":{\"field\":{\"username\":[\"esadmin01\",\"esadmin02\"]}}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping2\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping2\")\n .roles(List.of(\"user\",\"admin\"))\n .rules(r -> r\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"esadmin01\"),FieldValue.of(\"esadmin02\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping9\",\n rules={\n \"field\": {\n \"realm.name\": \"cloud-saml\"\n }\n },\n role_templates=[\n {\n \"template\": {\n \"source\": \"saml_user\"\n }\n },\n {\n \"template\": {\n \"source\": \"_user_{{username}}\"\n }\n }\n ],\n enabled=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping9\",\n rules: {\n field: {\n \"realm.name\": \"cloud-saml\",\n },\n },\n role_templates: [\n {\n template: {\n source: \"saml_user\",\n },\n },\n {\n template: {\n source: \"_user_{{username}}\",\n },\n },\n ],\n enabled: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping9\",\n body: {\n \"rules\": {\n \"field\": {\n \"realm.name\": \"cloud-saml\"\n }\n },\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"saml_user\"\n }\n },\n {\n \"template\": {\n \"source\": \"_user_{{username}}\"\n }\n }\n ],\n \"enabled\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping9\",\n \"body\" => [\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"cloud-saml\",\n ],\n ],\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"saml_user\",\n ],\n ],\n [\n \"template\" => [\n \"source\" => \"_user_{{username}}\",\n ],\n ],\n ),\n \"enabled\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":{\"field\":{\"realm.name\":\"cloud-saml\"}},\"role_templates\":[{\"template\":{\"source\":\"saml_user\"}},{\"template\":{\"source\":\"_user_{{username}}\"}}],\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping9\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping9\")\n .roleTemplates(List.of(RoleTemplate.of(r -> r\n .template(t -> t\n .source(s -> s\n .scriptString(\"saml_user\")\n )\n )),RoleTemplate.of(ro -> ro\n .template(t -> t\n .source(s -> s\n .scriptString(\"_user_{{username}}\")\n )\n ))))\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"cloud-saml\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping5\",\n role_templates=[\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n rules={\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n enabled=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping5\",\n role_templates: [\n {\n template: {\n source: \"{{#tojson}}groups{{/tojson}}\",\n },\n format: \"json\",\n },\n ],\n rules: {\n field: {\n \"realm.name\": \"saml1\",\n },\n },\n enabled: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping5\",\n body: {\n \"role_templates\": [\n {\n \"template\": {\n \"source\": \"{{#tojson}}groups{{/tojson}}\"\n },\n \"format\": \"json\"\n }\n ],\n \"rules\": {\n \"field\": {\n \"realm.name\": \"saml1\"\n }\n },\n \"enabled\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping5\",\n \"body\" => [\n \"role_templates\" => array(\n [\n \"template\" => [\n \"source\" => \"{{#tojson}}groups{{/tojson}}\",\n ],\n \"format\" => \"json\",\n ],\n ),\n \"rules\" => [\n \"field\" => [\n \"realm.name\" => \"saml1\",\n ],\n ],\n \"enabled\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping5\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping5\")\n .roleTemplates(r -> r\n .format(TemplateFormat.Json)\n .template(t -> t\n .source(s -> s\n .scriptString(\"{{#tojson}}groups{{/tojson}}\")\n )\n )\n )\n .rules(ru -> ru\n .field(NamedValue.of(\"realm.name\",List.of(FieldValue.of(\"saml1\"))))\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping4\",\n roles=[\n \"superuser\"\n ],\n enabled=True,\n rules={\n \"any\": [\n {\n \"field\": {\n \"username\": \"esadmin\"\n }\n },\n {\n \"field\": {\n \"groups\": \"cn=admins,dc=example,dc=com\"\n }\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping4\",\n roles: [\"superuser\"],\n enabled: true,\n rules: {\n any: [\n {\n field: {\n username: \"esadmin\",\n },\n },\n {\n field: {\n groups: \"cn=admins,dc=example,dc=com\",\n },\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping4\",\n body: {\n \"roles\": [\n \"superuser\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"any\": [\n {\n \"field\": {\n \"username\": \"esadmin\"\n }\n },\n {\n \"field\": {\n \"groups\": \"cn=admins,dc=example,dc=com\"\n }\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping4\",\n \"body\" => [\n \"roles\" => array(\n \"superuser\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"any\" => array(\n [\n \"field\" => [\n \"username\" => \"esadmin\",\n ],\n ],\n [\n \"field\" => [\n \"groups\" => \"cn=admins,dc=example,dc=com\",\n ],\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"any\":[{\"field\":{\"username\":\"esadmin\"}},{\"field\":{\"groups\":\"cn=admins,dc=example,dc=com\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping4\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping4\")\n .roles(\"superuser\")\n .rules(r -> r\n .any(List.of(RoleMappingRule.of(ro -> ro\n .field(NamedValue.of(\"username\",List.of(FieldValue.of(\"esadmin\"))\n ))), RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"groups\",List.of(FieldValue.of(\"cn=admins,dc=example,dc=com\"))\n )))\n )\n )\n )\n);\n" - } - ], - "specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role_mapping(\n name=\"mapping8\",\n roles=[\n \"superuser\"\n ],\n enabled=True,\n rules={\n \"all\": [\n {\n \"any\": [\n {\n \"field\": {\n \"dn\": \"*,ou=admin,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"username\": [\n \"es-admin\",\n \"es-system\"\n ]\n }\n }\n ]\n },\n {\n \"field\": {\n \"groups\": \"cn=people,dc=example,dc=com\"\n }\n },\n {\n \"except\": {\n \"field\": {\n \"metadata.terminated_date\": None\n }\n }\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRoleMapping({\n name: \"mapping8\",\n roles: [\"superuser\"],\n enabled: true,\n rules: {\n all: [\n {\n any: [\n {\n field: {\n dn: \"*,ou=admin,dc=example,dc=com\",\n },\n },\n {\n field: {\n username: [\"es-admin\", \"es-system\"],\n },\n },\n ],\n },\n {\n field: {\n groups: \"cn=people,dc=example,dc=com\",\n },\n },\n {\n except: {\n field: {\n \"metadata.terminated_date\": null,\n },\n },\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role_mapping(\n name: \"mapping8\",\n body: {\n \"roles\": [\n \"superuser\"\n ],\n \"enabled\": true,\n \"rules\": {\n \"all\": [\n {\n \"any\": [\n {\n \"field\": {\n \"dn\": \"*,ou=admin,dc=example,dc=com\"\n }\n },\n {\n \"field\": {\n \"username\": [\n \"es-admin\",\n \"es-system\"\n ]\n }\n }\n ]\n },\n {\n \"field\": {\n \"groups\": \"cn=people,dc=example,dc=com\"\n }\n },\n {\n \"except\": {\n \"field\": {\n \"metadata.terminated_date\": nil\n }\n }\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRoleMapping([\n \"name\" => \"mapping8\",\n \"body\" => [\n \"roles\" => array(\n \"superuser\",\n ),\n \"enabled\" => true,\n \"rules\" => [\n \"all\" => array(\n [\n \"any\" => array(\n [\n \"field\" => [\n \"dn\" => \"*,ou=admin,dc=example,dc=com\",\n ],\n ],\n [\n \"field\" => [\n \"username\" => array(\n \"es-admin\",\n \"es-system\",\n ),\n ],\n ],\n ),\n ],\n [\n \"field\" => [\n \"groups\" => \"cn=people,dc=example,dc=com\",\n ],\n ],\n [\n \"except\" => [\n \"field\" => [\n \"metadata.terminated_date\" => null,\n ],\n ],\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"all\":[{\"any\":[{\"field\":{\"dn\":\"*,ou=admin,dc=example,dc=com\"}},{\"field\":{\"username\":[\"es-admin\",\"es-system\"]}}]},{\"field\":{\"groups\":\"cn=people,dc=example,dc=com\"}},{\"except\":{\"field\":{\"metadata.terminated_date\":null}}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping8\"" - }, - { - "language": "Java", - "code": "client.security().putRoleMapping(p -> p\n .enabled(true)\n .name(\"mapping8\")\n .roles(\"superuser\")\n .rules(r -> r\n .all(List.of(RoleMappingRule.of(ro -> ro\n .any(List.of(RoleMappingRule.of(rol -> rol\n .field(NamedValue.of(\"dn\", List.of(FieldValue.of(\"*,ou=admin,\" +\n \"dc=example,dc=com\"))\n ))\n ), RoleMappingRule.of(role -> role\n .field(NamedValue.of(\"username\", List.of(FieldValue.of(\"es-admin\"),\n FieldValue.of(\"es-system\"))\n )))), RoleMappingRule.of(roleM -> roleM\n .field(NamedValue.of(\"groups\", List.of(FieldValue.of(\"cn=people,\" +\n \"dc=example,dc=com\"))\n )), RoleMappingRule.of(roleMa -> roleMa\n .except(e -> e\n .field(NamedValue.of(\"metadata.terminated_date\",\n List.of(FieldValue.of(null))\n )\n ))))\n )\n )\n )\n )\n )\n);\n" - } - ], - "specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_prepare_authentication(\n realm=\"saml1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlPrepareAuthentication({\n realm: \"saml1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_prepare_authentication(\n body: {\n \"realm\": \"saml1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlPrepareAuthentication([\n \"body\" => [\n \"realm\" => \"saml1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/saml/prepare\"" - }, - { - "language": "Java", - "code": "client.security().samlPrepareAuthentication(s -> s\n .realm(\"saml1\")\n);\n" - } - ], - "specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_prepare_authentication(\n acs=\"https://kibana.org/api/security/saml/callback\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlPrepareAuthentication({\n acs: \"https://kibana.org/api/security/saml/callback\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_prepare_authentication(\n body: {\n \"acs\": \"https://kibana.org/api/security/saml/callback\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlPrepareAuthentication([\n \"body\" => [\n \"acs\" => \"https://kibana.org/api/security/saml/callback\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"acs\":\"https://kibana.org/api/security/saml/callback\"}' \"$ELASTICSEARCH_URL/_security/saml/prepare\"" - }, - { - "language": "Java", - "code": "client.security().samlPrepareAuthentication(s -> s\n .acs(\"https://kibana.org/api/security/saml/callback\")\n);\n" - } - ], - "specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_invalidate(\n query_string=\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n realm=\"saml1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlInvalidate({\n query_string:\n \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n realm: \"saml1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_invalidate(\n body: {\n \"query_string\": \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n \"realm\": \"saml1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlInvalidate([\n \"body\" => [\n \"query_string\" => \"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\n \"realm\" => \"saml1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query_string\":\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\"realm\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/saml/invalidate\"" - }, - { - "language": "Java", - "code": "client.security().samlInvalidate(s -> s\n .queryString(\"SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\")\n .realm(\"saml1\")\n);\n" - } - ], - "specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_token(\n grant_type=\"client_credentials\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getToken({\n grant_type: \"client_credentials\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_token(\n body: {\n \"grant_type\": \"client_credentials\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getToken([\n \"body\" => [\n \"grant_type\" => \"client_credentials\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"client_credentials\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().getToken(g -> g\n .grantType(AccessTokenGrantType.ClientCredentials)\n);\n" - } - ], - "specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_token(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getToken({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_token(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getToken([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().getToken(g -> g\n .grantType(AccessTokenGrantType.Password)\n .password(\"x-pack-test-password\")\n .username(\"test_admin\")\n);\n" - } - ], - "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.bulk_put_role(\n roles={\n \"my_admin_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.bulkPutRole({\n roles: {\n my_admin_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n my_user_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\"],\n privileges: [\"read\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.bulk_put_role(\n body: {\n \"roles\": {\n \"my_admin_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->bulkPutRole([\n \"body\" => [\n \"roles\" => [\n \"my_admin_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n \"my_user_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":{\"my_admin_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}},\"my_user_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\"],\"privileges\":[\"read\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" - }, - { - "language": "Java", - "code": "client.security().bulkPutRole(b -> b\n .roles(Map.of(\"my_admin_role\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\")),\"my_user_role\", RoleDescriptor.of(ro -> ro\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(\"index1\")\n .privileges(\"read\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\"))))\n);\n" - } - ], - "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role(\n name=\"only_remote_access_role\",\n remote_indices=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n remote_cluster=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRole({\n name: \"only_remote_access_role\",\n remote_indices: [\n {\n clusters: [\"my_remote\"],\n names: [\"logs*\"],\n privileges: [\"read\", \"read_cross_cluster\", \"view_index_metadata\"],\n },\n ],\n remote_cluster: [\n {\n clusters: [\"my_remote\"],\n privileges: [\"monitor_stats\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role(\n name: \"only_remote_access_role\",\n body: {\n \"remote_indices\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n \"remote_cluster\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRole([\n \"name\" => \"only_remote_access_role\",\n \"body\" => [\n \"remote_indices\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"names\" => array(\n \"logs*\",\n ),\n \"privileges\" => array(\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\",\n ),\n ],\n ),\n \"remote_cluster\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"privileges\" => array(\n \"monitor_stats\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"view_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" - }, - { - "language": "Java", - "code": "client.security().putRole(p -> p\n .name(\"only_remote_access_role\")\n .remoteCluster(r -> r\n .clusters(\"my_remote\")\n .privileges(RemoteClusterPrivilege.MonitorStats)\n )\n .remoteIndices(r -> r\n .clusters(\"my_remote\")\n .names(\"logs*\")\n .privileges(List.of(\"read\",\"read_cross_cluster\",\"view_index_metadata\"))\n )\n);\n" - } - ], - "specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.bulk_put_role(\n roles={\n \"my_admin_role\": {\n \"cluster\": [\n \"bad_cluster_privilege\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.bulkPutRole({\n roles: {\n my_admin_role: {\n cluster: [\"bad_cluster_privilege\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n my_user_role: {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\"],\n privileges: [\"read\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.bulk_put_role(\n body: {\n \"roles\": {\n \"my_admin_role\": {\n \"cluster\": [\n \"bad_cluster_privilege\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n },\n \"my_user_role\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\"\n ],\n \"privileges\": [\n \"read\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->bulkPutRole([\n \"body\" => [\n \"roles\" => [\n \"my_admin_role\" => [\n \"cluster\" => array(\n \"bad_cluster_privilege\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n \"my_user_role\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":{\"my_admin_role\":{\"cluster\":[\"bad_cluster_privilege\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}},\"my_user_role\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\"],\"privileges\":[\"read\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" - }, - { - "language": "Java", - "code": "client.security().bulkPutRole(b -> b\n .roles(Map.of(\"my_admin_role\", RoleDescriptor.of(r -> r\n .cluster(\"bad_cluster_privilege\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\")),\"my_user_role\", RoleDescriptor.of(ro -> ro\n .cluster(\"all\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(\"index1\")\n .privileges(\"read\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .runAs(\"other_user\"))))\n);\n" - } - ], - "specification/security/get_role/examples/request/SecurityGetRoleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_role(\n name=\"my_admin_role\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getRole({\n name: \"my_admin_role\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_role(\n name: \"my_admin_role\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getRole([\n \"name\" => \"my_admin_role\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" - }, - { - "language": "Java", - "code": "client.security().getRole(g -> g\n .name(\"my_admin_role\")\n);\n" - } - ], - "specification/security/delete_role/examples/request/SecurityDeleteRoleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.delete_role(\n name=\"my_admin_role\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.deleteRole({\n name: \"my_admin_role\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.delete_role(\n name: \"my_admin_role\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->deleteRole([\n \"name\" => \"my_admin_role\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" - }, - { - "language": "Java", - "code": "client.security().deleteRole(d -> d\n .name(\"my_admin_role\")\n);\n" - } - ], - "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_token(\n username=\"myuser\",\n realm_name=\"saml1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateToken({\n username: \"myuser\",\n realm_name: \"saml1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_token(\n body: {\n \"username\": \"myuser\",\n \"realm_name\": \"saml1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"username\" => \"myuser\",\n \"realm_name\" => \"saml1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\",\"realm_name\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().invalidateToken(i -> i\n .realmName(\"saml1\")\n .username(\"myuser\")\n);\n" - } - ], - "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_token(\n username=\"myuser\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateToken({\n username: \"myuser\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_token(\n body: {\n \"username\": \"myuser\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"username\" => \"myuser\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"username\":\"myuser\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().invalidateToken(i -> i\n .username(\"myuser\")\n);\n" - } - ], - "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_token(\n realm_name=\"saml1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateToken({\n realm_name: \"saml1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_token(\n body: {\n \"realm_name\": \"saml1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"realm_name\" => \"saml1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm_name\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().invalidateToken(i -> i\n .realmName(\"saml1\")\n);\n" - } - ], - "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_token(\n refresh_token=\"vLBPvmAB6KvwvJZr27cS\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateToken({\n refresh_token: \"vLBPvmAB6KvwvJZr27cS\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_token(\n body: {\n \"refresh_token\": \"vLBPvmAB6KvwvJZr27cS\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"refresh_token\" => \"vLBPvmAB6KvwvJZr27cS\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"refresh_token\":\"vLBPvmAB6KvwvJZr27cS\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().invalidateToken(i -> i\n .refreshToken(\"vLBPvmAB6KvwvJZr27cS\")\n);\n" - } - ], - "specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.invalidate_token(\n token=\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.invalidateToken({\n token:\n \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.invalidate_token(\n body: {\n \"token\": \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->invalidateToken([\n \"body\" => [\n \"token\" => \"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\"}' \"$ELASTICSEARCH_URL/_security/oauth2/token\"" - }, - { - "language": "Java", - "code": "client.security().invalidateToken(i -> i\n .token(\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\")\n);\n" - } - ], - "specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_user(\n query={\n \"bool\": {\n \"must\": [\n {\n \"wildcard\": {\n \"email\": \"*example.com\"\n }\n },\n {\n \"term\": {\n \"enabled\": True\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"roles\": \"*other*\"\n }\n }\n ]\n }\n },\n from=1,\n size=2,\n sort=[\n {\n \"username\": {\n \"order\": \"desc\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryUser({\n query: {\n bool: {\n must: [\n {\n wildcard: {\n email: \"*example.com\",\n },\n },\n {\n term: {\n enabled: true,\n },\n },\n ],\n filter: [\n {\n wildcard: {\n roles: \"*other*\",\n },\n },\n ],\n },\n },\n from: 1,\n size: 2,\n sort: [\n {\n username: {\n order: \"desc\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_user(\n body: {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"wildcard\": {\n \"email\": \"*example.com\"\n }\n },\n {\n \"term\": {\n \"enabled\": true\n }\n }\n ],\n \"filter\": [\n {\n \"wildcard\": {\n \"roles\": \"*other*\"\n }\n }\n ]\n }\n },\n \"from\": 1,\n \"size\": 2,\n \"sort\": [\n {\n \"username\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryUser([\n \"body\" => [\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"wildcard\" => [\n \"email\" => \"*example.com\",\n ],\n ],\n [\n \"term\" => [\n \"enabled\" => true,\n ],\n ],\n ),\n \"filter\" => array(\n [\n \"wildcard\" => [\n \"roles\" => \"*other*\",\n ],\n ],\n ),\n ],\n ],\n \"from\" => 1,\n \"size\" => 2,\n \"sort\" => array(\n [\n \"username\" => [\n \"order\" => \"desc\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"bool\":{\"must\":[{\"wildcard\":{\"email\":\"*example.com\"}},{\"term\":{\"enabled\":true}}],\"filter\":[{\"wildcard\":{\"roles\":\"*other*\"}}]}},\"from\":1,\"size\":2,\"sort\":[{\"username\":{\"order\":\"desc\"}}]}' \"$ELASTICSEARCH_URL/_security/_query/user\"" - }, - { - "language": "Java", - "code": "client.security().queryUser(q -> q\n .from(1)\n .query(qu -> qu\n .bool(b -> b\n .filter(f -> f\n .wildcard(w -> w\n .field(\"roles\")\n .value(\"*other*\")\n )\n )\n .must(List.of(Query.of(que -> que\n .wildcard(w -> w\n .field(\"email\")\n .value(\"*example.com\")\n )),Query.of(quer -> quer\n .term(t -> t\n .field(\"enabled\")\n .value(FieldValue.of(true))\n ))))\n )\n )\n .size(2)\n .sort(s -> s\n .field(fi -> fi\n .field(\"username\")\n .order(SortOrder.Desc)\n )\n )\n);\n" - } - ], - "specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.query_user(\n with_profile_uid=True,\n query={\n \"prefix\": {\n \"roles\": \"other\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.queryUser({\n with_profile_uid: \"true\",\n query: {\n prefix: {\n roles: \"other\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.query_user(\n with_profile_uid: \"true\",\n body: {\n \"query\": {\n \"prefix\": {\n \"roles\": \"other\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->queryUser([\n \"with_profile_uid\" => \"true\",\n \"body\" => [\n \"query\" => [\n \"prefix\" => [\n \"roles\" => \"other\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"prefix\":{\"roles\":\"other\"}}}' \"$ELASTICSEARCH_URL/_security/_query/user?with_profile_uid=true\"" - }, - { - "language": "Java", - "code": "client.security().queryUser(q -> q\n .query(qu -> qu\n .prefix(p -> p\n .field(\"roles\")\n .value(\"other\")\n )\n )\n .withProfileUid(true)\n);\n" - } - ], - "specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_user_profile_data(\n uid=\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateUserProfileData({\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_user_profile_data(\n uid: \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateUserProfileData([\n \"uid\" => \"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data\"" - }, - { - "language": "Java", - "code": "client.security().updateUserProfileData(u -> u\n .uid(\"u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0\")\n);\n" - } - ], - "specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors={\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n metadata={\n \"environment\": {\n \"level\": 2,\n \"trusted\": True,\n \"tags\": [\n \"production\"\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors: {\n \"role-a\": {\n indices: [\n {\n names: [\"*\"],\n privileges: [\"write\"],\n },\n ],\n },\n },\n metadata: {\n environment: {\n level: 2,\n trusted: true,\n tags: [\"production\"],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"role_descriptors\": {\n \"role-a\": {\n \"indices\": [\n {\n \"names\": [\n \"*\"\n ],\n \"privileges\": [\n \"write\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"environment\": {\n \"level\": 2,\n \"trusted\": true,\n \"tags\": [\n \"production\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"role_descriptors\" => [\n \"role-a\" => [\n \"indices\" => array(\n [\n \"names\" => array(\n \"*\",\n ),\n \"privileges\" => array(\n \"write\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"environment\" => [\n \"level\" => 2,\n \"trusted\" => true,\n \"tags\" => array(\n \"production\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx\"" - }, - { - "language": "Java", - "code": "client.security().updateApiKey(u -> u\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n .metadata(\"environment\", JsonData.fromJson(\"{\\\"level\\\":2,\\\"trusted\\\":true,\\\"tags\\\":[\\\"production\\\"]}\"))\n .roleDescriptors(\"role-a\", r -> r\n .indices(i -> i\n .names(\"*\")\n .privileges(\"write\")\n )\n )\n);\n" - } - ], - "specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.update_api_key(\n id=\"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors={},\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.updateApiKey({\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n role_descriptors: {},\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.update_api_key(\n id: \"VuaCfGcBCdbkQm-e5aOx\",\n body: {\n \"role_descriptors\": {}\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->updateApiKey([\n \"id\" => \"VuaCfGcBCdbkQm-e5aOx\",\n \"body\" => [\n \"role_descriptors\" => new ArrayObject([]),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_descriptors\":{}}' \"$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx\"" - }, - { - "language": "Java", - "code": "client.security().updateApiKey(u -> u\n .id(\"VuaCfGcBCdbkQm-e5aOx\")\n);\n" - } - ], - "specification/security/delete_service_token/examples/request/DeleteServiceTokenRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.delete_service_token(\n namespace=\"elastic\",\n service=\"fleet-server\",\n name=\"token42\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.deleteServiceToken({\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token42\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.delete_service_token(\n namespace: \"elastic\",\n service: \"fleet-server\",\n name: \"token42\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->deleteServiceToken([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n \"name\" => \"token42\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token42\"" - }, - { - "language": "Java", - "code": "client.security().deleteServiceToken(d -> d\n .name(\"token42\")\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" - } - ], - "specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.saml_logout(\n token=\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n refresh_token=\"mJdXLtmvTUSpoLwMvdBt_w\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.samlLogout({\n token: \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n refresh_token: \"mJdXLtmvTUSpoLwMvdBt_w\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.saml_logout(\n body: {\n \"token\": \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n \"refresh_token\": \"mJdXLtmvTUSpoLwMvdBt_w\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->samlLogout([\n \"body\" => [\n \"token\" => \"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\n \"refresh_token\" => \"mJdXLtmvTUSpoLwMvdBt_w\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\",\"refresh_token\":\"mJdXLtmvTUSpoLwMvdBt_w\"}' \"$ELASTICSEARCH_URL/_security/saml/logout\"" - }, - { - "language": "Java", - "code": "client.security().samlLogout(s -> s\n .refreshToken(\"mJdXLtmvTUSpoLwMvdBt_w\")\n .token(\"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3\")\n);\n" - } - ], - "specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.oidc_authenticate(\n redirect_uri=\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n state=\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n nonce=\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n realm=\"oidc1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.oidcAuthenticate({\n redirect_uri:\n \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n state: \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n nonce: \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n realm: \"oidc1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.oidc_authenticate(\n body: {\n \"redirect_uri\": \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"state\": \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"nonce\": \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n \"realm\": \"oidc1\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->oidcAuthenticate([\n \"body\" => [\n \"redirect_uri\" => \"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"state\" => \"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\n \"nonce\" => \"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\n \"realm\" => \"oidc1\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"redirect_uri\":\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"state\":\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"nonce\":\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\",\"realm\":\"oidc1\"}' \"$ELASTICSEARCH_URL/_security/oidc/authenticate\"" - }, - { - "language": "Java", - "code": "client.security().oidcAuthenticate(o -> o\n .nonce(\"WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM\")\n .realm(\"oidc1\")\n .redirectUri(\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\")\n .state(\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\")\n);\n" - } - ], - "specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.grant_api_key(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n run_as=\"test_user\",\n api_key={\n \"name\": \"another-api-key\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.grantApiKey({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n run_as: \"test_user\",\n api_key: {\n name: \"another-api-key\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.grant_api_key(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\",\n \"run_as\": \"test_user\",\n \"api_key\": {\n \"name\": \"another-api-key\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->grantApiKey([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n \"run_as\" => \"test_user\",\n \"api_key\" => [\n \"name\" => \"another-api-key\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\",\"run_as\":\"test_user\",\"api_key\":{\"name\":\"another-api-key\"}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" - }, - { - "language": "Java", - "code": "client.security().grantApiKey(g -> g\n .apiKey(a -> a\n .name(\"another-api-key\")\n )\n .grantType(ApiKeyGrantType.Password)\n .password(\"x-pack-test-password\")\n .runAs(\"test_user\")\n .username(\"test_admin\")\n);\n" - } - ], - "specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.grant_api_key(\n grant_type=\"password\",\n username=\"test_admin\",\n password=\"x-pack-test-password\",\n api_key={\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": True,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.grantApiKey({\n grant_type: \"password\",\n username: \"test_admin\",\n password: \"x-pack-test-password\",\n api_key: {\n name: \"my-api-key\",\n expiration: \"1d\",\n role_descriptors: {\n \"role-a\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-a*\"],\n privileges: [\"read\"],\n },\n ],\n },\n \"role-b\": {\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index-b*\"],\n privileges: [\"all\"],\n },\n ],\n },\n },\n metadata: {\n application: \"my-application\",\n environment: {\n level: 1,\n trusted: true,\n tags: [\"dev\", \"staging\"],\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.grant_api_key(\n body: {\n \"grant_type\": \"password\",\n \"username\": \"test_admin\",\n \"password\": \"x-pack-test-password\",\n \"api_key\": {\n \"name\": \"my-api-key\",\n \"expiration\": \"1d\",\n \"role_descriptors\": {\n \"role-a\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-a*\"\n ],\n \"privileges\": [\n \"read\"\n ]\n }\n ]\n },\n \"role-b\": {\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index-b*\"\n ],\n \"privileges\": [\n \"all\"\n ]\n }\n ]\n }\n },\n \"metadata\": {\n \"application\": \"my-application\",\n \"environment\": {\n \"level\": 1,\n \"trusted\": true,\n \"tags\": [\n \"dev\",\n \"staging\"\n ]\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->grantApiKey([\n \"body\" => [\n \"grant_type\" => \"password\",\n \"username\" => \"test_admin\",\n \"password\" => \"x-pack-test-password\",\n \"api_key\" => [\n \"name\" => \"my-api-key\",\n \"expiration\" => \"1d\",\n \"role_descriptors\" => [\n \"role-a\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-a*\",\n ),\n \"privileges\" => array(\n \"read\",\n ),\n ],\n ),\n ],\n \"role-b\" => [\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index-b*\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n ],\n ),\n ],\n ],\n \"metadata\" => [\n \"application\" => \"my-application\",\n \"environment\" => [\n \"level\" => 1,\n \"trusted\" => true,\n \"tags\" => array(\n \"dev\",\n \"staging\",\n ),\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\",\"api_key\":{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-a*\"],\"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"privileges\":[\"all\"]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" - }, - { - "language": "Java", - "code": "client.security().grantApiKey(g -> g\n .apiKey(a -> a\n .name(\"my-api-key\")\n .expiration(e -> e\n .time(\"1d\")\n )\n .roleDescriptors(Map.of(\"role-b\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-b*\")\n .privileges(\"all\")\n )),\"role-a\", RoleDescriptor.of(r -> r\n .cluster(\"all\")\n .indices(i -> i\n .names(\"index-a*\")\n .privileges(\"read\")\n ))))\n .metadata(Map.of(\"environment\", JsonData.fromJson(\"{\\\"level\\\":1,\\\"trusted\\\":true,\\\"tags\\\":[\\\"dev\\\",\\\"staging\\\"]}\"),\"application\", JsonData.fromJson(\"\\\"my-application\\\"\")))\n )\n .grantType(ApiKeyGrantType.Password)\n .password(\"x-pack-test-password\")\n .username(\"test_admin\")\n);\n" - } - ], - "specification/security/get_service_accounts/examples/request/GetServiceAccountsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.get_service_accounts(\n namespace=\"elastic\",\n service=\"fleet-server\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.getServiceAccounts({\n namespace: \"elastic\",\n service: \"fleet-server\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.get_service_accounts(\n namespace: \"elastic\",\n service: \"fleet-server\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->getServiceAccounts([\n \"namespace\" => \"elastic\",\n \"service\" => \"fleet-server\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/service/elastic/fleet-server\"" - }, - { - "language": "Java", - "code": "client.security().getServiceAccounts(g -> g\n .namespace(\"elastic\")\n .service(\"fleet-server\")\n);\n" - } - ], - "specification/security/delete_role_mapping/examples/request/SecurityDeleteRoleMappingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.delete_role_mapping(\n name=\"mapping1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.deleteRoleMapping({\n name: \"mapping1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.delete_role_mapping(\n name: \"mapping1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->deleteRoleMapping([\n \"name\" => \"mapping1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/role_mapping/mapping1\"" - }, - { - "language": "Java", - "code": "client.security().deleteRoleMapping(d -> d\n .name(\"mapping1\")\n);\n" - } - ], - "specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role(\n name=\"only_remote_access_role\",\n remote_indices=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n remote_cluster=[\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRole({\n name: \"only_remote_access_role\",\n remote_indices: [\n {\n clusters: [\"my_remote\"],\n names: [\"logs*\"],\n privileges: [\"read\", \"read_cross_cluster\", \"view_index_metadata\"],\n },\n ],\n remote_cluster: [\n {\n clusters: [\"my_remote\"],\n privileges: [\"monitor_stats\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role(\n name: \"only_remote_access_role\",\n body: {\n \"remote_indices\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"names\": [\n \"logs*\"\n ],\n \"privileges\": [\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\"\n ]\n }\n ],\n \"remote_cluster\": [\n {\n \"clusters\": [\n \"my_remote\"\n ],\n \"privileges\": [\n \"monitor_stats\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRole([\n \"name\" => \"only_remote_access_role\",\n \"body\" => [\n \"remote_indices\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"names\" => array(\n \"logs*\",\n ),\n \"privileges\" => array(\n \"read\",\n \"read_cross_cluster\",\n \"view_index_metadata\",\n ),\n ],\n ),\n \"remote_cluster\" => array(\n [\n \"clusters\" => array(\n \"my_remote\",\n ),\n \"privileges\" => array(\n \"monitor_stats\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"view_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" - }, - { - "language": "Java", - "code": "client.security().putRole(p -> p\n .name(\"only_remote_access_role\")\n .remoteCluster(r -> r\n .clusters(\"my_remote\")\n .privileges(RemoteClusterPrivilege.MonitorStats)\n )\n .remoteIndices(r -> r\n .clusters(\"my_remote\")\n .names(\"logs*\")\n .privileges(List.of(\"read\",\"read_cross_cluster\",\"view_index_metadata\"))\n )\n);\n" - } - ], - "specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role(\n name=\"cli_or_drivers_minimal\",\n cluster=[\n \"cluster:monitor/main\"\n ],\n indices=[\n {\n \"names\": [\n \"test\"\n ],\n \"privileges\": [\n \"read\",\n \"indices:admin/get\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRole({\n name: \"cli_or_drivers_minimal\",\n cluster: [\"cluster:monitor/main\"],\n indices: [\n {\n names: [\"test\"],\n privileges: [\"read\", \"indices:admin/get\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role(\n name: \"cli_or_drivers_minimal\",\n body: {\n \"cluster\": [\n \"cluster:monitor/main\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"test\"\n ],\n \"privileges\": [\n \"read\",\n \"indices:admin/get\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRole([\n \"name\" => \"cli_or_drivers_minimal\",\n \"body\" => [\n \"cluster\" => array(\n \"cluster:monitor/main\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"test\",\n ),\n \"privileges\" => array(\n \"read\",\n \"indices:admin/get\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cluster\":[\"cluster:monitor/main\"],\"indices\":[{\"names\":[\"test\"],\"privileges\":[\"read\",\"indices:admin/get\"]}]}' \"$ELASTICSEARCH_URL/_security/role/cli_or_drivers_minimal\"" - }, - { - "language": "Java", - "code": "client.security().putRole(p -> p\n .cluster(\"cluster:monitor/main\")\n .indices(i -> i\n .names(\"test\")\n .privileges(List.of(\"read\",\"indices:admin/get\"))\n )\n .name(\"cli_or_drivers_minimal\")\n);\n" - } - ], - "specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_role(\n name=\"my_admin_role\",\n description=\"Grants full access to all management features within the cluster.\",\n cluster=[\n \"all\"\n ],\n indices=[\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n applications=[\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n run_as=[\n \"other_user\"\n ],\n metadata={\n \"version\": 1\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putRole({\n name: \"my_admin_role\",\n description:\n \"Grants full access to all management features within the cluster.\",\n cluster: [\"all\"],\n indices: [\n {\n names: [\"index1\", \"index2\"],\n privileges: [\"all\"],\n field_security: {\n grant: [\"title\", \"body\"],\n },\n query: '{\"match\": {\"title\": \"foo\"}}',\n },\n ],\n applications: [\n {\n application: \"myapp\",\n privileges: [\"admin\", \"read\"],\n resources: [\"*\"],\n },\n ],\n run_as: [\"other_user\"],\n metadata: {\n version: 1,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_role(\n name: \"my_admin_role\",\n body: {\n \"description\": \"Grants full access to all management features within the cluster.\",\n \"cluster\": [\n \"all\"\n ],\n \"indices\": [\n {\n \"names\": [\n \"index1\",\n \"index2\"\n ],\n \"privileges\": [\n \"all\"\n ],\n \"field_security\": {\n \"grant\": [\n \"title\",\n \"body\"\n ]\n },\n \"query\": \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"\n }\n ],\n \"applications\": [\n {\n \"application\": \"myapp\",\n \"privileges\": [\n \"admin\",\n \"read\"\n ],\n \"resources\": [\n \"*\"\n ]\n }\n ],\n \"run_as\": [\n \"other_user\"\n ],\n \"metadata\": {\n \"version\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putRole([\n \"name\" => \"my_admin_role\",\n \"body\" => [\n \"description\" => \"Grants full access to all management features within the cluster.\",\n \"cluster\" => array(\n \"all\",\n ),\n \"indices\" => array(\n [\n \"names\" => array(\n \"index1\",\n \"index2\",\n ),\n \"privileges\" => array(\n \"all\",\n ),\n \"field_security\" => [\n \"grant\" => array(\n \"title\",\n \"body\",\n ),\n ],\n \"query\" => \"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\",\n ],\n ),\n \"applications\" => array(\n [\n \"application\" => \"myapp\",\n \"privileges\" => array(\n \"admin\",\n \"read\",\n ),\n \"resources\" => array(\n \"*\",\n ),\n ],\n ),\n \"run_as\" => array(\n \"other_user\",\n ),\n \"metadata\" => [\n \"version\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Grants full access to all management features within the cluster.\",\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index1\",\"index2\"],\"privileges\":[\"all\"],\"field_security\":{\"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}' \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" - }, - { - "language": "Java", - "code": "client.security().putRole(p -> p\n .applications(a -> a\n .application(\"myapp\")\n .privileges(List.of(\"admin\",\"read\"))\n .resources(\"*\")\n )\n .cluster(\"all\")\n .description(\"Grants full access to all management features within the cluster.\")\n .indices(i -> i\n .fieldSecurity(f -> f\n .grant(List.of(\"title\",\"body\"))\n )\n .names(List.of(\"index1\",\"index2\"))\n .privileges(\"all\")\n .query(q -> q\n .match(m -> m\n .field(\"title\")\n .query(FieldValue.of(\"foo\"))\n )\n )\n )\n .metadata(\"version\", JsonData.fromJson(\"1\"))\n .name(\"my_admin_role\")\n .runAs(\"other_user\")\n);\n" - } - ], - "specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.bulk_delete_role(\n names=[\n \"my_admin_role\",\n \"my_user_role\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.bulkDeleteRole({\n names: [\"my_admin_role\", \"my_user_role\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.bulk_delete_role(\n body: {\n \"names\": [\n \"my_admin_role\",\n \"my_user_role\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->bulkDeleteRole([\n \"body\" => [\n \"names\" => array(\n \"my_admin_role\",\n \"my_user_role\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"names\":[\"my_admin_role\",\"my_user_role\"]}' \"$ELASTICSEARCH_URL/_security/role\"" - }, - { - "language": "Java", - "code": "client.security().bulkDeleteRole(b -> b\n .names(List.of(\"my_admin_role\",\"my_user_role\"))\n);\n" - } - ], - "specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_privileges(\n privileges={\n \"myapp\": {\n \"read\": {\n \"actions\": [\n \"data:read/*\",\n \"action:login\"\n ],\n \"metadata\": {\n \"description\": \"Read access to myapp\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putPrivileges({\n privileges: {\n myapp: {\n read: {\n actions: [\"data:read/*\", \"action:login\"],\n metadata: {\n description: \"Read access to myapp\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_privileges(\n body: {\n \"myapp\": {\n \"read\": {\n \"actions\": [\n \"data:read/*\",\n \"action:login\"\n ],\n \"metadata\": {\n \"description\": \"Read access to myapp\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putPrivileges([\n \"body\" => [\n \"myapp\" => [\n \"read\" => [\n \"actions\" => array(\n \"data:read/*\",\n \"action:login\",\n ),\n \"metadata\" => [\n \"description\" => \"Read access to myapp\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"myapp\":{\"read\":{\"actions\":[\"data:read/*\",\"action:login\"],\"metadata\":{\"description\":\"Read access to myapp\"}}}}' \"$ELASTICSEARCH_URL/_security/privilege\"" - }, - { - "language": "Java", - "code": "client.security().putPrivileges(p -> p\n .privileges(\"myapp\", \"read\", pr -> pr\n .actions(List.of(\"data:read/*\",\"action:login\"))\n .metadata(\"description\", JsonData.fromJson(\"\\\"Read access to myapp\\\"\"))\n )\n);\n" - } - ], - "specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.security.put_privileges(\n privileges={\n \"app01\": {\n \"read\": {\n \"actions\": [\n \"action:login\",\n \"data:read/*\"\n ]\n },\n \"write\": {\n \"actions\": [\n \"action:login\",\n \"data:write/*\"\n ]\n }\n },\n \"app02\": {\n \"all\": {\n \"actions\": [\n \"*\"\n ]\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.putPrivileges({\n privileges: {\n app01: {\n read: {\n actions: [\"action:login\", \"data:read/*\"],\n },\n write: {\n actions: [\"action:login\", \"data:write/*\"],\n },\n },\n app02: {\n all: {\n actions: [\"*\"],\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.security.put_privileges(\n body: {\n \"app01\": {\n \"read\": {\n \"actions\": [\n \"action:login\",\n \"data:read/*\"\n ]\n },\n \"write\": {\n \"actions\": [\n \"action:login\",\n \"data:write/*\"\n ]\n }\n },\n \"app02\": {\n \"all\": {\n \"actions\": [\n \"*\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->putPrivileges([\n \"body\" => [\n \"app01\" => [\n \"read\" => [\n \"actions\" => array(\n \"action:login\",\n \"data:read/*\",\n ),\n ],\n \"write\" => [\n \"actions\" => array(\n \"action:login\",\n \"data:write/*\",\n ),\n ],\n ],\n \"app02\" => [\n \"all\" => [\n \"actions\" => array(\n \"*\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"app01\":{\"read\":{\"actions\":[\"action:login\",\"data:read/*\"]},\"write\":{\"actions\":[\"action:login\",\"data:write/*\"]}},\"app02\":{\"all\":{\"actions\":[\"*\"]}}}' \"$ELASTICSEARCH_URL/_security/privilege\"" - }, - { - "language": "Java", - "code": "client.security().putPrivileges(p -> p\n .privileges(Map.of(\"app02\", \"all\", pr -> pr\n .actions(\"*\"),\"app01\", Map.of(\"read\", Actions.of(a -> a\n .actions(List.of(\"action:login\",\"data:read/*\"))),\"write\", Actions.of(a -> a\n .actions(List.of(\"action:login\",\"data:write/*\"))))))\n);\n" - } - ], - "specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.security.enroll_kibana()" - }, - { - "language": "JavaScript", - "code": "const response = await client.security.enrollKibana();" - }, - { - "language": "Ruby", - "code": "response = client.security.enroll_kibana" - }, - { - "language": "PHP", - "code": "$resp = $client->security()->enrollKibana();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_security/enroll/kibana\"" - }, - { - "language": "Java", - "code": "client.security().enrollKibana();\n" - } - ], - "specification/nodes/usage/examples/request/NodesUsageExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.nodes.usage()" - }, - { - "language": "JavaScript", - "code": "const response = await client.nodes.usage();" - }, - { - "language": "Ruby", - "code": "response = client.nodes.usage" - }, - { - "language": "PHP", - "code": "$resp = $client->nodes()->usage();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/usage\"" - }, - { - "language": "Java", - "code": "client.nodes().usage(u -> u);\n" - } - ], - "specification/nodes/info/examples/request/NodesInfoExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.nodes.info(\n node_id=\"_all\",\n metric=\"jvm\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.nodes.info({\n node_id: \"_all\",\n metric: \"jvm\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.nodes.info(\n node_id: \"_all\",\n metric: \"jvm\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->nodes()->info([\n \"node_id\" => \"_all\",\n \"metric\" => \"jvm\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/_all/jvm\"" - }, - { - "language": "Java", - "code": "client.nodes().info(i -> i\n .metric(\"jvm\")\n .nodeId(\"_all\")\n);\n" - } - ], - "specification/nodes/hot_threads/examples/request/NodesHotThreadsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.nodes.hot_threads()" - }, - { - "language": "JavaScript", - "code": "const response = await client.nodes.hotThreads();" - }, - { - "language": "Ruby", - "code": "response = client.nodes.hot_threads" - }, - { - "language": "PHP", - "code": "$resp = $client->nodes()->hotThreads();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/hot_threads\"" - }, - { - "language": "Java", - "code": "client.nodes().hotThreads(h -> h);\n" - } - ], - "specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.nodes.reload_secure_settings(\n secure_settings_password=\"keystore-password\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.nodes.reloadSecureSettings({\n secure_settings_password: \"keystore-password\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.nodes.reload_secure_settings(\n body: {\n \"secure_settings_password\": \"keystore-password\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->nodes()->reloadSecureSettings([\n \"body\" => [\n \"secure_settings_password\" => \"keystore-password\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"secure_settings_password\":\"keystore-password\"}' \"$ELASTICSEARCH_URL/_nodes/reload_secure_settings\"" - }, - { - "language": "Java", - "code": "client.nodes().reloadSecureSettings(r -> r\n .secureSettingsPassword(\"keystore-password\")\n);\n" - } - ], - "specification/nodes/stats/examples/request/NodesStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.nodes.stats(\n metric=\"process\",\n filter_path=\"**.max_file_descriptors\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.nodes.stats({\n metric: \"process\",\n filter_path: \"**.max_file_descriptors\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.nodes.stats(\n metric: \"process\",\n filter_path: \"**.max_file_descriptors\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->nodes()->stats([\n \"metric\" => \"process\",\n \"filter_path\" => \"**.max_file_descriptors\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_nodes/stats/process?filter_path=**.max_file_descriptors\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/ingest/get_pipeline/examples/request/IngestGetPipelineExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.get_pipeline(\n id=\"my-pipeline-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.getPipeline({\n id: \"my-pipeline-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.get_pipeline(\n id: \"my-pipeline-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->getPipeline([\n \"id\" => \"my-pipeline-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" - }, - { - "language": "Java", - "code": "client.ingest().getPipeline(g -> g\n .id(\"my-pipeline-id\")\n);\n" - } - ], - "specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.put_pipeline(\n id=\"my-pipeline-id\",\n description=\"My optional pipeline description\",\n processors=[\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.putPipeline({\n id: \"my-pipeline-id\",\n description: \"My optional pipeline description\",\n processors: [\n {\n set: {\n description: \"My optional processor description\",\n field: \"my-keyword-field\",\n value: \"foo\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.put_pipeline(\n id: \"my-pipeline-id\",\n body: {\n \"description\": \"My optional pipeline description\",\n \"processors\": [\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->putPipeline([\n \"id\" => \"my-pipeline-id\",\n \"body\" => [\n \"description\" => \"My optional pipeline description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"description\" => \"My optional processor description\",\n \"field\" => \"my-keyword-field\",\n \"value\" => \"foo\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"My optional pipeline description\",\"processors\":[{\"set\":{\"description\":\"My optional processor description\",\"field\":\"my-keyword-field\",\"value\":\"foo\"}}]}' \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" - }, - { - "language": "Java", - "code": "client.ingest().putPipeline(p -> p\n .description(\"My optional pipeline description\")\n .id(\"my-pipeline-id\")\n .processors(pr -> pr\n .set(s -> s\n .field(\"my-keyword-field\")\n .value(JsonData.fromJson(\"\\\"foo\\\"\"))\n .description(\"My optional processor description\")\n )\n )\n);\n" - } - ], - "specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.put_pipeline(\n id=\"my-pipeline-id\",\n description=\"My optional pipeline description\",\n processors=[\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n meta={\n \"reason\": \"set my-keyword-field to foo\",\n \"serialization\": {\n \"class\": \"MyPipeline\",\n \"id\": 10\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.putPipeline({\n id: \"my-pipeline-id\",\n description: \"My optional pipeline description\",\n processors: [\n {\n set: {\n description: \"My optional processor description\",\n field: \"my-keyword-field\",\n value: \"foo\",\n },\n },\n ],\n meta: {\n reason: \"set my-keyword-field to foo\",\n serialization: {\n class: \"MyPipeline\",\n id: 10,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.put_pipeline(\n id: \"my-pipeline-id\",\n body: {\n \"description\": \"My optional pipeline description\",\n \"processors\": [\n {\n \"set\": {\n \"description\": \"My optional processor description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"foo\"\n }\n }\n ],\n \"_meta\": {\n \"reason\": \"set my-keyword-field to foo\",\n \"serialization\": {\n \"class\": \"MyPipeline\",\n \"id\": 10\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->putPipeline([\n \"id\" => \"my-pipeline-id\",\n \"body\" => [\n \"description\" => \"My optional pipeline description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"description\" => \"My optional processor description\",\n \"field\" => \"my-keyword-field\",\n \"value\" => \"foo\",\n ],\n ],\n ),\n \"_meta\" => [\n \"reason\" => \"set my-keyword-field to foo\",\n \"serialization\" => [\n \"class\" => \"MyPipeline\",\n \"id\" => 10,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"My optional pipeline description\",\"processors\":[{\"set\":{\"description\":\"My optional processor description\",\"field\":\"my-keyword-field\",\"value\":\"foo\"}}],\"_meta\":{\"reason\":\"set my-keyword-field to foo\",\"serialization\":{\"class\":\"MyPipeline\",\"id\":10}}}' \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" - }, - { - "language": "Java", - "code": "client.ingest().putPipeline(p -> p\n .meta(Map.of(\"serialization\", JsonData.fromJson(\"{\\\"class\\\":\\\"MyPipeline\\\",\\\"id\\\":10}\"),\"reason\", JsonData.fromJson(\"\\\"set my-keyword-field to foo\\\"\")))\n .description(\"My optional pipeline description\")\n .id(\"my-pipeline-id\")\n .processors(pr -> pr\n .set(s -> s\n .field(\"my-keyword-field\")\n .value(JsonData.fromJson(\"\\\"foo\\\"\"))\n .description(\"My optional processor description\")\n )\n )\n);\n" - } - ], - "specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.simulate(\n pipeline={\n \"description\": \"_description\",\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field2\",\n \"value\": \"_value\"\n }\n }\n ]\n },\n docs=[\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.simulate({\n pipeline: {\n description: \"_description\",\n processors: [\n {\n set: {\n field: \"field2\",\n value: \"_value\",\n },\n },\n ],\n },\n docs: [\n {\n _index: \"index\",\n _id: \"id\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _index: \"index\",\n _id: \"id\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.simulate(\n body: {\n \"pipeline\": {\n \"description\": \"_description\",\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field2\",\n \"value\": \"_value\"\n }\n }\n ]\n },\n \"docs\": [\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->simulate([\n \"body\" => [\n \"pipeline\" => [\n \"description\" => \"_description\",\n \"processors\" => array(\n [\n \"set\" => [\n \"field\" => \"field2\",\n \"value\" => \"_value\",\n ],\n ],\n ),\n ],\n \"docs\" => array(\n [\n \"_index\" => \"index\",\n \"_id\" => \"id\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_index\" => \"index\",\n \"_id\" => \"id\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"pipeline\":{\"description\":\"_description\",\"processors\":[{\"set\":{\"field\":\"field2\",\"value\":\"_value\"}}]},\"docs\":[{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/pipeline/_simulate\"" - }, - { - "language": "Java", - "code": "client.ingest().simulate(s -> s\n .docs(List.of(Document.of(d -> d\n .id(\"id\")\n .index(\"index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"id\")\n .index(\"index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .pipeline(p -> p\n .description(\"_description\")\n .processors(pr -> pr\n .set(se -> se\n .field(\"field2\")\n .value(JsonData.fromJson(\"\\\"_value\\\"\"))\n )\n )\n )\n);\n" - } - ], - "specification/ingest/delete_pipeline/examples/request/IngestDeletePipelineExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.delete_pipeline(\n id=\"my-pipeline-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.deletePipeline({\n id: \"my-pipeline-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.delete_pipeline(\n id: \"my-pipeline-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->deletePipeline([\n \"id\" => \"my-pipeline-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id\"" - }, - { - "language": "Java", - "code": "client.ingest().deletePipeline(d -> d\n .id(\"my-pipeline-id\")\n);\n" - } - ], - "specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.geo_ip_stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.geoIpStats();" - }, - { - "language": "Ruby", - "code": "response = client.ingest.geo_ip_stats" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->geoIpStats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/geoip/stats\"" - }, - { - "language": "Java", - "code": "client.ingest().geoIpStats();\n" - } - ], - "specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.put_ip_location_database(\n id=\"my-database-1\",\n configuration={\n \"name\": \"GeoIP2-Domain\",\n \"maxmind\": {\n \"account_id\": \"1234567\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.putIpLocationDatabase({\n id: \"my-database-1\",\n configuration: {\n name: \"GeoIP2-Domain\",\n maxmind: {\n account_id: \"1234567\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.put_ip_location_database(\n id: \"my-database-1\",\n body: {\n \"name\": \"GeoIP2-Domain\",\n \"maxmind\": {\n \"account_id\": \"1234567\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->putIpLocationDatabase([\n \"id\" => \"my-database-1\",\n \"body\" => [\n \"name\" => \"GeoIP2-Domain\",\n \"maxmind\" => [\n \"account_id\" => \"1234567\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"GeoIP2-Domain\",\"maxmind\":{\"account_id\":\"1234567\"}}' \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-1\"" - }, - { - "language": "Java", - "code": "client.ingest().putIpLocationDatabase(p -> p\n .id(\"my-database-1\")\n .configuration(c -> c\n .maxmind(m -> m\n .accountId(\"1234567\")\n )\n .name(\"GeoIP2-Domain\")\n )\n);\n" - } - ], - "specification/ingest/delete_ip_location_database/examples/request/IngestDeleteIpLocationDatabaseExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.delete_ip_location_database(\n id=\"my-database-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.deleteIpLocationDatabase({\n id: \"my-database-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.delete_ip_location_database(\n id: \"my-database-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->deleteIpLocationDatabase([\n \"id\" => \"my-database-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-id\"" - }, - { - "language": "Java", - "code": "client.ingest().deleteIpLocationDatabase(d -> d\n .id(\"my-database-id\")\n);\n" - } - ], - "specification/ingest/get_ip_location_database/examples/request/IngestGetIpLocationDatabaseExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.get_ip_location_database(\n id=\"my-database-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.getIpLocationDatabase({\n id: \"my-database-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ingest.get_ip_location_database(\n id: \"my-database-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->getIpLocationDatabase([\n \"id\" => \"my-database-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-id\"" - }, - { - "language": "Java", - "code": "client.ingest().getIpLocationDatabase(g -> g\n .id(\"my-database-id\")\n);\n" - } - ], - "specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ingest.processor_grok()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ingest.processorGrok();" - }, - { - "language": "Ruby", - "code": "response = client.ingest.processor_grok" - }, - { - "language": "PHP", - "code": "$resp = $client->ingest()->processorGrok();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ingest/processor/grok\"" - }, - { - "language": "Java", - "code": "client.ingest().processorGrok();\n" - } - ], - "specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n pipeline_substitutions={\n \"my-pipeline\": {\n \"processors\": [\n {\n \"uppercase\": {\n \"field\": \"foo\"\n }\n }\n ]\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _index: \"my-index\",\n _id: \"123\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _index: \"my-index\",\n _id: \"456\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n pipeline_substitutions: {\n \"my-pipeline\": {\n processors: [\n {\n uppercase: {\n field: \"foo\",\n },\n },\n ],\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n \"pipeline_substitutions\": {\n \"my-pipeline\": {\n \"processors\": [\n {\n \"uppercase\": {\n \"field\": \"foo\"\n }\n }\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"123\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"456\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n \"pipeline_substitutions\" => [\n \"my-pipeline\" => [\n \"processors\" => array(\n [\n \"uppercase\" => [\n \"field\" => \"foo\",\n ],\n ],\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index\",\"_id\":\"123\",\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"my-index\",\"_id\":\"456\",\"_source\":{\"foo\":\"rab\"}}],\"pipeline_substitutions\":{\"my-pipeline\":{\"processors\":[{\"uppercase\":{\"field\":\"foo\"}}]}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" - }, - { - "language": "Java", - "code": "client.simulate().ingest(i -> i\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .pipelineSubstitutions(\"my-pipeline\", p -> p\n .processors(pr -> pr\n .uppercase(u -> u\n .field(\"foo\")\n )\n )\n )\n);\n" - } - ], - "specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"foo\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"bar\": \"rab\"\n }\n }\n ],\n component_template_substitutions={\n \"my-mappings_template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n },\n \"bar\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _index: \"my-index\",\n _id: \"123\",\n _source: {\n foo: \"foo\",\n },\n },\n {\n _index: \"my-index\",\n _id: \"456\",\n _source: {\n bar: \"rab\",\n },\n },\n ],\n component_template_substitutions: {\n \"my-mappings_template\": {\n template: {\n mappings: {\n dynamic: \"strict\",\n properties: {\n foo: {\n type: \"keyword\",\n },\n bar: {\n type: \"keyword\",\n },\n },\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_index\": \"my-index\",\n \"_id\": \"123\",\n \"_source\": {\n \"foo\": \"foo\"\n }\n },\n {\n \"_index\": \"my-index\",\n \"_id\": \"456\",\n \"_source\": {\n \"bar\": \"rab\"\n }\n }\n ],\n \"component_template_substitutions\": {\n \"my-mappings_template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n },\n \"bar\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"123\",\n \"_source\" => [\n \"foo\" => \"foo\",\n ],\n ],\n [\n \"_index\" => \"my-index\",\n \"_id\" => \"456\",\n \"_source\" => [\n \"bar\" => \"rab\",\n ],\n ],\n ),\n \"component_template_substitutions\" => [\n \"my-mappings_template\" => [\n \"template\" => [\n \"mappings\" => [\n \"dynamic\" => \"strict\",\n \"properties\" => [\n \"foo\" => [\n \"type\" => \"keyword\",\n ],\n \"bar\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"my-index\",\"_id\":\"123\",\"_source\":{\"foo\":\"foo\"}},{\"_index\":\"my-index\",\"_id\":\"456\",\"_source\":{\"bar\":\"rab\"}}],\"component_template_substitutions\":{\"my-mappings_template\":{\"template\":{\"mappings\":{\"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyword\"},\"bar\":{\"type\":\"keyword\"}}}}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" - }, - { - "language": "Java", - "code": "client.simulate().ingest(i -> i\n .componentTemplateSubstitutions(\"my-mappings_template\", c -> c\n .template(t -> t\n .mappings(m -> m\n .dynamic(DynamicMapping.Strict)\n .properties(Map.of(\"bar\", Property.of(p -> p\n .keyword(k -> k\n )),\"foo\", Property.of(pr -> pr\n .keyword(k -> k\n ))))\n )\n )\n )\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"foo\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"bar\\\":\\\"rab\\\"}\")))))\n);\n" - } - ], - "specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n pipeline_substitutions={\n \"my-pipeline\": {\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field3\",\n \"value\": \"value3\"\n }\n }\n ]\n }\n },\n component_template_substitutions={\n \"my-component-template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": True,\n \"properties\": {\n \"field3\": {\n \"type\": \"keyword\"\n }\n }\n },\n \"settings\": {\n \"index\": {\n \"default_pipeline\": \"my-pipeline\"\n }\n }\n }\n }\n },\n index_template_substitutions={\n \"my-index-template\": {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"component_template_1\",\n \"component_template_2\"\n ]\n }\n },\n mapping_addition={\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _id: \"id\",\n _index: \"my-index\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _id: \"id\",\n _index: \"my-index\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n pipeline_substitutions: {\n \"my-pipeline\": {\n processors: [\n {\n set: {\n field: \"field3\",\n value: \"value3\",\n },\n },\n ],\n },\n },\n component_template_substitutions: {\n \"my-component-template\": {\n template: {\n mappings: {\n dynamic: true,\n properties: {\n field3: {\n type: \"keyword\",\n },\n },\n },\n settings: {\n index: {\n default_pipeline: \"my-pipeline\",\n },\n },\n },\n },\n },\n index_template_substitutions: {\n \"my-index-template\": {\n index_patterns: [\"my-index-*\"],\n composed_of: [\"component_template_1\", \"component_template_2\"],\n },\n },\n mapping_addition: {\n dynamic: \"strict\",\n properties: {\n foo: {\n type: \"keyword\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"id\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n \"pipeline_substitutions\": {\n \"my-pipeline\": {\n \"processors\": [\n {\n \"set\": {\n \"field\": \"field3\",\n \"value\": \"value3\"\n }\n }\n ]\n }\n },\n \"component_template_substitutions\": {\n \"my-component-template\": {\n \"template\": {\n \"mappings\": {\n \"dynamic\": true,\n \"properties\": {\n \"field3\": {\n \"type\": \"keyword\"\n }\n }\n },\n \"settings\": {\n \"index\": {\n \"default_pipeline\": \"my-pipeline\"\n }\n }\n }\n }\n },\n \"index_template_substitutions\": {\n \"my-index-template\": {\n \"index_patterns\": [\n \"my-index-*\"\n ],\n \"composed_of\": [\n \"component_template_1\",\n \"component_template_2\"\n ]\n }\n },\n \"mapping_addition\": {\n \"dynamic\": \"strict\",\n \"properties\": {\n \"foo\": {\n \"type\": \"keyword\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"id\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_id\" => \"id\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n \"pipeline_substitutions\" => [\n \"my-pipeline\" => [\n \"processors\" => array(\n [\n \"set\" => [\n \"field\" => \"field3\",\n \"value\" => \"value3\",\n ],\n ],\n ),\n ],\n ],\n \"component_template_substitutions\" => [\n \"my-component-template\" => [\n \"template\" => [\n \"mappings\" => [\n \"dynamic\" => true,\n \"properties\" => [\n \"field3\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n \"settings\" => [\n \"index\" => [\n \"default_pipeline\" => \"my-pipeline\",\n ],\n ],\n ],\n ],\n ],\n \"index_template_substitutions\" => [\n \"my-index-template\" => [\n \"index_patterns\" => array(\n \"my-index-*\",\n ),\n \"composed_of\" => array(\n \"component_template_1\",\n \"component_template_2\",\n ),\n ],\n ],\n \"mapping_addition\" => [\n \"dynamic\" => \"strict\",\n \"properties\" => [\n \"foo\" => [\n \"type\" => \"keyword\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"id\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"bar\"}},{\"_id\":\"id\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"rab\"}}],\"pipeline_substitutions\":{\"my-pipeline\":{\"processors\":[{\"set\":{\"field\":\"field3\",\"value\":\"value3\"}}]}},\"component_template_substitutions\":{\"my-component-template\":{\"template\":{\"mappings\":{\"dynamic\":true,\"properties\":{\"field3\":{\"type\":\"keyword\"}}},\"settings\":{\"index\":{\"default_pipeline\":\"my-pipeline\"}}}}},\"index_template_substitutions\":{\"my-index-template\":{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"component_template_1\",\"component_template_2\"]}},\"mapping_addition\":{\"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyword\"}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" - }, - { - "language": "Java", - "code": "client.simulate().ingest(i -> i\n .componentTemplateSubstitutions(\"my-component-template\", c -> c\n .template(t -> t\n .settings(\"index\", s -> s\n .defaultPipeline(\"my-pipeline\")\n )\n .mappings(m -> m\n .dynamic(DynamicMapping.True)\n .properties(\"field3\", p -> p\n .keyword(k -> k)\n )\n )\n )\n )\n .docs(List.of(Document.of(d -> d\n .id(\"id\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"id\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n .indexTemplateSubstitutions(\"my-index-template\", in -> in\n .indexPatterns(\"my-index-*\")\n .composedOf(List.of(\"component_template_1\",\"component_template_2\"))\n )\n .mappingAddition(m -> m\n .dynamic(DynamicMapping.Strict)\n .properties(\"foo\", p -> p\n .keyword(k -> k)\n )\n )\n .pipelineSubstitutions(\"my-pipeline\", p -> p\n .processors(pr -> pr\n .set(s -> s\n .field(\"field3\")\n .value(JsonData.fromJson(\"\\\"value3\\\"\"))\n )\n )\n )\n);\n" - } - ], - "specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.simulate.ingest(\n docs=[\n {\n \"_id\": \"123\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"456\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.simulate.ingest({\n docs: [\n {\n _id: \"123\",\n _index: \"my-index\",\n _source: {\n foo: \"bar\",\n },\n },\n {\n _id: \"456\",\n _index: \"my-index\",\n _source: {\n foo: \"rab\",\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.simulate.ingest(\n body: {\n \"docs\": [\n {\n \"_id\": \"123\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"bar\"\n }\n },\n {\n \"_id\": \"456\",\n \"_index\": \"my-index\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->simulate()->ingest([\n \"body\" => [\n \"docs\" => array(\n [\n \"_id\" => \"123\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"bar\",\n ],\n ],\n [\n \"_id\" => \"456\",\n \"_index\" => \"my-index\",\n \"_source\" => [\n \"foo\" => \"rab\",\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":\"123\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"bar\"}},{\"_id\":\"456\",\"_index\":\"my-index\",\"_source\":{\"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" - }, - { - "language": "Java", - "code": "client.simulate().ingest(i -> i\n .docs(List.of(Document.of(d -> d\n .id(\"123\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"bar\\\"}\"))),Document.of(d -> d\n .id(\"456\")\n .index(\"my-index\")\n .source(JsonData.fromJson(\"{\\\"foo\\\":\\\"rab\\\"}\")))))\n);\n" - } - ], - "specification/slm/get_stats/examples/request/GetSnapshotLifecycleManagementStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.get_stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.getStats();" - }, - { - "language": "Ruby", - "code": "response = client.slm.get_stats" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->getStats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/stats\"" - }, - { - "language": "Java", - "code": "client.slm().getStats(g -> g);\n" - } - ], - "specification/slm/get_status/examples/request/GetSnapshotLifecycleManagementStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.get_status()" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.getStatus();" - }, - { - "language": "Ruby", - "code": "response = client.slm.get_status" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->getStatus();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/status\"" - }, - { - "language": "Java", - "code": "client.slm().getStatus(g -> g);\n" - } - ], - "specification/slm/delete_lifecycle/examples/request/SlmDeleteLifecycleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.delete_lifecycle(\n policy_id=\"daily-snapshots\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.deleteLifecycle({\n policy_id: \"daily-snapshots\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.slm.delete_lifecycle(\n policy_id: \"daily-snapshots\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->deleteLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots\"" - }, - { - "language": "Java", - "code": "client.slm().deleteLifecycle(d -> d\n .policyId(\"daily-snapshots\")\n);\n" - } - ], - "specification/slm/start/examples/request/StartSnapshotLifecycleManagementRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.start()" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.start();" - }, - { - "language": "Ruby", - "code": "response = client.slm.start" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->start();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/start\"" - }, - { - "language": "Java", - "code": "client.slm().start(s -> s);\n" - } - ], - "specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.get_lifecycle(\n policy_id=\"daily-snapshots\",\n human=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.getLifecycle({\n policy_id: \"daily-snapshots\",\n human: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.slm.get_lifecycle(\n policy_id: \"daily-snapshots\",\n human: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->getLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n \"human\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots?human\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.put_lifecycle(\n policy_id=\"daily-snapshots\",\n schedule=\"0 30 1 * * ?\",\n name=\"\",\n repository=\"my_repository\",\n config={\n \"indices\": [\n \"data-*\",\n \"important\"\n ],\n \"ignore_unavailable\": False,\n \"include_global_state\": False\n },\n retention={\n \"expire_after\": \"30d\",\n \"min_count\": 5,\n \"max_count\": 50\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.putLifecycle({\n policy_id: \"daily-snapshots\",\n schedule: \"0 30 1 * * ?\",\n name: \"\",\n repository: \"my_repository\",\n config: {\n indices: [\"data-*\", \"important\"],\n ignore_unavailable: false,\n include_global_state: false,\n },\n retention: {\n expire_after: \"30d\",\n min_count: 5,\n max_count: 50,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.slm.put_lifecycle(\n policy_id: \"daily-snapshots\",\n body: {\n \"schedule\": \"0 30 1 * * ?\",\n \"name\": \"\",\n \"repository\": \"my_repository\",\n \"config\": {\n \"indices\": [\n \"data-*\",\n \"important\"\n ],\n \"ignore_unavailable\": false,\n \"include_global_state\": false\n },\n \"retention\": {\n \"expire_after\": \"30d\",\n \"min_count\": 5,\n \"max_count\": 50\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->putLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n \"body\" => [\n \"schedule\" => \"0 30 1 * * ?\",\n \"name\" => \"\",\n \"repository\" => \"my_repository\",\n \"config\" => [\n \"indices\" => array(\n \"data-*\",\n \"important\",\n ),\n \"ignore_unavailable\" => false,\n \"include_global_state\" => false,\n ],\n \"retention\" => [\n \"expire_after\" => \"30d\",\n \"min_count\" => 5,\n \"max_count\" => 50,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"schedule\":\"0 30 1 * * ?\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\"important\"],\"ignore_unavailable\":false,\"include_global_state\":false},\"retention\":{\"expire_after\":\"30d\",\"min_count\":5,\"max_count\":50}}' \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots\"" - }, - { - "language": "Java", - "code": "client.slm().putLifecycle(p -> p\n .config(c -> c\n .ignoreUnavailable(false)\n .indices(List.of(\"data-*\",\"important\"))\n .includeGlobalState(false)\n )\n .name(\"\")\n .policyId(\"daily-snapshots\")\n .repository(\"my_repository\")\n .retention(r -> r\n .expireAfter(e -> e\n .time(\"30d\")\n )\n .maxCount(50)\n .minCount(5)\n )\n .schedule(\"0 30 1 * * ?\")\n);\n" - } - ], - "specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.put_lifecycle(\n policy_id=\"hourly-snapshots\",\n schedule=\"1h\",\n name=\"\",\n repository=\"my_repository\",\n config={\n \"indices\": [\n \"data-*\",\n \"important\"\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.putLifecycle({\n policy_id: \"hourly-snapshots\",\n schedule: \"1h\",\n name: \"\",\n repository: \"my_repository\",\n config: {\n indices: [\"data-*\", \"important\"],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.slm.put_lifecycle(\n policy_id: \"hourly-snapshots\",\n body: {\n \"schedule\": \"1h\",\n \"name\": \"\",\n \"repository\": \"my_repository\",\n \"config\": {\n \"indices\": [\n \"data-*\",\n \"important\"\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->putLifecycle([\n \"policy_id\" => \"hourly-snapshots\",\n \"body\" => [\n \"schedule\" => \"1h\",\n \"name\" => \"\",\n \"repository\" => \"my_repository\",\n \"config\" => [\n \"indices\" => array(\n \"data-*\",\n \"important\",\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"schedule\":\"1h\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\"important\"]}}' \"$ELASTICSEARCH_URL/_slm/policy/hourly-snapshots\"" - }, - { - "language": "Java", - "code": "client.slm().putLifecycle(p -> p\n .config(c -> c\n .indices(List.of(\"data-*\",\"important\"))\n )\n .name(\"\")\n .policyId(\"hourly-snapshots\")\n .repository(\"my_repository\")\n .schedule(\"1h\")\n);\n" - } - ], - "specification/slm/execute_retention/examples/request/SlmExecuteRetentionExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.execute_retention()" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.executeRetention();" - }, - { - "language": "Ruby", - "code": "response = client.slm.execute_retention" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->executeRetention();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/_execute_retention\"" - }, - { - "language": "Java", - "code": "client.slm().executeRetention(e -> e);\n" - } - ], - "specification/slm/execute_lifecycle/examples/request/ExecuteSnapshotLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.slm.execute_lifecycle(\n policy_id=\"daily-snapshots\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.slm.executeLifecycle({\n policy_id: \"daily-snapshots\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.slm.execute_lifecycle(\n policy_id: \"daily-snapshots\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->slm()->executeLifecycle([\n \"policy_id\" => \"daily-snapshots\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots/_execute\"" - }, - { - "language": "Java", - "code": "client.slm().executeLifecycle(e -> e\n .policyId(\"daily-snapshots\")\n);\n" - } - ], - "specification/features/reset_features/examples/request/FeaturesResetFeaturesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.features.reset_features()" - }, - { - "language": "JavaScript", - "code": "const response = await client.features.resetFeatures();" - }, - { - "language": "Ruby", - "code": "response = client.features.reset_features" - }, - { - "language": "PHP", - "code": "$resp = $client->features()->resetFeatures();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_features/_reset\"" - }, - { - "language": "Java", - "code": "client.features().resetFeatures(r -> r);\n" - } - ], - "specification/features/get_features/examples/request/FeaturesGetFeaturesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.features.get_features()" - }, - { - "language": "JavaScript", - "code": "const response = await client.features.getFeatures();" - }, - { - "language": "Ruby", - "code": "response = client.features.get_features" - }, - { - "language": "PHP", - "code": "$resp = $client->features()->getFeatures();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_features\"" - }, - { - "language": "Java", - "code": "client.features().getFeatures(g -> g);\n" - } - ], - "specification/graph/explore/examples/request/GraphExploreRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.graph.explore(\n index=\"clicklogs\",\n query={\n \"match\": {\n \"query.raw\": \"midi\"\n }\n },\n vertices=[\n {\n \"field\": \"product\"\n }\n ],\n connections={\n \"vertices\": [\n {\n \"field\": \"query.raw\"\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.graph.explore({\n index: \"clicklogs\",\n query: {\n match: {\n \"query.raw\": \"midi\",\n },\n },\n vertices: [\n {\n field: \"product\",\n },\n ],\n connections: {\n vertices: [\n {\n field: \"query.raw\",\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.graph.explore(\n index: \"clicklogs\",\n body: {\n \"query\": {\n \"match\": {\n \"query.raw\": \"midi\"\n }\n },\n \"vertices\": [\n {\n \"field\": \"product\"\n }\n ],\n \"connections\": {\n \"vertices\": [\n {\n \"field\": \"query.raw\"\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->graph()->explore([\n \"index\" => \"clicklogs\",\n \"body\" => [\n \"query\" => [\n \"match\" => [\n \"query.raw\" => \"midi\",\n ],\n ],\n \"vertices\" => array(\n [\n \"field\" => \"product\",\n ],\n ),\n \"connections\" => [\n \"vertices\" => array(\n [\n \"field\" => \"query.raw\",\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"match\":{\"query.raw\":\"midi\"}},\"vertices\":[{\"field\":\"product\"}],\"connections\":{\"vertices\":[{\"field\":\"query.raw\"}]}}' \"$ELASTICSEARCH_URL/clicklogs/_graph/explore\"" - }, - { - "language": "Java", - "code": "client.graph().explore(e -> e\n .connections(c -> c\n .vertices(v -> v\n .field(\"query.raw\")\n )\n )\n .index(\"clicklogs\")\n .query(q -> q\n .match(m -> m\n .field(\"query.raw\")\n .query(FieldValue.of(\"midi\"))\n )\n )\n .vertices(v -> v\n .field(\"product\")\n )\n);\n" - } - ], - "specification/synonyms/get_synonym_rule/examples/request/SynonymRuleGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.get_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.getSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.get_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->getSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" - }, - { - "language": "Java", - "code": "client.synonyms().getSynonymRule(g -> g\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n);\n" - } - ], - "specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.put_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n synonyms=\"hello, hi, howdy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.putSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n synonyms: \"hello, hi, howdy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.put_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n body: {\n \"synonyms\": \"hello, hi, howdy\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->putSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n \"body\" => [\n \"synonyms\" => \"hello, hi, howdy\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"synonyms\":\"hello, hi, howdy\"}' \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" - }, - { - "language": "Java", - "code": "client.synonyms().putSynonymRule(p -> p\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n .synonyms(\"hello, hi, howdy\")\n);\n" - } - ], - "specification/synonyms/delete_synonym_rule/examples/request/SynonymRuleDeleteRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.delete_synonym_rule(\n set_id=\"my-synonyms-set\",\n rule_id=\"test-1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.deleteSynonymRule({\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.delete_synonym_rule(\n set_id: \"my-synonyms-set\",\n rule_id: \"test-1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->deleteSynonymRule([\n \"set_id\" => \"my-synonyms-set\",\n \"rule_id\" => \"test-1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1\"" - }, - { - "language": "Java", - "code": "client.synonyms().deleteSynonymRule(d -> d\n .ruleId(\"test-1\")\n .setId(\"my-synonyms-set\")\n);\n" - } - ], - "specification/synonyms/delete_synonym/examples/request/SynonymsDeleteSynonymExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.delete_synonym(\n id=\"my-synonyms-set\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.deleteSynonym({\n id: \"my-synonyms-set\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.delete_synonym(\n id: \"my-synonyms-set\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->deleteSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" - }, - { - "language": "Java", - "code": "client.synonyms().deleteSynonym(d -> d\n .id(\"my-synonyms-set\")\n);\n" - } - ], - "specification/synonyms/get_synonym/examples/request/SynonymsGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.get_synonym(\n id=\"my-synonyms-set\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.getSynonym({\n id: \"my-synonyms-set\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.get_synonym(\n id: \"my-synonyms-set\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->getSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" - }, - { - "language": "Java", - "code": "client.synonyms().getSynonym(g -> g\n .id(\"my-synonyms-set\")\n);\n" - } - ], - "specification/synonyms/get_synonyms_sets/examples/request/SynonymsSetsGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.get_synonyms_sets()" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.getSynonymsSets();" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.get_synonyms_sets" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->getSynonymsSets();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms\"" - }, - { - "language": "Java", - "code": "client.synonyms().getSynonymsSets(g -> g);\n" - } - ], - "specification/synonyms/put_synonym/examples/request/SynonymsPutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.synonyms.put_synonym(\n id=\"my-synonyms-set\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.synonyms.putSynonym({\n id: \"my-synonyms-set\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.synonyms.put_synonym(\n id: \"my-synonyms-set\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->synonyms()->putSynonym([\n \"id\" => \"my-synonyms-set\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_synonyms/my-synonyms-set\"" - } - ], - "specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.dangling_indices.list_dangling_indices()" - }, - { - "language": "JavaScript", - "code": "const response = await client.danglingIndices.listDanglingIndices();" - }, - { - "language": "Ruby", - "code": "response = client.dangling_indices.list_dangling_indices" - }, - { - "language": "PHP", - "code": "$resp = $client->danglingIndices()->listDanglingIndices();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling\"" - }, - { - "language": "Java", - "code": "client.danglingIndices().listDanglingIndices();\n" - } - ], - "specification/dangling_indices/delete_dangling_index/examples/request/DanglingIndicesDeleteDanglingIndexExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.dangling_indices.delete_dangling_index(\n index_uuid=\"\",\n accept_data_loss=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.danglingIndices.deleteDanglingIndex({\n index_uuid: \"\",\n accept_data_loss: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.dangling_indices.delete_dangling_index(\n index_uuid: \"\",\n accept_data_loss: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->danglingIndices()->deleteDanglingIndex([\n \"index_uuid\" => \"\",\n \"accept_data_loss\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling/?accept_data_loss=true\"" - }, - { - "language": "Java", - "code": "client.danglingIndices().deleteDanglingIndex(d -> d\n .acceptDataLoss(true)\n .indexUuid(\"\")\n);\n" - } - ], - "specification/dangling_indices/import_dangling_index/examples/request/ImportDanglingIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.dangling_indices.import_dangling_index(\n index_uuid=\"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.danglingIndices.importDanglingIndex({\n index_uuid: \"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.dangling_indices.import_dangling_index(\n index_uuid: \"zmM4e0JtBkeUjiHD-MihPQ\",\n accept_data_loss: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->danglingIndices()->importDanglingIndex([\n \"index_uuid\" => \"zmM4e0JtBkeUjiHD-MihPQ\",\n \"accept_data_loss\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_dangling/zmM4e0JtBkeUjiHD-MihPQ?accept_data_loss=true\"" - }, - { - "language": "Java", - "code": "client.danglingIndices().importDanglingIndex(i -> i\n .acceptDataLoss(true)\n .indexUuid(\"zmM4e0JtBkeUjiHD-MihPQ\")\n);\n" - } - ], - "specification/ml/forecast/examples/request/MlForecastExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.forecast(\n job_id=\"low_request_rate\",\n duration=\"10d\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.forecast({\n job_id: \"low_request_rate\",\n duration: \"10d\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.forecast(\n job_id: \"low_request_rate\",\n body: {\n \"duration\": \"10d\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->forecast([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"duration\" => \"10d\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"duration\":\"10d\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_forecast\"" - }, - { - "language": "Java", - "code": "client.ml().forecast(f -> f\n .duration(d -> d\n .time(\"10d\")\n )\n .jobId(\"low_request_rate\")\n);\n" - } - ], - "specification/ml/stop_data_frame_analytics/examples/request/MlStopDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.stop_data_frame_analytics(\n id=\"loganalytics\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.stopDataFrameAnalytics({\n id: \"loganalytics\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.stop_data_frame_analytics(\n id: \"loganalytics\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->stopDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_stop\"" - }, - { - "language": "Java", - "code": "client.ml().stopDataFrameAnalytics(s -> s\n .id(\"loganalytics\")\n);\n" - } - ], - "specification/ml/delete_model_snapshot/examples/request/MlDeleteModelSnapshotExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_model_snapshot(\n job_id=\"farequote\",\n snapshot_id=\"1491948163\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteModelSnapshot({\n job_id: \"farequote\",\n snapshot_id: 1491948163,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_model_snapshot(\n job_id: \"farequote\",\n snapshot_id: \"1491948163\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteModelSnapshot([\n \"job_id\" => \"farequote\",\n \"snapshot_id\" => \"1491948163\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/farequote/model_snapshots/1491948163\"" - }, - { - "language": "Java", - "code": "client.ml().deleteModelSnapshot(d -> d\n .jobId(\"farequote\")\n .snapshotId(\"1491948163\")\n);\n" - } - ], - "specification/ml/get_datafeed_stats/examples/request/MlGetDatafeedStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_datafeed_stats(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getDatafeedStats({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_datafeed_stats(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getDatafeedStats([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_stats\"" - }, - { - "language": "Java", - "code": "client.ml().getDatafeedStats(g -> g\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" - } - ], - "specification/ml/delete_datafeed/examples/request/MlDeleteDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_datafeed(\n datafeed_id=\"datafeed-total-requests\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteDatafeed({\n datafeed_id: \"datafeed-total-requests\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_datafeed(\n datafeed_id: \"datafeed-total-requests\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteDatafeed([\n \"datafeed_id\" => \"datafeed-total-requests\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-total-requests\"" - }, - { - "language": "Java", - "code": "client.ml().deleteDatafeed(d -> d\n .datafeedId(\"datafeed-total-requests\")\n);\n" - } - ], - "specification/ml/delete_calendar_job/examples/request/MlDeleteCalendarJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_calendar_job(\n calendar_id=\"planned-outages\",\n job_id=\"total-requests\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteCalendarJob({\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_calendar_job(\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteCalendarJob([\n \"calendar_id\" => \"planned-outages\",\n \"job_id\" => \"total-requests\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/jobs/total-requests\"" - }, - { - "language": "Java", - "code": "client.ml().deleteCalendarJob(d -> d\n .calendarId(\"planned-outages\")\n .jobId(\"total-requests\")\n);\n" - } - ], - "specification/ml/get_datafeeds/examples/request/MlGetDatafeedsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_datafeeds(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getDatafeeds({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_datafeeds(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getDatafeeds([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales\"" - }, - { - "language": "Java", - "code": "client.ml().getDatafeeds(g -> g\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" - } - ], - "specification/ml/stop_trained_model_deployment/examples/request/MlStopTrainedModelDeploymentExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.stop_trained_model_deployment(\n model_id=\"my_model_for_search\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.stopTrainedModelDeployment({\n model_id: \"my_model_for_search\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.stop_trained_model_deployment(\n model_id: \"my_model_for_search\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->stopTrainedModelDeployment([\n \"model_id\" => \"my_model_for_search\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/my_model_for_search/deployment/_stop\"" - }, - { - "language": "Java", - "code": "client.ml().stopTrainedModelDeployment(s -> s\n .modelId(\"my_model_for_search\")\n);\n" - } - ], - "specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.stop_datafeed(\n datafeed_id=\"datafeed-low_request_rate\",\n timeout=\"30s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.stopDatafeed({\n datafeed_id: \"datafeed-low_request_rate\",\n timeout: \"30s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.stop_datafeed(\n datafeed_id: \"datafeed-low_request_rate\",\n body: {\n \"timeout\": \"30s\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->stopDatafeed([\n \"datafeed_id\" => \"datafeed-low_request_rate\",\n \"body\" => [\n \"timeout\" => \"30s\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_stop\"" - }, - { - "language": "Java", - "code": "client.ml().stopDatafeed(s -> s\n .datafeedId(\"datafeed-low_request_rate\")\n .timeout(t -> t\n .time(\"30s\")\n )\n);\n" - } - ], - "specification/ml/get_calendar_events/examples/request/MlGetCalendarEventsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_calendar_events(\n calendar_id=\"planned-outages\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getCalendarEvents({\n calendar_id: \"planned-outages\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_calendar_events(\n calendar_id: \"planned-outages\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getCalendarEvents([\n \"calendar_id\" => \"planned-outages\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events\"" - }, - { - "language": "Java", - "code": "client.ml().getCalendarEvents(g -> g\n .calendarId(\"planned-outages\")\n);\n" - } - ], - "specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.infer_trained_model(\n model_id=\"lang_ident_model_1\",\n docs=[\n {\n \"text\": \"The fool doth think he is wise, but the wise man knows himself to be a fool.\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.inferTrainedModel({\n model_id: \"lang_ident_model_1\",\n docs: [\n {\n text: \"The fool doth think he is wise, but the wise man knows himself to be a fool.\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.infer_trained_model(\n model_id: \"lang_ident_model_1\",\n body: {\n \"docs\": [\n {\n \"text\": \"The fool doth think he is wise, but the wise man knows himself to be a fool.\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->inferTrainedModel([\n \"model_id\" => \"lang_ident_model_1\",\n \"body\" => [\n \"docs\" => array(\n [\n \"text\" => \"The fool doth think he is wise, but the wise man knows himself to be a fool.\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"text\":\"The fool doth think he is wise, but the wise man knows himself to be a fool.\"}]}' \"$ELASTICSEARCH_URL/_ml/trained_models/lang_ident_model_1/_infer\"" - }, - { - "language": "Java", - "code": "client.ml().inferTrainedModel(i -> i\n .docs(Map.of(\"text\", JsonData.fromJson(\"\\\"The fool doth think he is wise, but the wise man knows himself to be a fool.\\\"\")))\n .modelId(\"lang_ident_model_1\")\n);\n" - } - ], - "specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_datafeed(\n datafeed_id=\"datafeed-test-job\",\n pretty=True,\n indices=[\n \"kibana_sample_data_logs\"\n ],\n query={\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n job_id=\"test-job\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putDatafeed({\n datafeed_id: \"datafeed-test-job\",\n pretty: \"true\",\n indices: [\"kibana_sample_data_logs\"],\n query: {\n bool: {\n must: [\n {\n match_all: {},\n },\n ],\n },\n },\n job_id: \"test-job\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_datafeed(\n datafeed_id: \"datafeed-test-job\",\n pretty: \"true\",\n body: {\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"job_id\": \"test-job\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putDatafeed([\n \"datafeed_id\" => \"datafeed-test-job\",\n \"pretty\" => \"true\",\n \"body\" => [\n \"indices\" => array(\n \"kibana_sample_data_logs\",\n ),\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"match_all\" => new ArrayObject([]),\n ],\n ),\n ],\n ],\n \"job_id\" => \"test-job\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":[\"kibana_sample_data_logs\"],\"query\":{\"bool\":{\"must\":[{\"match_all\":{}}]}},\"job_id\":\"test-job\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job?pretty\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_job(\n job_id=\"low_request_rate\",\n description=\"An updated job\",\n detectors={\n \"detector_index\": 0,\n \"description\": \"An updated detector description\"\n },\n groups=[\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\"\n ],\n model_plot_config={\n \"enabled\": True\n },\n renormalization_window_days=30,\n background_persist_interval=\"2h\",\n model_snapshot_retention_days=7,\n results_retention_days=60,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateJob({\n job_id: \"low_request_rate\",\n description: \"An updated job\",\n detectors: {\n detector_index: 0,\n description: \"An updated detector description\",\n },\n groups: [\"kibana_sample_data\", \"kibana_sample_web_logs\"],\n model_plot_config: {\n enabled: true,\n },\n renormalization_window_days: 30,\n background_persist_interval: \"2h\",\n model_snapshot_retention_days: 7,\n results_retention_days: 60,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_job(\n job_id: \"low_request_rate\",\n body: {\n \"description\": \"An updated job\",\n \"detectors\": {\n \"detector_index\": 0,\n \"description\": \"An updated detector description\"\n },\n \"groups\": [\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\"\n ],\n \"model_plot_config\": {\n \"enabled\": true\n },\n \"renormalization_window_days\": 30,\n \"background_persist_interval\": \"2h\",\n \"model_snapshot_retention_days\": 7,\n \"results_retention_days\": 60\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateJob([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"description\" => \"An updated job\",\n \"detectors\" => [\n \"detector_index\" => 0,\n \"description\" => \"An updated detector description\",\n ],\n \"groups\" => array(\n \"kibana_sample_data\",\n \"kibana_sample_web_logs\",\n ),\n \"model_plot_config\" => [\n \"enabled\" => true,\n ],\n \"renormalization_window_days\" => 30,\n \"background_persist_interval\" => \"2h\",\n \"model_snapshot_retention_days\" => 7,\n \"results_retention_days\" => 60,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"An updated job\",\"detectors\":{\"detector_index\":0,\"description\":\"An updated detector description\"},\"groups\":[\"kibana_sample_data\",\"kibana_sample_web_logs\"],\"model_plot_config\":{\"enabled\":true},\"renormalization_window_days\":30,\"background_persist_interval\":\"2h\",\"model_snapshot_retention_days\":7,\"results_retention_days\":60}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateJob(u -> u\n .backgroundPersistInterval(b -> b\n .time(\"2h\")\n )\n .description(\"An updated job\")\n .detectors(d -> d\n .detectorIndex(0)\n .description(\"An updated detector description\")\n )\n .groups(List.of(\"kibana_sample_data\",\"kibana_sample_web_logs\"))\n .jobId(\"low_request_rate\")\n .modelPlotConfig(m -> m\n .enabled(true)\n )\n .modelSnapshotRetentionDays(7L)\n .renormalizationWindowDays(30L)\n .resultsRetentionDays(60L)\n);\n" - } - ], - "specification/ml/upgrade_job_snapshot/examples/request/MlUpgradeJobSnapshotExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.upgrade_job_snapshot(\n job_id=\"low_request_rate\",\n snapshot_id=\"1828371\",\n timeout=\"45m\",\n wait_for_completion=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.upgradeJobSnapshot({\n job_id: \"low_request_rate\",\n snapshot_id: 1828371,\n timeout: \"45m\",\n wait_for_completion: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.upgrade_job_snapshot(\n job_id: \"low_request_rate\",\n snapshot_id: \"1828371\",\n timeout: \"45m\",\n wait_for_completion: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->upgradeJobSnapshot([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"1828371\",\n \"timeout\" => \"45m\",\n \"wait_for_completion\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1828371/_upgrade?timeout=45m&wait_for_completion=true\"" - }, - { - "language": "Java", - "code": "client.ml().upgradeJobSnapshot(u -> u\n .jobId(\"low_request_rate\")\n .snapshotId(\"1828371\")\n .timeout(t -> t\n .offset(45)\n )\n .waitForCompletion(true)\n);\n" - } - ], - "specification/ml/get_jobs/examples/request/MlGetJobsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_jobs(\n job_id=\"high_sum_total_sales\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getJobs({\n job_id: \"high_sum_total_sales\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_jobs(\n job_id: \"high_sum_total_sales\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getJobs([\n \"job_id\" => \"high_sum_total_sales\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales\"" - }, - { - "language": "Java", - "code": "client.ml().getJobs(g -> g\n .jobId(\"high_sum_total_sales\")\n);\n" - } - ], - "specification/ml/get_model_snapshot_upgrade_stats/examples/request/MlGetModelSnapshotUpgradeStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_model_snapshot_upgrade_stats(\n job_id=\"low_request_rate\",\n snapshot_id=\"_all\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getModelSnapshotUpgradeStats({\n job_id: \"low_request_rate\",\n snapshot_id: \"_all\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_model_snapshot_upgrade_stats(\n job_id: \"low_request_rate\",\n snapshot_id: \"_all\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getModelSnapshotUpgradeStats([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"_all\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/_all/_upgrade/_stats\"" - }, - { - "language": "Java", - "code": "client.ml().getModelSnapshotUpgradeStats(g -> g\n .jobId(\"low_request_rate\")\n .snapshotId(\"_all\")\n);\n" - } - ], - "specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_model_snapshot(\n job_id=\"it_ops_new_logs\",\n snapshot_id=\"1491852978\",\n description=\"Snapshot 1\",\n retain=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateModelSnapshot({\n job_id: \"it_ops_new_logs\",\n snapshot_id: 1491852978,\n description: \"Snapshot 1\",\n retain: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_model_snapshot(\n job_id: \"it_ops_new_logs\",\n snapshot_id: \"1491852978\",\n body: {\n \"description\": \"Snapshot 1\",\n \"retain\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateModelSnapshot([\n \"job_id\" => \"it_ops_new_logs\",\n \"snapshot_id\" => \"1491852978\",\n \"body\" => [\n \"description\" => \"Snapshot 1\",\n \"retain\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Snapshot 1\",\"retain\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateModelSnapshot(u -> u\n .description(\"Snapshot 1\")\n .jobId(\"it_ops_new_logs\")\n .retain(true)\n .snapshotId(\"1491852978\")\n);\n" - } - ], - "specification/ml/put_calendar_job/examples/request/MlPutCalendarJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_calendar_job(\n calendar_id=\"planned-outages\",\n job_id=\"total-requests\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putCalendarJob({\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_calendar_job(\n calendar_id: \"planned-outages\",\n job_id: \"total-requests\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putCalendarJob([\n \"calendar_id\" => \"planned-outages\",\n \"job_id\" => \"total-requests\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/jobs/total-requests\"" - }, - { - "language": "Java", - "code": "client.ml().putCalendarJob(p -> p\n .calendarId(\"planned-outages\")\n .jobId(\"total-requests\")\n);\n" - } - ], - "specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.estimate_model_memory(\n analysis_config={\n \"bucket_span\": \"5m\",\n \"detectors\": [\n {\n \"function\": \"sum\",\n \"field_name\": \"bytes\",\n \"by_field_name\": \"status\",\n \"partition_field_name\": \"app\"\n }\n ],\n \"influencers\": [\n \"source_ip\",\n \"dest_ip\"\n ]\n },\n overall_cardinality={\n \"status\": 10,\n \"app\": 50\n },\n max_bucket_cardinality={\n \"source_ip\": 300,\n \"dest_ip\": 30\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.estimateModelMemory({\n analysis_config: {\n bucket_span: \"5m\",\n detectors: [\n {\n function: \"sum\",\n field_name: \"bytes\",\n by_field_name: \"status\",\n partition_field_name: \"app\",\n },\n ],\n influencers: [\"source_ip\", \"dest_ip\"],\n },\n overall_cardinality: {\n status: 10,\n app: 50,\n },\n max_bucket_cardinality: {\n source_ip: 300,\n dest_ip: 30,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.estimate_model_memory(\n body: {\n \"analysis_config\": {\n \"bucket_span\": \"5m\",\n \"detectors\": [\n {\n \"function\": \"sum\",\n \"field_name\": \"bytes\",\n \"by_field_name\": \"status\",\n \"partition_field_name\": \"app\"\n }\n ],\n \"influencers\": [\n \"source_ip\",\n \"dest_ip\"\n ]\n },\n \"overall_cardinality\": {\n \"status\": 10,\n \"app\": 50\n },\n \"max_bucket_cardinality\": {\n \"source_ip\": 300,\n \"dest_ip\": 30\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->estimateModelMemory([\n \"body\" => [\n \"analysis_config\" => [\n \"bucket_span\" => \"5m\",\n \"detectors\" => array(\n [\n \"function\" => \"sum\",\n \"field_name\" => \"bytes\",\n \"by_field_name\" => \"status\",\n \"partition_field_name\" => \"app\",\n ],\n ),\n \"influencers\" => array(\n \"source_ip\",\n \"dest_ip\",\n ),\n ],\n \"overall_cardinality\" => [\n \"status\" => 10,\n \"app\" => 50,\n ],\n \"max_bucket_cardinality\" => [\n \"source_ip\" => 300,\n \"dest_ip\" => 30,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis_config\":{\"bucket_span\":\"5m\",\"detectors\":[{\"function\":\"sum\",\"field_name\":\"bytes\",\"by_field_name\":\"status\",\"partition_field_name\":\"app\"}],\"influencers\":[\"source_ip\",\"dest_ip\"]},\"overall_cardinality\":{\"status\":10,\"app\":50},\"max_bucket_cardinality\":{\"source_ip\":300,\"dest_ip\":30}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/_estimate_model_memory\"" - }, - { - "language": "Java", - "code": "client.ml().estimateModelMemory(e -> e\n .analysisConfig(a -> a\n .bucketSpan(b -> b\n .time(\"5m\")\n )\n .detectors(d -> d\n .byFieldName(\"status\")\n .fieldName(\"bytes\")\n .function(\"sum\")\n .partitionFieldName(\"app\")\n )\n .influencers(List.of(\"source_ip\",\"dest_ip\"))\n )\n .maxBucketCardinality(Map.of(\"dest_ip\", 30L,\"source_ip\", 300L))\n .overallCardinality(Map.of(\"app\", 50L,\"status\", 10L))\n);\n" - } - ], - "specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_categories(\n job_id=\"esxi_log\",\n page={\n \"size\": 1\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getCategories({\n job_id: \"esxi_log\",\n page: {\n size: 1,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_categories(\n job_id: \"esxi_log\",\n body: {\n \"page\": {\n \"size\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getCategories([\n \"job_id\" => \"esxi_log\",\n \"body\" => [\n \"page\" => [\n \"size\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"page\":{\"size\":1}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/esxi_log/results/categories\"" - }, - { - "language": "Java", - "code": "client.ml().getCategories(g -> g\n .jobId(\"esxi_log\")\n .page(p -> p\n .size(1)\n )\n);\n" - } - ], - "specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.post_calendar_events(\n calendar_id=\"planned-outages\",\n events=[\n {\n \"description\": \"event 1\",\n \"start_time\": 1513641600000,\n \"end_time\": 1513728000000\n },\n {\n \"description\": \"event 2\",\n \"start_time\": 1513814400000,\n \"end_time\": 1513900800000\n },\n {\n \"description\": \"event 3\",\n \"start_time\": 1514160000000,\n \"end_time\": 1514246400000\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.postCalendarEvents({\n calendar_id: \"planned-outages\",\n events: [\n {\n description: \"event 1\",\n start_time: 1513641600000,\n end_time: 1513728000000,\n },\n {\n description: \"event 2\",\n start_time: 1513814400000,\n end_time: 1513900800000,\n },\n {\n description: \"event 3\",\n start_time: 1514160000000,\n end_time: 1514246400000,\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.post_calendar_events(\n calendar_id: \"planned-outages\",\n body: {\n \"events\": [\n {\n \"description\": \"event 1\",\n \"start_time\": 1513641600000,\n \"end_time\": 1513728000000\n },\n {\n \"description\": \"event 2\",\n \"start_time\": 1513814400000,\n \"end_time\": 1513900800000\n },\n {\n \"description\": \"event 3\",\n \"start_time\": 1514160000000,\n \"end_time\": 1514246400000\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->postCalendarEvents([\n \"calendar_id\" => \"planned-outages\",\n \"body\" => [\n \"events\" => array(\n [\n \"description\" => \"event 1\",\n \"start_time\" => 1513641600000,\n \"end_time\" => 1513728000000,\n ],\n [\n \"description\" => \"event 2\",\n \"start_time\" => 1513814400000,\n \"end_time\" => 1513900800000,\n ],\n [\n \"description\" => \"event 3\",\n \"start_time\" => 1514160000000,\n \"end_time\" => 1514246400000,\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"events\":[{\"description\":\"event 1\",\"start_time\":1513641600000,\"end_time\":1513728000000},{\"description\":\"event 2\",\"start_time\":1513814400000,\"end_time\":1513900800000},{\"description\":\"event 3\",\"start_time\":1514160000000,\"end_time\":1514246400000}]}' \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events\"" - }, - { - "language": "Java", - "code": "client.ml().postCalendarEvents(p -> p\n .calendarId(\"planned-outages\")\n .events(List.of(CalendarEvent.of(c -> c\n .description(\"event 1\")\n .endTime(DateTime.ofEpochMilli(1513728000000L))\n .startTime(DateTime.ofEpochMilli(1513641600000L))),CalendarEvent.of(c -> c\n .description(\"event 2\")\n .endTime(DateTime.ofEpochMilli(1513900800000L))\n .startTime(DateTime.ofEpochMilli(1513814400000L))),CalendarEvent.of(c -> c\n .description(\"event 3\")\n .endTime(DateTime.ofEpochMilli(1514246400000L))\n .startTime(DateTime.ofEpochMilli(1514160000000L)))))\n);\n" - } - ], - "specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_datafeed(\n datafeed_id=\"datafeed-test-job\",\n query={\n \"term\": {\n \"geo.src\": \"US\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateDatafeed({\n datafeed_id: \"datafeed-test-job\",\n query: {\n term: {\n \"geo.src\": \"US\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_datafeed(\n datafeed_id: \"datafeed-test-job\",\n body: {\n \"query\": {\n \"term\": {\n \"geo.src\": \"US\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateDatafeed([\n \"datafeed_id\" => \"datafeed-test-job\",\n \"body\" => [\n \"query\" => [\n \"term\" => [\n \"geo.src\" => \"US\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":{\"term\":{\"geo.src\":\"US\"}}}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateDatafeed(u -> u\n .datafeedId(\"datafeed-test-job\")\n .query(q -> q\n .term(t -> t\n .field(\"geo.src\")\n .value(FieldValue.of(\"US\"))\n )\n )\n);\n" - } - ], - "specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_job(\n job_id=\"job-01\",\n analysis_config={\n \"bucket_span\": \"15m\",\n \"detectors\": [\n {\n \"detector_description\": \"Sum of bytes\",\n \"function\": \"sum\",\n \"field_name\": \"bytes\"\n }\n ]\n },\n data_description={\n \"time_field\": \"timestamp\",\n \"time_format\": \"epoch_ms\"\n },\n analysis_limits={\n \"model_memory_limit\": \"11MB\"\n },\n model_plot_config={\n \"enabled\": True,\n \"annotations_enabled\": True\n },\n results_index_name=\"test-job1\",\n datafeed_config={\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"runtime_mappings\": {\n \"hour_of_day\": {\n \"type\": \"long\",\n \"script\": {\n \"source\": \"emit(doc['timestamp'].value.getHour());\"\n }\n }\n },\n \"datafeed_id\": \"datafeed-test-job1\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putJob({\n job_id: \"job-01\",\n analysis_config: {\n bucket_span: \"15m\",\n detectors: [\n {\n detector_description: \"Sum of bytes\",\n function: \"sum\",\n field_name: \"bytes\",\n },\n ],\n },\n data_description: {\n time_field: \"timestamp\",\n time_format: \"epoch_ms\",\n },\n analysis_limits: {\n model_memory_limit: \"11MB\",\n },\n model_plot_config: {\n enabled: true,\n annotations_enabled: true,\n },\n results_index_name: \"test-job1\",\n datafeed_config: {\n indices: [\"kibana_sample_data_logs\"],\n query: {\n bool: {\n must: [\n {\n match_all: {},\n },\n ],\n },\n },\n runtime_mappings: {\n hour_of_day: {\n type: \"long\",\n script: {\n source: \"emit(doc['timestamp'].value.getHour());\",\n },\n },\n },\n datafeed_id: \"datafeed-test-job1\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_job(\n job_id: \"job-01\",\n body: {\n \"analysis_config\": {\n \"bucket_span\": \"15m\",\n \"detectors\": [\n {\n \"detector_description\": \"Sum of bytes\",\n \"function\": \"sum\",\n \"field_name\": \"bytes\"\n }\n ]\n },\n \"data_description\": {\n \"time_field\": \"timestamp\",\n \"time_format\": \"epoch_ms\"\n },\n \"analysis_limits\": {\n \"model_memory_limit\": \"11MB\"\n },\n \"model_plot_config\": {\n \"enabled\": true,\n \"annotations_enabled\": true\n },\n \"results_index_name\": \"test-job1\",\n \"datafeed_config\": {\n \"indices\": [\n \"kibana_sample_data_logs\"\n ],\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"runtime_mappings\": {\n \"hour_of_day\": {\n \"type\": \"long\",\n \"script\": {\n \"source\": \"emit(doc['timestamp'].value.getHour());\"\n }\n }\n },\n \"datafeed_id\": \"datafeed-test-job1\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putJob([\n \"job_id\" => \"job-01\",\n \"body\" => [\n \"analysis_config\" => [\n \"bucket_span\" => \"15m\",\n \"detectors\" => array(\n [\n \"detector_description\" => \"Sum of bytes\",\n \"function\" => \"sum\",\n \"field_name\" => \"bytes\",\n ],\n ),\n ],\n \"data_description\" => [\n \"time_field\" => \"timestamp\",\n \"time_format\" => \"epoch_ms\",\n ],\n \"analysis_limits\" => [\n \"model_memory_limit\" => \"11MB\",\n ],\n \"model_plot_config\" => [\n \"enabled\" => true,\n \"annotations_enabled\" => true,\n ],\n \"results_index_name\" => \"test-job1\",\n \"datafeed_config\" => [\n \"indices\" => array(\n \"kibana_sample_data_logs\",\n ),\n \"query\" => [\n \"bool\" => [\n \"must\" => array(\n [\n \"match_all\" => new ArrayObject([]),\n ],\n ),\n ],\n ],\n \"runtime_mappings\" => [\n \"hour_of_day\" => [\n \"type\" => \"long\",\n \"script\" => [\n \"source\" => \"emit(doc['timestamp'].value.getHour());\",\n ],\n ],\n ],\n \"datafeed_id\" => \"datafeed-test-job1\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"analysis_config\":{\"bucket_span\":\"15m\",\"detectors\":[{\"detector_description\":\"Sum of bytes\",\"function\":\"sum\",\"field_name\":\"bytes\"}]},\"data_description\":{\"time_field\":\"timestamp\",\"time_format\":\"epoch_ms\"},\"analysis_limits\":{\"model_memory_limit\":\"11MB\"},\"model_plot_config\":{\"enabled\":true,\"annotations_enabled\":true},\"results_index_name\":\"test-job1\",\"datafeed_config\":{\"indices\":[\"kibana_sample_data_logs\"],\"query\":{\"bool\":{\"must\":[{\"match_all\":{}}]}},\"runtime_mappings\":{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['\"'\"'timestamp'\"'\"'].value.getHour());\"}}},\"datafeed_id\":\"datafeed-test-job1\"}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01\"" - }, - { - "language": "Java", - "code": "client.ml().putJob(p -> p\n .analysisConfig(a -> a\n .bucketSpan(b -> b\n .time(\"15m\")\n )\n .detectors(d -> d\n .detectorDescription(\"Sum of bytes\")\n .fieldName(\"bytes\")\n .function(\"sum\")\n )\n )\n .analysisLimits(an -> an\n .modelMemoryLimit(\"11MB\")\n )\n .dataDescription(d -> d\n .timeField(\"timestamp\")\n .timeFormat(\"epoch_ms\")\n )\n .datafeedConfig(d -> d\n .datafeedId(\"datafeed-test-job1\")\n .indices(\"kibana_sample_data_logs\")\n .query(q -> q\n .bool(b -> b\n .must(m -> m\n .matchAll(ma -> ma)\n )\n )\n )\n .runtimeMappings(\"hour_of_day\", r -> r\n .script(s -> s\n .source(so -> so\n .scriptString(\"emit(doc['timestamp'].value.getHour());\")\n )\n )\n .type(RuntimeFieldType.Long)\n )\n )\n .jobId(\"job-01\")\n .modelPlotConfig(m -> m\n .annotationsEnabled(true)\n .enabled(true)\n )\n .resultsIndexName(\"test-job1\")\n);\n" - } - ], - "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.evaluate_data_frame(\n index=\"house_price_predictions\",\n query={\n \"term\": {\n \"ml.is_training\": {\n \"value\": True\n }\n }\n },\n evaluation={\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {},\n \"huber\": {}\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.evaluateDataFrame({\n index: \"house_price_predictions\",\n query: {\n term: {\n \"ml.is_training\": {\n value: true,\n },\n },\n },\n evaluation: {\n regression: {\n actual_field: \"price\",\n predicted_field: \"ml.price_prediction\",\n metrics: {\n r_squared: {},\n mse: {},\n msle: {},\n huber: {},\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"term\": {\n \"ml.is_training\": {\n \"value\": true\n }\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {},\n \"huber\": {}\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"house_price_predictions\",\n \"query\" => [\n \"term\" => [\n \"ml.is_training\" => [\n \"value\" => true,\n ],\n ],\n ],\n \"evaluation\" => [\n \"regression\" => [\n \"actual_field\" => \"price\",\n \"predicted_field\" => \"ml.price_prediction\",\n \"metrics\" => [\n \"r_squared\" => new ArrayObject([]),\n \"mse\" => new ArrayObject([]),\n \"msle\" => new ArrayObject([]),\n \"huber\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"house_price_predictions\",\"query\":{\"term\":{\"ml.is_training\":{\"value\":true}}},\"evaluation\":{\"regression\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\":{},\"msle\":{},\"huber\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" - }, - { - "language": "Java", - "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .regression(r -> r\n .actualField(\"price\")\n .predictedField(\"ml.price_prediction\")\n .metrics(m -> m\n .msle(ms -> ms)\n .huber(h -> h)\n )\n )\n )\n .index(\"house_price_predictions\")\n .query(q -> q\n .term(t -> t\n .field(\"ml.is_training\")\n .value(FieldValue.of(true))\n )\n )\n);\n" - } - ], - "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.evaluate_data_frame(\n index=\"house_price_predictions\",\n query={\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": False\n }\n }\n ]\n }\n },\n evaluation={\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.evaluateDataFrame({\n index: \"house_price_predictions\",\n query: {\n bool: {\n filter: [\n {\n term: {\n \"ml.is_training\": false,\n },\n },\n ],\n },\n },\n evaluation: {\n regression: {\n actual_field: \"price\",\n predicted_field: \"ml.price_prediction\",\n metrics: {\n r_squared: {},\n mse: {},\n msle: {\n offset: 10,\n },\n huber: {\n delta: 1.5,\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"house_price_predictions\",\n \"query\" => [\n \"bool\" => [\n \"filter\" => array(\n [\n \"term\" => [\n \"ml.is_training\" => false,\n ],\n ],\n ),\n ],\n ],\n \"evaluation\" => [\n \"regression\" => [\n \"actual_field\" => \"price\",\n \"predicted_field\" => \"ml.price_prediction\",\n \"metrics\" => [\n \"r_squared\" => new ArrayObject([]),\n \"mse\" => new ArrayObject([]),\n \"msle\" => [\n \"offset\" => 10,\n ],\n \"huber\" => [\n \"delta\" => 1.5,\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"house_price_predictions\",\"query\":{\"bool\":{\"filter\":[{\"term\":{\"ml.is_training\":false}}]}},\"evaluation\":{\"regression\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\":{},\"msle\":{\"offset\":10},\"huber\":{\"delta\":1.5}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" - }, - { - "language": "Java", - "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .regression(r -> r\n .actualField(\"price\")\n .predictedField(\"ml.price_prediction\")\n .metrics(m -> m\n .msle(ms -> ms\n .offset(10.0D)\n )\n .huber(h -> h\n .delta(1.5D)\n )\n )\n )\n )\n .index(\"house_price_predictions\")\n .query(q -> q\n .bool(b -> b\n .filter(f -> f\n .term(t -> t\n .field(\"ml.is_training\")\n .value(FieldValue.of(false))\n )\n )\n )\n )\n);\n" - } - ], - "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.evaluate_data_frame(\n index=\"my_analytics_dest_index\",\n evaluation={\n \"outlier_detection\": {\n \"actual_field\": \"is_outlier\",\n \"predicted_probability_field\": \"ml.outlier_score\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.evaluateDataFrame({\n index: \"my_analytics_dest_index\",\n evaluation: {\n outlier_detection: {\n actual_field: \"is_outlier\",\n predicted_probability_field: \"ml.outlier_score\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"my_analytics_dest_index\",\n \"evaluation\": {\n \"outlier_detection\": {\n \"actual_field\": \"is_outlier\",\n \"predicted_probability_field\": \"ml.outlier_score\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"my_analytics_dest_index\",\n \"evaluation\" => [\n \"outlier_detection\" => [\n \"actual_field\" => \"is_outlier\",\n \"predicted_probability_field\" => \"ml.outlier_score\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_analytics_dest_index\",\"evaluation\":{\"outlier_detection\":{\"actual_field\":\"is_outlier\",\"predicted_probability_field\":\"ml.outlier_score\"}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" - }, - { - "language": "Java", - "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .outlierDetection(o -> o\n .actualField(\"is_outlier\")\n .predictedProbabilityField(\"ml.outlier_score\")\n )\n )\n .index(\"my_analytics_dest_index\")\n);\n" - } - ], - "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.evaluate_data_frame(\n index=\"animal_classification\",\n evaluation={\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"metrics\": {\n \"auc_roc\": {\n \"class_name\": \"dog\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.evaluateDataFrame({\n index: \"animal_classification\",\n evaluation: {\n classification: {\n actual_field: \"animal_class\",\n metrics: {\n auc_roc: {\n class_name: \"dog\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"animal_classification\",\n \"evaluation\": {\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"metrics\": {\n \"auc_roc\": {\n \"class_name\": \"dog\"\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"animal_classification\",\n \"evaluation\" => [\n \"classification\" => [\n \"actual_field\" => \"animal_class\",\n \"metrics\" => [\n \"auc_roc\" => [\n \"class_name\" => \"dog\",\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"metrics\":{\"auc_roc\":{\"class_name\":\"dog\"}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" - }, - { - "language": "Java", - "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .classification(c -> c\n .actualField(\"animal_class\")\n .metrics(m -> m\n .aucRoc(a -> a\n .className(\"dog\")\n )\n )\n )\n )\n .index(\"animal_classification\")\n);\n" - } - ], - "specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.evaluate_data_frame(\n index=\"animal_classification\",\n evaluation={\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"predicted_field\": \"ml.animal_class_prediction\",\n \"metrics\": {\n \"multiclass_confusion_matrix\": {}\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.evaluateDataFrame({\n index: \"animal_classification\",\n evaluation: {\n classification: {\n actual_field: \"animal_class\",\n predicted_field: \"ml.animal_class_prediction\",\n metrics: {\n multiclass_confusion_matrix: {},\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.evaluate_data_frame(\n body: {\n \"index\": \"animal_classification\",\n \"evaluation\": {\n \"classification\": {\n \"actual_field\": \"animal_class\",\n \"predicted_field\": \"ml.animal_class_prediction\",\n \"metrics\": {\n \"multiclass_confusion_matrix\": {}\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->evaluateDataFrame([\n \"body\" => [\n \"index\" => \"animal_classification\",\n \"evaluation\" => [\n \"classification\" => [\n \"actual_field\" => \"animal_class\",\n \"predicted_field\" => \"ml.animal_class_prediction\",\n \"metrics\" => [\n \"multiclass_confusion_matrix\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"predicted_field\":\"ml.animal_class_prediction\",\"metrics\":{\"multiclass_confusion_matrix\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" - }, - { - "language": "Java", - "code": "client.ml().evaluateDataFrame(e -> e\n .evaluation(ev -> ev\n .classification(c -> c\n .actualField(\"animal_class\")\n .predictedField(\"ml.animal_class_prediction\")\n .metrics(m -> m)\n )\n )\n .index(\"animal_classification\")\n);\n" - } - ], - "specification/ml/delete_forecast/examples/request/MlDeleteForecastExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_forecast(\n job_id=\"total-requests\",\n forecast_id=\"_all\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteForecast({\n job_id: \"total-requests\",\n forecast_id: \"_all\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_forecast(\n job_id: \"total-requests\",\n forecast_id: \"_all\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteForecast([\n \"job_id\" => \"total-requests\",\n \"forecast_id\" => \"_all\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests/_forecast/_all\"" - }, - { - "language": "Java", - "code": "client.ml().deleteForecast(d -> d\n .forecastId(\"_all\")\n .jobId(\"total-requests\")\n);\n" - } - ], - "specification/ml/get_trained_models/examples/request/MlGetTrainedModelsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_trained_models()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getTrainedModels();" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_trained_models" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getTrainedModels();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/\"" - }, - { - "language": "Java", - "code": "client.ml().getTrainedModels(g -> g);\n" - } - ], - "specification/ml/get_trained_models_stats/examples/request/MlGetTrainedModelsStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_trained_models_stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getTrainedModelsStats();" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_trained_models_stats" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getTrainedModelsStats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/_stats\"" - }, - { - "language": "Java", - "code": "client.ml().getTrainedModelsStats(g -> g);\n" - } - ], - "specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_influencers(\n job_id=\"high_sum_total_sales\",\n sort=\"influencer_score\",\n desc=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getInfluencers({\n job_id: \"high_sum_total_sales\",\n sort: \"influencer_score\",\n desc: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_influencers(\n job_id: \"high_sum_total_sales\",\n body: {\n \"sort\": \"influencer_score\",\n \"desc\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getInfluencers([\n \"job_id\" => \"high_sum_total_sales\",\n \"body\" => [\n \"sort\" => \"influencer_score\",\n \"desc\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":\"influencer_score\",\"desc\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/results/influencers\"" - }, - { - "language": "Java", - "code": "client.ml().getInfluencers(g -> g\n .jobId(\"high_sum_total_sales\")\n);\n" - } - ], - "specification/ml/reset_job/examples/request/MlResetJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.reset_job(\n job_id=\"total-requests\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.resetJob({\n job_id: \"total-requests\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.reset_job(\n job_id: \"total-requests\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->resetJob([\n \"job_id\" => \"total-requests\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests/_reset\"" - }, - { - "language": "Java", - "code": "client.ml().resetJob(r -> r\n .jobId(\"total-requests\")\n);\n" - } - ], - "specification/ml/get_data_frame_analytics_stats/examples/request/MlGetDataFrameAnalyticsStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_data_frame_analytics_stats(\n id=\"weblog-outliers\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getDataFrameAnalyticsStats({\n id: \"weblog-outliers\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_data_frame_analytics_stats(\n id: \"weblog-outliers\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getDataFrameAnalyticsStats([\n \"id\" => \"weblog-outliers\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/weblog-outliers/_stats\"" - }, - { - "language": "Java", - "code": "client.ml().getDataFrameAnalyticsStats(g -> g\n .id(\"weblog-outliers\")\n);\n" - } - ], - "specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_calendar(\n calendar_id=\"planned-outages\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putCalendar({\n calendar_id: \"planned-outages\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_calendar(\n calendar_id: \"planned-outages\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putCalendar([\n \"calendar_id\" => \"planned-outages\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" - }, - { - "language": "Java", - "code": "client.ml().putCalendar(p -> p\n .calendarId(\"planned-outages\")\n);\n" - } - ], - "specification/ml/delete_filter/examples/request/MlDeleteFilterExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_filter(\n filter_id=\"safe_domains\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteFilter({\n filter_id: \"safe_domains\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_filter(\n filter_id: \"safe_domains\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteFilter([\n \"filter_id\" => \"safe_domains\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" - }, - { - "language": "Java", - "code": "client.ml().deleteFilter(d -> d\n .filterId(\"safe_domains\")\n);\n" - } - ], - "specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_filter(\n filter_id=\"safe_domains\",\n description=\"Updated list of domains\",\n add_items=[\n \"*.myorg.com\"\n ],\n remove_items=[\n \"wikipedia.org\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateFilter({\n filter_id: \"safe_domains\",\n description: \"Updated list of domains\",\n add_items: [\"*.myorg.com\"],\n remove_items: [\"wikipedia.org\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_filter(\n filter_id: \"safe_domains\",\n body: {\n \"description\": \"Updated list of domains\",\n \"add_items\": [\n \"*.myorg.com\"\n ],\n \"remove_items\": [\n \"wikipedia.org\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateFilter([\n \"filter_id\" => \"safe_domains\",\n \"body\" => [\n \"description\" => \"Updated list of domains\",\n \"add_items\" => array(\n \"*.myorg.com\",\n ),\n \"remove_items\" => array(\n \"wikipedia.org\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"Updated list of domains\",\"add_items\":[\"*.myorg.com\"],\"remove_items\":[\"wikipedia.org\"]}' \"$ELASTICSEARCH_URL/_ml/filters/safe_domains/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateFilter(u -> u\n .addItems(\"*.myorg.com\")\n .description(\"Updated list of domains\")\n .filterId(\"safe_domains\")\n .removeItems(\"wikipedia.org\")\n);\n" - } - ], - "specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_expired_data(\n timeout=\"1h\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteExpiredData({\n timeout: \"1h\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_expired_data(\n timeout: \"1h\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteExpiredData([\n \"timeout\" => \"1h\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/_delete_expired_data?timeout=1h\"" - }, - { - "language": "Java", - "code": "client.ml().deleteExpiredData(d -> d\n .timeout(t -> t\n .offset(1)\n )\n);\n" - } - ], - "specification/ml/clear_trained_model_deployment_cache/examples/request/MlClearTrainedModelDeploymentCacheExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.clear_trained_model_deployment_cache(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.clearTrainedModelDeploymentCache({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.clear_trained_model_deployment_cache(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->clearTrainedModelDeploymentCache([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/cache/_clear\"" - }, - { - "language": "Java", - "code": "client.ml().clearTrainedModelDeploymentCache(c -> c\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n);\n" - } - ], - "specification/ml/delete_calendar/examples/request/MlDeleteCalendarExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_calendar(\n calendar_id=\"planned-outages\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteCalendar({\n calendar_id: \"planned-outages\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_calendar(\n calendar_id: \"planned-outages\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteCalendar([\n \"calendar_id\" => \"planned-outages\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" - }, - { - "language": "Java", - "code": "client.ml().deleteCalendar(d -> d\n .calendarId(\"planned-outages\")\n);\n" - } - ], - "specification/ml/get_filters/examples/request/MlGetFiltersExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_filters(\n filter_id=\"safe_domains\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getFilters({\n filter_id: \"safe_domains\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_filters(\n filter_id: \"safe_domains\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getFilters([\n \"filter_id\" => \"safe_domains\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" - }, - { - "language": "Java", - "code": "client.ml().getFilters(g -> g\n .filterId(\"safe_domains\")\n);\n" - } - ], - "specification/ml/put_trained_model_alias/examples/request/MlPutTrainedModelAliasExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_trained_model_alias(\n model_id=\"flight-delay-prediction-1574775339910\",\n model_alias=\"flight_delay_model\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putTrainedModelAlias({\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_trained_model_alias(\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putTrainedModelAlias([\n \"model_id\" => \"flight-delay-prediction-1574775339910\",\n \"model_alias\" => \"flight_delay_model\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model\"" - }, - { - "language": "Java", - "code": "client.ml().putTrainedModelAlias(p -> p\n .modelAlias(\"flight_delay_model\")\n .modelId(\"flight-delay-prediction-1574775339910\")\n);\n" - } - ], - "specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_trained_model_deployment(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n number_of_allocations=4,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateTrainedModelDeployment({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n number_of_allocations: 4,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_trained_model_deployment(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n body: {\n \"number_of_allocations\": 4\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateTrainedModelDeployment([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"body\" => [\n \"number_of_allocations\" => 4,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"number_of_allocations\":4}' \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateTrainedModelDeployment(u -> u\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .numberOfAllocations(4)\n);\n" - } - ], - "specification/ml/info/examples/request/MlInfoExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.info()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.info();" - }, - { - "language": "Ruby", - "code": "response = client.ml.info" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->info();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/info\"" - }, - { - "language": "Java", - "code": "client.ml().info();\n" - } - ], - "specification/ml/delete_job/examples/request/MlDeleteJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_job(\n job_id=\"total-requests\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteJob({\n job_id: \"total-requests\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_job(\n job_id: \"total-requests\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteJob([\n \"job_id\" => \"total-requests\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/total-requests\"" - }, - { - "language": "Java", - "code": "client.ml().deleteJob(d -> d\n .jobId(\"total-requests\")\n);\n" - } - ], - "specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_buckets(\n job_id=\"low_request_rate\",\n anomaly_score=80,\n start=\"1454530200001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getBuckets({\n job_id: \"low_request_rate\",\n anomaly_score: 80,\n start: 1454530200001,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_buckets(\n job_id: \"low_request_rate\",\n body: {\n \"anomaly_score\": 80,\n \"start\": \"1454530200001\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getBuckets([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"anomaly_score\" => 80,\n \"start\" => \"1454530200001\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"anomaly_score\":80,\"start\":\"1454530200001\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/buckets\"" - }, - { - "language": "Java", - "code": "client.ml().getBuckets(g -> g\n .anomalyScore(80.0D)\n .jobId(\"low_request_rate\")\n .start(DateTime.of(\"1454530200001\"))\n);\n" - } - ], - "specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.start_trained_model_deployment(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for=\"started\",\n timeout=\"1m\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.startTrainedModelDeployment({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for: \"started\",\n timeout: \"1m\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.start_trained_model_deployment(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n wait_for: \"started\",\n timeout: \"1m\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->startTrainedModelDeployment([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"wait_for\" => \"started\",\n \"timeout\" => \"1m\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_start?wait_for=started&timeout=1m\"" - }, - { - "language": "Java", - "code": "client.ml().startTrainedModelDeployment(s -> s\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .timeout(t -> t\n .offset(1)\n )\n .waitFor(DeploymentAllocationState.Started)\n);\n" - } - ], - "specification/ml/delete_calendar_event/examples/request/MlDeleteCalendarEventExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_calendar_event(\n calendar_id=\"planned-outages\",\n event_id=\"LS8LJGEBMTCMA-qz49st\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteCalendarEvent({\n calendar_id: \"planned-outages\",\n event_id: \"LS8LJGEBMTCMA-qz49st\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_calendar_event(\n calendar_id: \"planned-outages\",\n event_id: \"LS8LJGEBMTCMA-qz49st\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteCalendarEvent([\n \"calendar_id\" => \"planned-outages\",\n \"event_id\" => \"LS8LJGEBMTCMA-qz49st\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events/LS8LJGEBMTCMA-qz49st\"" - }, - { - "language": "Java", - "code": "client.ml().deleteCalendarEvent(d -> d\n .calendarId(\"planned-outages\")\n .eventId(\"LS8LJGEBMTCMA-qz49st\")\n);\n" - } - ], - "specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_records(\n job_id=\"low_request_rate\",\n sort=\"record_score\",\n desc=True,\n start=\"1454944100000\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getRecords({\n job_id: \"low_request_rate\",\n sort: \"record_score\",\n desc: true,\n start: 1454944100000,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_records(\n job_id: \"low_request_rate\",\n body: {\n \"sort\": \"record_score\",\n \"desc\": true,\n \"start\": \"1454944100000\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getRecords([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"sort\" => \"record_score\",\n \"desc\" => true,\n \"start\" => \"1454944100000\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":\"record_score\",\"desc\":true,\"start\":\"1454944100000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/records\"" - }, - { - "language": "Java", - "code": "client.ml().getRecords(g -> g\n .desc(true)\n .jobId(\"low_request_rate\")\n .sort(\"record_score\")\n .start(DateTime.of(\"1454944100000\"))\n);\n" - } - ], - "specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_memory_stats(\n human=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getMemoryStats({\n human: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_memory_stats(\n human: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getMemoryStats([\n \"human\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/memory/_stats?human\"" - }, - { - "language": "Java", - "code": "\n" - } - ], - "specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.start_datafeed(\n datafeed_id=\"datafeed-low_request_rate\",\n start=\"2019-04-07T18:22:16Z\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.startDatafeed({\n datafeed_id: \"datafeed-low_request_rate\",\n start: \"2019-04-07T18:22:16Z\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.start_datafeed(\n datafeed_id: \"datafeed-low_request_rate\",\n body: {\n \"start\": \"2019-04-07T18:22:16Z\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->startDatafeed([\n \"datafeed_id\" => \"datafeed-low_request_rate\",\n \"body\" => [\n \"start\" => \"2019-04-07T18:22:16Z\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"start\":\"2019-04-07T18:22:16Z\"}' \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_start\"" - }, - { - "language": "Java", - "code": "client.ml().startDatafeed(s -> s\n .datafeedId(\"datafeed-low_request_rate\")\n .start(DateTime.of(\"2019-04-07T18:22:16Z\"))\n);\n" - } - ], - "specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.explain_data_frame_analytics(\n source={\n \"index\": \"houses_sold_last_10_yrs\"\n },\n analysis={\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.explainDataFrameAnalytics({\n source: {\n index: \"houses_sold_last_10_yrs\",\n },\n analysis: {\n regression: {\n dependent_variable: \"price\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.explain_data_frame_analytics(\n body: {\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->explainDataFrameAnalytics([\n \"body\" => [\n \"source\" => [\n \"index\" => \"houses_sold_last_10_yrs\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"price\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"houses_sold_last_10_yrs\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"price\"}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/_explain\"" - }, - { - "language": "Java", - "code": "client.ml().explainDataFrameAnalytics(e -> e\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"price\")\n )\n )\n .source(s -> s\n .index(\"houses_sold_last_10_yrs\")\n )\n);\n" - } - ], - "specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.flush_job(\n job_id=\"low_request_rate\",\n calc_interim=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.flushJob({\n job_id: \"low_request_rate\",\n calc_interim: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.flush_job(\n job_id: \"low_request_rate\",\n body: {\n \"calc_interim\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->flushJob([\n \"job_id\" => \"low_request_rate\",\n \"body\" => [\n \"calc_interim\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"calc_interim\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_flush\"" - }, - { - "language": "Java", - "code": "client.ml().flushJob(f -> f\n .calcInterim(true)\n .jobId(\"low_request_rate\")\n);\n" - } - ], - "specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_model_snapshots(\n job_id=\"high_sum_total_sales\",\n start=\"1575402236000\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getModelSnapshots({\n job_id: \"high_sum_total_sales\",\n start: 1575402236000,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_model_snapshots(\n job_id: \"high_sum_total_sales\",\n body: {\n \"start\": \"1575402236000\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getModelSnapshots([\n \"job_id\" => \"high_sum_total_sales\",\n \"body\" => [\n \"start\" => \"1575402236000\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"start\":\"1575402236000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/model_snapshots\"" - }, - { - "language": "Java", - "code": "client.ml().getModelSnapshots(g -> g\n .jobId(\"high_sum_total_sales\")\n .start(DateTime.of(\"1575402236000\"))\n);\n" - } - ], - "specification/ml/set_upgrade_mode/examples/request/MlSetUpgradeModeExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.set_upgrade_mode(\n enabled=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.setUpgradeMode({\n enabled: \"true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.set_upgrade_mode(\n enabled: \"true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->setUpgradeMode([\n \"enabled\" => \"true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/set_upgrade_mode?enabled=true\"" - }, - { - "language": "Java", - "code": "client.ml().setUpgradeMode(s -> s\n .enabled(true)\n);\n" - } - ], - "specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.update_data_frame_analytics(\n id=\"loganalytics\",\n model_memory_limit=\"200mb\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.updateDataFrameAnalytics({\n id: \"loganalytics\",\n model_memory_limit: \"200mb\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.update_data_frame_analytics(\n id: \"loganalytics\",\n body: {\n \"model_memory_limit\": \"200mb\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->updateDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n \"body\" => [\n \"model_memory_limit\" => \"200mb\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"model_memory_limit\":\"200mb\"}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_update\"" - }, - { - "language": "Java", - "code": "client.ml().updateDataFrameAnalytics(u -> u\n .id(\"loganalytics\")\n .modelMemoryLimit(\"200mb\")\n);\n" - } - ], - "specification/ml/delete_trained_model/examples/request/MlDeleteTrainedModelExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_trained_model(\n model_id=\"regression-job-one-1574775307356\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteTrainedModel({\n model_id: \"regression-job-one-1574775307356\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_trained_model(\n model_id: \"regression-job-one-1574775307356\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteTrainedModel([\n \"model_id\" => \"regression-job-one-1574775307356\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/regression-job-one-1574775307356\"" - }, - { - "language": "Java", - "code": "client.ml().deleteTrainedModel(d -> d\n .modelId(\"regression-job-one-1574775307356\")\n);\n" - } - ], - "specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_overall_buckets(\n job_id=\"job-*\",\n overall_score=80,\n start=\"1403532000000\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getOverallBuckets({\n job_id: \"job-*\",\n overall_score: 80,\n start: 1403532000000,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_overall_buckets(\n job_id: \"job-*\",\n body: {\n \"overall_score\": 80,\n \"start\": \"1403532000000\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getOverallBuckets([\n \"job_id\" => \"job-*\",\n \"body\" => [\n \"overall_score\" => 80,\n \"start\" => \"1403532000000\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"overall_score\":80,\"start\":\"1403532000000\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-*/results/overall_buckets\"" - }, - { - "language": "Java", - "code": "client.ml().getOverallBuckets(g -> g\n .jobId(\"job-*\")\n .overallScore(\"80\")\n .start(DateTime.of(\"1403532000000\"))\n);\n" - } - ], - "specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.preview_datafeed(\n datafeed_id=\"datafeed-high_sum_total_sales\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.previewDatafeed({\n datafeed_id: \"datafeed-high_sum_total_sales\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.preview_datafeed(\n datafeed_id: \"datafeed-high_sum_total_sales\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->previewDatafeed([\n \"datafeed_id\" => \"datafeed-high_sum_total_sales\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_preview\"" - }, - { - "language": "Java", - "code": "client.ml().previewDatafeed(p -> p\n .datafeedId(\"datafeed-high_sum_total_sales\")\n);\n" - } - ], - "specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_trained_model_vocabulary(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n vocabulary=[\n \"[PAD]\",\n \"[unused0]\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putTrainedModelVocabulary({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n vocabulary: [\"[PAD]\", \"[unused0]\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_trained_model_vocabulary(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n body: {\n \"vocabulary\": [\n \"[PAD]\",\n \"[unused0]\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putTrainedModelVocabulary([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"body\" => [\n \"vocabulary\" => array(\n \"[PAD]\",\n \"[unused0]\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"vocabulary\":[\"[PAD]\",\"[unused0]\"]}' \"$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary\"" - }, - { - "language": "Java", - "code": "client.ml().putTrainedModelVocabulary(p -> p\n .modelId(\"elastic__distilbert-base-uncased-finetuned-conll03-english\")\n .vocabulary(List.of(\"[PAD]\",\"[unused0]\"))\n);\n" - } - ], - "specification/ml/get_data_frame_analytics/examples/request/MlGetDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_data_frame_analytics(\n id=\"loganalytics\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getDataFrameAnalytics({\n id: \"loganalytics\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_data_frame_analytics(\n id: \"loganalytics\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics\"" - }, - { - "language": "Java", - "code": "client.ml().getDataFrameAnalytics(g -> g\n .id(\"loganalytics\")\n);\n" - } - ], - "specification/ml/delete_trained_model_alias/examples/request/MlDeleteTrainedModelAliasExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_trained_model_alias(\n model_id=\"flight-delay-prediction-1574775339910\",\n model_alias=\"flight_delay_model\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteTrainedModelAlias({\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_trained_model_alias(\n model_id: \"flight-delay-prediction-1574775339910\",\n model_alias: \"flight_delay_model\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteTrainedModelAlias([\n \"model_id\" => \"flight-delay-prediction-1574775339910\",\n \"model_alias\" => \"flight_delay_model\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model\"" - }, - { - "language": "Java", - "code": "client.ml().deleteTrainedModelAlias(d -> d\n .modelAlias(\"flight_delay_model\")\n .modelId(\"flight-delay-prediction-1574775339910\")\n);\n" - } - ], - "specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.revert_model_snapshot(\n job_id=\"low_request_rate\",\n snapshot_id=\"1637092688\",\n delete_intervening_results=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.revertModelSnapshot({\n job_id: \"low_request_rate\",\n snapshot_id: 1637092688,\n delete_intervening_results: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.revert_model_snapshot(\n job_id: \"low_request_rate\",\n snapshot_id: \"1637092688\",\n body: {\n \"delete_intervening_results\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->revertModelSnapshot([\n \"job_id\" => \"low_request_rate\",\n \"snapshot_id\" => \"1637092688\",\n \"body\" => [\n \"delete_intervening_results\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"delete_intervening_results\":true}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1637092688/_revert\"" - }, - { - "language": "Java", - "code": "client.ml().revertModelSnapshot(r -> r\n .deleteInterveningResults(true)\n .jobId(\"low_request_rate\")\n .snapshotId(\"1637092688\")\n);\n" - } - ], - "specification/ml/close_job/examples/request/MlCloseJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.close_job(\n job_id=\"low_request_rate\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.closeJob({\n job_id: \"low_request_rate\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.close_job(\n job_id: \"low_request_rate\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->closeJob([\n \"job_id\" => \"low_request_rate\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_close\"" - }, - { - "language": "Java", - "code": "client.ml().closeJob(c -> c\n .jobId(\"low_request_rate\")\n);\n" - } - ], - "specification/ml/put_trained_model_definition_part/examples/request/MlPutTrainedModelDefinitionPartExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_trained_model_definition_part(\n model_id=\"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part=\"0\",\n definition=\"...\",\n total_definition_length=265632637,\n total_parts=64,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putTrainedModelDefinitionPart({\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part: 0,\n definition: \"...\",\n total_definition_length: 265632637,\n total_parts: 64,\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_trained_model_definition_part(\n model_id: \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n part: \"0\",\n body: {\n \"definition\": \"...\",\n \"total_definition_length\": 265632637,\n \"total_parts\": 64\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putTrainedModelDefinitionPart([\n \"model_id\" => \"elastic__distilbert-base-uncased-finetuned-conll03-english\",\n \"part\" => \"0\",\n \"body\" => [\n \"definition\" => \"...\",\n \"total_definition_length\" => 265632637,\n \"total_parts\" => 64,\n ],\n]);" - }, - { - "language": "curl", - "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\"" - } - ], - "specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_data_frame_analytics(\n id=\"model-flight-delays-pre\",\n source={\n \"index\": [\n \"kibana_sample_data_flights\"\n ],\n \"query\": {\n \"range\": {\n \"DistanceKilometers\": {\n \"gt\": 0\n }\n }\n },\n \"_source\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightDelay\",\n \"FlightDelayType\"\n ]\n }\n },\n dest={\n \"index\": \"df-flight-delays\",\n \"results_field\": \"ml-results\"\n },\n analysis={\n \"regression\": {\n \"dependent_variable\": \"FlightDelayMin\",\n \"training_percent\": 90\n }\n },\n analyzed_fields={\n \"includes\": [],\n \"excludes\": [\n \"FlightNum\"\n ]\n },\n model_memory_limit=\"100mb\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putDataFrameAnalytics({\n id: \"model-flight-delays-pre\",\n source: {\n index: [\"kibana_sample_data_flights\"],\n query: {\n range: {\n DistanceKilometers: {\n gt: 0,\n },\n },\n },\n _source: {\n includes: [],\n excludes: [\"FlightDelay\", \"FlightDelayType\"],\n },\n },\n dest: {\n index: \"df-flight-delays\",\n results_field: \"ml-results\",\n },\n analysis: {\n regression: {\n dependent_variable: \"FlightDelayMin\",\n training_percent: 90,\n },\n },\n analyzed_fields: {\n includes: [],\n excludes: [\"FlightNum\"],\n },\n model_memory_limit: \"100mb\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_data_frame_analytics(\n id: \"model-flight-delays-pre\",\n body: {\n \"source\": {\n \"index\": [\n \"kibana_sample_data_flights\"\n ],\n \"query\": {\n \"range\": {\n \"DistanceKilometers\": {\n \"gt\": 0\n }\n }\n },\n \"_source\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightDelay\",\n \"FlightDelayType\"\n ]\n }\n },\n \"dest\": {\n \"index\": \"df-flight-delays\",\n \"results_field\": \"ml-results\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"FlightDelayMin\",\n \"training_percent\": 90\n }\n },\n \"analyzed_fields\": {\n \"includes\": [],\n \"excludes\": [\n \"FlightNum\"\n ]\n },\n \"model_memory_limit\": \"100mb\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putDataFrameAnalytics([\n \"id\" => \"model-flight-delays-pre\",\n \"body\" => [\n \"source\" => [\n \"index\" => array(\n \"kibana_sample_data_flights\",\n ),\n \"query\" => [\n \"range\" => [\n \"DistanceKilometers\" => [\n \"gt\" => 0,\n ],\n ],\n ],\n \"_source\" => [\n \"includes\" => array(\n ),\n \"excludes\" => array(\n \"FlightDelay\",\n \"FlightDelayType\",\n ),\n ],\n ],\n \"dest\" => [\n \"index\" => \"df-flight-delays\",\n \"results_field\" => \"ml-results\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"FlightDelayMin\",\n \"training_percent\" => 90,\n ],\n ],\n \"analyzed_fields\" => [\n \"includes\" => array(\n ),\n \"excludes\" => array(\n \"FlightNum\",\n ),\n ],\n \"model_memory_limit\" => \"100mb\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":[\"kibana_sample_data_flights\"],\"query\":{\"range\":{\"DistanceKilometers\":{\"gt\":0}}},\"_source\":{\"includes\":[],\"excludes\":[\"FlightDelay\",\"FlightDelayType\"]}},\"dest\":{\"index\":\"df-flight-delays\",\"results_field\":\"ml-results\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"FlightDelayMin\",\"training_percent\":90}},\"analyzed_fields\":{\"includes\":[],\"excludes\":[\"FlightNum\"]},\"model_memory_limit\":\"100mb\"}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/model-flight-delays-pre\"" - }, - { - "language": "Java", - "code": "client.ml().putDataFrameAnalytics(p -> p\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"FlightDelayMin\")\n .trainingPercent(\"90\")\n )\n )\n .analyzedFields(an -> an\n .excludes(\"FlightNum\")\n )\n .dest(d -> d\n .index(\"df-flight-delays\")\n .resultsField(\"ml-results\")\n )\n .id(\"model-flight-delays-pre\")\n .modelMemoryLimit(\"100mb\")\n .source(s -> s\n .index(\"kibana_sample_data_flights\")\n .query(q -> q\n .range(r -> r\n .untyped(u -> u\n .field(\"DistanceKilometers\")\n .gt(JsonData.fromJson(\"0\"))\n )\n )\n )\n .source(so -> so\n .excludes(List.of(\"FlightDelay\",\"FlightDelayType\"))\n )\n )\n);\n" - } - ], - "specification/ml/delete_data_frame_analytics/examples/request/MlDeleteDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.delete_data_frame_analytics(\n id=\"loganalytics\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.deleteDataFrameAnalytics({\n id: \"loganalytics\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.delete_data_frame_analytics(\n id: \"loganalytics\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->deleteDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics\"" - }, - { - "language": "Java", - "code": "client.ml().deleteDataFrameAnalytics(d -> d\n .id(\"loganalytics\")\n);\n" - } - ], - "specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.preview_data_frame_analytics(\n config={\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.previewDataFrameAnalytics({\n config: {\n source: {\n index: \"houses_sold_last_10_yrs\",\n },\n analysis: {\n regression: {\n dependent_variable: \"price\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.preview_data_frame_analytics(\n body: {\n \"config\": {\n \"source\": {\n \"index\": \"houses_sold_last_10_yrs\"\n },\n \"analysis\": {\n \"regression\": {\n \"dependent_variable\": \"price\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->previewDataFrameAnalytics([\n \"body\" => [\n \"config\" => [\n \"source\" => [\n \"index\" => \"houses_sold_last_10_yrs\",\n ],\n \"analysis\" => [\n \"regression\" => [\n \"dependent_variable\" => \"price\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"config\":{\"source\":{\"index\":\"houses_sold_last_10_yrs\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"price\"}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/_preview\"" - }, - { - "language": "Java", - "code": "client.ml().previewDataFrameAnalytics(p -> p\n .config(c -> c\n .source(s -> s\n .index(\"houses_sold_last_10_yrs\")\n )\n .analysis(a -> a\n .regression(r -> r\n .dependentVariable(\"price\")\n )\n )\n )\n);\n" - } - ], - "specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.put_filter(\n filter_id=\"safe_domains\",\n description=\"A list of safe domains\",\n items=[\n \"*.google.com\",\n \"wikipedia.org\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.putFilter({\n filter_id: \"safe_domains\",\n description: \"A list of safe domains\",\n items: [\"*.google.com\", \"wikipedia.org\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.put_filter(\n filter_id: \"safe_domains\",\n body: {\n \"description\": \"A list of safe domains\",\n \"items\": [\n \"*.google.com\",\n \"wikipedia.org\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->putFilter([\n \"filter_id\" => \"safe_domains\",\n \"body\" => [\n \"description\" => \"A list of safe domains\",\n \"items\" => array(\n \"*.google.com\",\n \"wikipedia.org\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"description\":\"A list of safe domains\",\"items\":[\"*.google.com\",\"wikipedia.org\"]}' \"$ELASTICSEARCH_URL/_ml/filters/safe_domains\"" - }, - { - "language": "Java", - "code": "client.ml().putFilter(p -> p\n .description(\"A list of safe domains\")\n .filterId(\"safe_domains\")\n .items(List.of(\"*.google.com\",\"wikipedia.org\"))\n);\n" - } - ], - "specification/ml/start_data_frame_analytics/examples/request/MlStartDataFrameAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.start_data_frame_analytics(\n id=\"loganalytics\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.startDataFrameAnalytics({\n id: \"loganalytics\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.start_data_frame_analytics(\n id: \"loganalytics\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->startDataFrameAnalytics([\n \"id\" => \"loganalytics\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_start\"" - }, - { - "language": "Java", - "code": "client.ml().startDataFrameAnalytics(s -> s\n .id(\"loganalytics\")\n);\n" - } - ], - "specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_calendars(\n calendar_id=\"planned-outages\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getCalendars({\n calendar_id: \"planned-outages\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_calendars(\n calendar_id: \"planned-outages\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getCalendars([\n \"calendar_id\" => \"planned-outages\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/calendars/planned-outages\"" - }, - { - "language": "Java", - "code": "client.ml().getCalendars(g -> g\n .calendarId(\"planned-outages\")\n);\n" - } - ], - "specification/ml/get_job_stats/examples/request/MlGetJobStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.get_job_stats(\n job_id=\"low_request_rate\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.getJobStats({\n job_id: \"low_request_rate\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.get_job_stats(\n job_id: \"low_request_rate\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->getJobStats([\n \"job_id\" => \"low_request_rate\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_stats\"" - }, - { - "language": "Java", - "code": "client.ml().getJobStats(g -> g\n .jobId(\"low_request_rate\")\n);\n" - } - ], - "specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ml.open_job(\n job_id=\"job-01\",\n timeout=\"35m\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ml.openJob({\n job_id: \"job-01\",\n timeout: \"35m\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ml.open_job(\n job_id: \"job-01\",\n body: {\n \"timeout\": \"35m\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ml()->openJob([\n \"job_id\" => \"job-01\",\n \"body\" => [\n \"timeout\" => \"35m\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"timeout\":\"35m\"}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01/_open\"" - }, - { - "language": "Java", - "code": "client.ml().openJob(o -> o\n .jobId(\"job-01\")\n .timeout(t -> t\n .time(\"35m\")\n )\n);\n" - } - ], - "specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.text_structure.test_grok_pattern(\n grok_pattern=\"Hello %{WORD:first_name} %{WORD:last_name}\",\n text=[\n \"Hello John Doe\",\n \"this does not match\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.textStructure.testGrokPattern({\n grok_pattern: \"Hello %{WORD:first_name} %{WORD:last_name}\",\n text: [\"Hello John Doe\", \"this does not match\"],\n});" - }, - { - "language": "Ruby", - "code": "response = client.text_structure.test_grok_pattern(\n body: {\n \"grok_pattern\": \"Hello %{WORD:first_name} %{WORD:last_name}\",\n \"text\": [\n \"Hello John Doe\",\n \"this does not match\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->textStructure()->testGrokPattern([\n \"body\" => [\n \"grok_pattern\" => \"Hello %{WORD:first_name} %{WORD:last_name}\",\n \"text\" => array(\n \"Hello John Doe\",\n \"this does not match\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grok_pattern\":\"Hello %{WORD:first_name} %{WORD:last_name}\",\"text\":[\"Hello John Doe\",\"this does not match\"]}' \"$ELASTICSEARCH_URL/_text_structure/test_grok_pattern\"" - }, - { - "language": "Java", - "code": "client.textStructure().testGrokPattern(t -> t\n .grokPattern(\"Hello %{WORD:first_name} %{WORD:last_name}\")\n .text(List.of(\"Hello John Doe\",\"this does not match\"))\n);\n" - } - ], - "specification/text_structure/find_structure/examples/request/FindStructureRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.text_structure.find_structure(\n text_files=[\n {\n \"name\": \"Leviathan Wakes\",\n \"author\": \"James S.A. Corey\",\n \"release_date\": \"2011-06-02\",\n \"page_count\": 561\n },\n {\n \"name\": \"Hyperion\",\n \"author\": \"Dan Simmons\",\n \"release_date\": \"1989-05-26\",\n \"page_count\": 482\n },\n {\n \"name\": \"Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1965-06-01\",\n \"page_count\": 604\n },\n {\n \"name\": \"Dune Messiah\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1969-10-15\",\n \"page_count\": 331\n },\n {\n \"name\": \"Children of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1976-04-21\",\n \"page_count\": 408\n },\n {\n \"name\": \"God Emperor of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1981-05-28\",\n \"page_count\": 454\n },\n {\n \"name\": \"Consider Phlebas\",\n \"author\": \"Iain M. Banks\",\n \"release_date\": \"1987-04-23\",\n \"page_count\": 471\n },\n {\n \"name\": \"Pandora's Star\",\n \"author\": \"Peter F. Hamilton\",\n \"release_date\": \"2004-03-02\",\n \"page_count\": 768\n },\n {\n \"name\": \"Revelation Space\",\n \"author\": \"Alastair Reynolds\",\n \"release_date\": \"2000-03-15\",\n \"page_count\": 585\n },\n {\n \"name\": \"A Fire Upon the Deep\",\n \"author\": \"Vernor Vinge\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 613\n },\n {\n \"name\": \"Ender's Game\",\n \"author\": \"Orson Scott Card\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 324\n },\n {\n \"name\": \"1984\",\n \"author\": \"George Orwell\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 328\n },\n {\n \"name\": \"Fahrenheit 451\",\n \"author\": \"Ray Bradbury\",\n \"release_date\": \"1953-10-15\",\n \"page_count\": 227\n },\n {\n \"name\": \"Brave New World\",\n \"author\": \"Aldous Huxley\",\n \"release_date\": \"1932-06-01\",\n \"page_count\": 268\n },\n {\n \"name\": \"Foundation\",\n \"author\": \"Isaac Asimov\",\n \"release_date\": \"1951-06-01\",\n \"page_count\": 224\n },\n {\n \"name\": \"The Giver\",\n \"author\": \"Lois Lowry\",\n \"release_date\": \"1993-04-26\",\n \"page_count\": 208\n },\n {\n \"name\": \"Slaughterhouse-Five\",\n \"author\": \"Kurt Vonnegut\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 275\n },\n {\n \"name\": \"The Hitchhiker's Guide to the Galaxy\",\n \"author\": \"Douglas Adams\",\n \"release_date\": \"1979-10-12\",\n \"page_count\": 180\n },\n {\n \"name\": \"Snow Crash\",\n \"author\": \"Neal Stephenson\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 470\n },\n {\n \"name\": \"Neuromancer\",\n \"author\": \"William Gibson\",\n \"release_date\": \"1984-07-01\",\n \"page_count\": 271\n },\n {\n \"name\": \"The Handmaid's Tale\",\n \"author\": \"Margaret Atwood\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 311\n },\n {\n \"name\": \"Starship Troopers\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1959-12-01\",\n \"page_count\": 335\n },\n {\n \"name\": \"The Left Hand of Darkness\",\n \"author\": \"Ursula K. Le Guin\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 304\n },\n {\n \"name\": \"The Moon is a Harsh Mistress\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1966-04-01\",\n \"page_count\": 288\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.textStructure.findStructure({\n text_files: [\n {\n name: \"Leviathan Wakes\",\n author: \"James S.A. Corey\",\n release_date: \"2011-06-02\",\n page_count: 561,\n },\n {\n name: \"Hyperion\",\n author: \"Dan Simmons\",\n release_date: \"1989-05-26\",\n page_count: 482,\n },\n {\n name: \"Dune\",\n author: \"Frank Herbert\",\n release_date: \"1965-06-01\",\n page_count: 604,\n },\n {\n name: \"Dune Messiah\",\n author: \"Frank Herbert\",\n release_date: \"1969-10-15\",\n page_count: 331,\n },\n {\n name: \"Children of Dune\",\n author: \"Frank Herbert\",\n release_date: \"1976-04-21\",\n page_count: 408,\n },\n {\n name: \"God Emperor of Dune\",\n author: \"Frank Herbert\",\n release_date: \"1981-05-28\",\n page_count: 454,\n },\n {\n name: \"Consider Phlebas\",\n author: \"Iain M. Banks\",\n release_date: \"1987-04-23\",\n page_count: 471,\n },\n {\n name: \"Pandora's Star\",\n author: \"Peter F. Hamilton\",\n release_date: \"2004-03-02\",\n page_count: 768,\n },\n {\n name: \"Revelation Space\",\n author: \"Alastair Reynolds\",\n release_date: \"2000-03-15\",\n page_count: 585,\n },\n {\n name: \"A Fire Upon the Deep\",\n author: \"Vernor Vinge\",\n release_date: \"1992-06-01\",\n page_count: 613,\n },\n {\n name: \"Ender's Game\",\n author: \"Orson Scott Card\",\n release_date: \"1985-06-01\",\n page_count: 324,\n },\n {\n name: \"1984\",\n author: \"George Orwell\",\n release_date: \"1985-06-01\",\n page_count: 328,\n },\n {\n name: \"Fahrenheit 451\",\n author: \"Ray Bradbury\",\n release_date: \"1953-10-15\",\n page_count: 227,\n },\n {\n name: \"Brave New World\",\n author: \"Aldous Huxley\",\n release_date: \"1932-06-01\",\n page_count: 268,\n },\n {\n name: \"Foundation\",\n author: \"Isaac Asimov\",\n release_date: \"1951-06-01\",\n page_count: 224,\n },\n {\n name: \"The Giver\",\n author: \"Lois Lowry\",\n release_date: \"1993-04-26\",\n page_count: 208,\n },\n {\n name: \"Slaughterhouse-Five\",\n author: \"Kurt Vonnegut\",\n release_date: \"1969-06-01\",\n page_count: 275,\n },\n {\n name: \"The Hitchhiker's Guide to the Galaxy\",\n author: \"Douglas Adams\",\n release_date: \"1979-10-12\",\n page_count: 180,\n },\n {\n name: \"Snow Crash\",\n author: \"Neal Stephenson\",\n release_date: \"1992-06-01\",\n page_count: 470,\n },\n {\n name: \"Neuromancer\",\n author: \"William Gibson\",\n release_date: \"1984-07-01\",\n page_count: 271,\n },\n {\n name: \"The Handmaid's Tale\",\n author: \"Margaret Atwood\",\n release_date: \"1985-06-01\",\n page_count: 311,\n },\n {\n name: \"Starship Troopers\",\n author: \"Robert A. Heinlein\",\n release_date: \"1959-12-01\",\n page_count: 335,\n },\n {\n name: \"The Left Hand of Darkness\",\n author: \"Ursula K. Le Guin\",\n release_date: \"1969-06-01\",\n page_count: 304,\n },\n {\n name: \"The Moon is a Harsh Mistress\",\n author: \"Robert A. Heinlein\",\n release_date: \"1966-04-01\",\n page_count: 288,\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.text_structure.find_structure(\n body: [\n {\n \"name\": \"Leviathan Wakes\",\n \"author\": \"James S.A. Corey\",\n \"release_date\": \"2011-06-02\",\n \"page_count\": 561\n },\n {\n \"name\": \"Hyperion\",\n \"author\": \"Dan Simmons\",\n \"release_date\": \"1989-05-26\",\n \"page_count\": 482\n },\n {\n \"name\": \"Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1965-06-01\",\n \"page_count\": 604\n },\n {\n \"name\": \"Dune Messiah\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1969-10-15\",\n \"page_count\": 331\n },\n {\n \"name\": \"Children of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1976-04-21\",\n \"page_count\": 408\n },\n {\n \"name\": \"God Emperor of Dune\",\n \"author\": \"Frank Herbert\",\n \"release_date\": \"1981-05-28\",\n \"page_count\": 454\n },\n {\n \"name\": \"Consider Phlebas\",\n \"author\": \"Iain M. Banks\",\n \"release_date\": \"1987-04-23\",\n \"page_count\": 471\n },\n {\n \"name\": \"Pandora's Star\",\n \"author\": \"Peter F. Hamilton\",\n \"release_date\": \"2004-03-02\",\n \"page_count\": 768\n },\n {\n \"name\": \"Revelation Space\",\n \"author\": \"Alastair Reynolds\",\n \"release_date\": \"2000-03-15\",\n \"page_count\": 585\n },\n {\n \"name\": \"A Fire Upon the Deep\",\n \"author\": \"Vernor Vinge\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 613\n },\n {\n \"name\": \"Ender's Game\",\n \"author\": \"Orson Scott Card\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 324\n },\n {\n \"name\": \"1984\",\n \"author\": \"George Orwell\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 328\n },\n {\n \"name\": \"Fahrenheit 451\",\n \"author\": \"Ray Bradbury\",\n \"release_date\": \"1953-10-15\",\n \"page_count\": 227\n },\n {\n \"name\": \"Brave New World\",\n \"author\": \"Aldous Huxley\",\n \"release_date\": \"1932-06-01\",\n \"page_count\": 268\n },\n {\n \"name\": \"Foundation\",\n \"author\": \"Isaac Asimov\",\n \"release_date\": \"1951-06-01\",\n \"page_count\": 224\n },\n {\n \"name\": \"The Giver\",\n \"author\": \"Lois Lowry\",\n \"release_date\": \"1993-04-26\",\n \"page_count\": 208\n },\n {\n \"name\": \"Slaughterhouse-Five\",\n \"author\": \"Kurt Vonnegut\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 275\n },\n {\n \"name\": \"The Hitchhiker's Guide to the Galaxy\",\n \"author\": \"Douglas Adams\",\n \"release_date\": \"1979-10-12\",\n \"page_count\": 180\n },\n {\n \"name\": \"Snow Crash\",\n \"author\": \"Neal Stephenson\",\n \"release_date\": \"1992-06-01\",\n \"page_count\": 470\n },\n {\n \"name\": \"Neuromancer\",\n \"author\": \"William Gibson\",\n \"release_date\": \"1984-07-01\",\n \"page_count\": 271\n },\n {\n \"name\": \"The Handmaid's Tale\",\n \"author\": \"Margaret Atwood\",\n \"release_date\": \"1985-06-01\",\n \"page_count\": 311\n },\n {\n \"name\": \"Starship Troopers\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1959-12-01\",\n \"page_count\": 335\n },\n {\n \"name\": \"The Left Hand of Darkness\",\n \"author\": \"Ursula K. Le Guin\",\n \"release_date\": \"1969-06-01\",\n \"page_count\": 304\n },\n {\n \"name\": \"The Moon is a Harsh Mistress\",\n \"author\": \"Robert A. Heinlein\",\n \"release_date\": \"1966-04-01\",\n \"page_count\": 288\n }\n ]\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->textStructure()->findStructure([\n \"body\" => array(\n [\n \"name\" => \"Leviathan Wakes\",\n \"author\" => \"James S.A. Corey\",\n \"release_date\" => \"2011-06-02\",\n \"page_count\" => 561,\n ],\n [\n \"name\" => \"Hyperion\",\n \"author\" => \"Dan Simmons\",\n \"release_date\" => \"1989-05-26\",\n \"page_count\" => 482,\n ],\n [\n \"name\" => \"Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1965-06-01\",\n \"page_count\" => 604,\n ],\n [\n \"name\" => \"Dune Messiah\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1969-10-15\",\n \"page_count\" => 331,\n ],\n [\n \"name\" => \"Children of Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1976-04-21\",\n \"page_count\" => 408,\n ],\n [\n \"name\" => \"God Emperor of Dune\",\n \"author\" => \"Frank Herbert\",\n \"release_date\" => \"1981-05-28\",\n \"page_count\" => 454,\n ],\n [\n \"name\" => \"Consider Phlebas\",\n \"author\" => \"Iain M. Banks\",\n \"release_date\" => \"1987-04-23\",\n \"page_count\" => 471,\n ],\n [\n \"name\" => \"Pandora's Star\",\n \"author\" => \"Peter F. Hamilton\",\n \"release_date\" => \"2004-03-02\",\n \"page_count\" => 768,\n ],\n [\n \"name\" => \"Revelation Space\",\n \"author\" => \"Alastair Reynolds\",\n \"release_date\" => \"2000-03-15\",\n \"page_count\" => 585,\n ],\n [\n \"name\" => \"A Fire Upon the Deep\",\n \"author\" => \"Vernor Vinge\",\n \"release_date\" => \"1992-06-01\",\n \"page_count\" => 613,\n ],\n [\n \"name\" => \"Ender's Game\",\n \"author\" => \"Orson Scott Card\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 324,\n ],\n [\n \"name\" => \"1984\",\n \"author\" => \"George Orwell\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 328,\n ],\n [\n \"name\" => \"Fahrenheit 451\",\n \"author\" => \"Ray Bradbury\",\n \"release_date\" => \"1953-10-15\",\n \"page_count\" => 227,\n ],\n [\n \"name\" => \"Brave New World\",\n \"author\" => \"Aldous Huxley\",\n \"release_date\" => \"1932-06-01\",\n \"page_count\" => 268,\n ],\n [\n \"name\" => \"Foundation\",\n \"author\" => \"Isaac Asimov\",\n \"release_date\" => \"1951-06-01\",\n \"page_count\" => 224,\n ],\n [\n \"name\" => \"The Giver\",\n \"author\" => \"Lois Lowry\",\n \"release_date\" => \"1993-04-26\",\n \"page_count\" => 208,\n ],\n [\n \"name\" => \"Slaughterhouse-Five\",\n \"author\" => \"Kurt Vonnegut\",\n \"release_date\" => \"1969-06-01\",\n \"page_count\" => 275,\n ],\n [\n \"name\" => \"The Hitchhiker's Guide to the Galaxy\",\n \"author\" => \"Douglas Adams\",\n \"release_date\" => \"1979-10-12\",\n \"page_count\" => 180,\n ],\n [\n \"name\" => \"Snow Crash\",\n \"author\" => \"Neal Stephenson\",\n \"release_date\" => \"1992-06-01\",\n \"page_count\" => 470,\n ],\n [\n \"name\" => \"Neuromancer\",\n \"author\" => \"William Gibson\",\n \"release_date\" => \"1984-07-01\",\n \"page_count\" => 271,\n ],\n [\n \"name\" => \"The Handmaid's Tale\",\n \"author\" => \"Margaret Atwood\",\n \"release_date\" => \"1985-06-01\",\n \"page_count\" => 311,\n ],\n [\n \"name\" => \"Starship Troopers\",\n \"author\" => \"Robert A. Heinlein\",\n \"release_date\" => \"1959-12-01\",\n \"page_count\" => 335,\n ],\n [\n \"name\" => \"The Left Hand of Darkness\",\n \"author\" => \"Ursula K. Le Guin\",\n \"release_date\" => \"1969-06-01\",\n \"page_count\" => 304,\n ],\n [\n \"name\" => \"The Moon is a Harsh Mistress\",\n \"author\" => \"Robert A. Heinlein\",\n \"release_date\" => \"1966-04-01\",\n \"page_count\" => 288,\n ],\n ),\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '[{\"name\":\"Leviathan Wakes\",\"author\":\"James S.A. Corey\",\"release_date\":\"2011-06-02\",\"page_count\":561},{\"name\":\"Hyperion\",\"author\":\"Dan Simmons\",\"release_date\":\"1989-05-26\",\"page_count\":482},{\"name\":\"Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1965-06-01\",\"page_count\":604},{\"name\":\"Dune Messiah\",\"author\":\"Frank Herbert\",\"release_date\":\"1969-10-15\",\"page_count\":331},{\"name\":\"Children of Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1976-04-21\",\"page_count\":408},{\"name\":\"God Emperor of Dune\",\"author\":\"Frank Herbert\",\"release_date\":\"1981-05-28\",\"page_count\":454},{\"name\":\"Consider Phlebas\",\"author\":\"Iain M. Banks\",\"release_date\":\"1987-04-23\",\"page_count\":471},{\"name\":\"Pandora'\"'\"'s Star\",\"author\":\"Peter F. Hamilton\",\"release_date\":\"2004-03-02\",\"page_count\":768},{\"name\":\"Revelation Space\",\"author\":\"Alastair Reynolds\",\"release_date\":\"2000-03-15\",\"page_count\":585},{\"name\":\"A Fire Upon the Deep\",\"author\":\"Vernor Vinge\",\"release_date\":\"1992-06-01\",\"page_count\":613},{\"name\":\"Ender'\"'\"'s Game\",\"author\":\"Orson Scott Card\",\"release_date\":\"1985-06-01\",\"page_count\":324},{\"name\":\"1984\",\"author\":\"George Orwell\",\"release_date\":\"1985-06-01\",\"page_count\":328},{\"name\":\"Fahrenheit 451\",\"author\":\"Ray Bradbury\",\"release_date\":\"1953-10-15\",\"page_count\":227},{\"name\":\"Brave New World\",\"author\":\"Aldous Huxley\",\"release_date\":\"1932-06-01\",\"page_count\":268},{\"name\":\"Foundation\",\"author\":\"Isaac Asimov\",\"release_date\":\"1951-06-01\",\"page_count\":224},{\"name\":\"The Giver\",\"author\":\"Lois Lowry\",\"release_date\":\"1993-04-26\",\"page_count\":208},{\"name\":\"Slaughterhouse-Five\",\"author\":\"Kurt Vonnegut\",\"release_date\":\"1969-06-01\",\"page_count\":275},{\"name\":\"The Hitchhiker'\"'\"'s Guide to the Galaxy\",\"author\":\"Douglas Adams\",\"release_date\":\"1979-10-12\",\"page_count\":180},{\"name\":\"Snow Crash\",\"author\":\"Neal Stephenson\",\"release_date\":\"1992-06-01\",\"page_count\":470},{\"name\":\"Neuromancer\",\"author\":\"William Gibson\",\"release_date\":\"1984-07-01\",\"page_count\":271},{\"name\":\"The Handmaid'\"'\"'s Tale\",\"author\":\"Margaret Atwood\",\"release_date\":\"1985-06-01\",\"page_count\":311},{\"name\":\"Starship Troopers\",\"author\":\"Robert A. Heinlein\",\"release_date\":\"1959-12-01\",\"page_count\":335},{\"name\":\"The Left Hand of Darkness\",\"author\":\"Ursula K. Le Guin\",\"release_date\":\"1969-06-01\",\"page_count\":304},{\"name\":\"The Moon is a Harsh Mistress\",\"author\":\"Robert A. Heinlein\",\"release_date\":\"1966-04-01\",\"page_count\":288}]' \"$ELASTICSEARCH_URL/_text_structure/find_structure\"" - } - ], - "specification/text_structure/find_field_structure/examples/request/FindFieldStructureRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.text_structure.find_field_structure(\n index=\"test-logs\",\n field=\"message\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.textStructure.findFieldStructure({\n index: \"test-logs\",\n field: \"message\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.text_structure.find_field_structure(\n index: \"test-logs\",\n field: \"message\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->textStructure()->findFieldStructure([\n \"index\" => \"test-logs\",\n \"field\" => \"message\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_text_structure/find_field_structure?index=test-logs&field=message\"" - }, - { - "language": "Java", - "code": "client.textStructure().findFieldStructure(f -> f\n .field(\"message\")\n .index(\"test-logs\")\n);\n" - } - ], - "specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.text_structure.find_message_structure(\n messages=[\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.textStructure.findMessageStructure({\n messages: [\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\",\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.text_structure.find_message_structure(\n body: {\n \"messages\": [\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->textStructure()->findMessageStructure([\n \"body\" => [\n \"messages\" => array(\n \"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\n \"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\n \"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\n \"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\n \"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\n \"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\n \"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\n \"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\n \"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\n \"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\n \"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\n \"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\n \"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\n \"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\",\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[\"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"]}' \"$ELASTICSEARCH_URL/_text_structure/find_message_structure\"" - }, - { - "language": "Java", - "code": "client.textStructure().findMessageStructure(f -> f\n .messages(List.of(\"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\",\"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\",\"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]\",\"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]\",\"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]\",\"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]\",\"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]\",\"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled\",\"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled\",\"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled\",\"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]\",\"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]\",\"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized\",\"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...\"))\n);\n" - } - ], - "specification/rollup/get_rollup_index_caps/examples/request/GetRollupIndexCapabilitiesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.get_rollup_index_caps(\n index=\"sensor_rollup\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.getRollupIndexCaps({\n index: \"sensor_rollup\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.get_rollup_index_caps(\n index: \"sensor_rollup\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->getRollupIndexCaps([\n \"index\" => \"sensor_rollup\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/sensor_rollup/_rollup/data\"" - }, - { - "language": "Java", - "code": "client.rollup().getRollupIndexCaps(g -> g\n .index(\"sensor_rollup\")\n);\n" - } - ], - "specification/rollup/get_jobs/examples/request/GetRollupJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.get_jobs(\n id=\"sensor\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.getJobs({\n id: \"sensor\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.get_jobs(\n id: \"sensor\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->getJobs([\n \"id\" => \"sensor\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" - }, - { - "language": "Java", - "code": "client.rollup().getJobs(g -> g\n .id(\"sensor\")\n);\n" - } - ], - "specification/rollup/stop_job/examples/request/RollupStopJobExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.stop_job(\n id=\"sensor\",\n wait_for_completion=True,\n timeout=\"10s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.stopJob({\n id: \"sensor\",\n wait_for_completion: \"true\",\n timeout: \"10s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.stop_job(\n id: \"sensor\",\n wait_for_completion: \"true\",\n timeout: \"10s\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->stopJob([\n \"id\" => \"sensor\",\n \"wait_for_completion\" => \"true\",\n \"timeout\" => \"10s\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor/_stop?wait_for_completion=true&timeout=10s\"" - }, - { - "language": "Java", - "code": "client.rollup().stopJob(s -> s\n .id(\"sensor\")\n .timeout(t -> t\n .offset(10)\n )\n .waitForCompletion(true)\n);\n" - } - ], - "specification/rollup/get_rollup_caps/examples/request/GetRollupCapabilitiesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.get_rollup_caps(\n id=\"sensor-*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.getRollupCaps({\n id: \"sensor-*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.get_rollup_caps(\n id: \"sensor-*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->getRollupCaps([\n \"id\" => \"sensor-*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/data/sensor-*\"" - }, - { - "language": "Java", - "code": "client.rollup().getRollupCaps(g -> g\n .id(\"sensor-*\")\n);\n" - } - ], - "specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.rollup_search(\n index=\"sensor_rollup\",\n size=0,\n aggregations={\n \"max_temperature\": {\n \"max\": {\n \"field\": \"temperature\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.rollupSearch({\n index: \"sensor_rollup\",\n size: 0,\n aggregations: {\n max_temperature: {\n max: {\n field: \"temperature\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.rollup_search(\n index: \"sensor_rollup\",\n body: {\n \"size\": 0,\n \"aggregations\": {\n \"max_temperature\": {\n \"max\": {\n \"field\": \"temperature\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->rollupSearch([\n \"index\" => \"sensor_rollup\",\n \"body\" => [\n \"size\" => 0,\n \"aggregations\" => [\n \"max_temperature\" => [\n \"max\" => [\n \"field\" => \"temperature\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"size\":0,\"aggregations\":{\"max_temperature\":{\"max\":{\"field\":\"temperature\"}}}}' \"$ELASTICSEARCH_URL/sensor_rollup/_rollup_search\"" - }, - { - "language": "Java", - "code": "client.rollup().rollupSearch(r -> r\n .aggregations(\"max_temperature\", a -> a\n .max(m -> m\n .field(\"temperature\")\n )\n )\n .index(\"sensor_rollup\")\n .size(0)\n);\n" - } - ], - "specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.put_job(\n id=\"sensor\",\n index_pattern=\"sensor-*\",\n rollup_index=\"sensor_rollup\",\n cron=\"*/30 * * * * ?\",\n page_size=1000,\n groups={\n \"date_histogram\": {\n \"field\": \"timestamp\",\n \"fixed_interval\": \"1h\",\n \"delay\": \"7d\"\n },\n \"terms\": {\n \"fields\": [\n \"node\"\n ]\n }\n },\n metrics=[\n {\n \"field\": \"temperature\",\n \"metrics\": [\n \"min\",\n \"max\",\n \"sum\"\n ]\n },\n {\n \"field\": \"voltage\",\n \"metrics\": [\n \"avg\"\n ]\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.putJob({\n id: \"sensor\",\n index_pattern: \"sensor-*\",\n rollup_index: \"sensor_rollup\",\n cron: \"*/30 * * * * ?\",\n page_size: 1000,\n groups: {\n date_histogram: {\n field: \"timestamp\",\n fixed_interval: \"1h\",\n delay: \"7d\",\n },\n terms: {\n fields: [\"node\"],\n },\n },\n metrics: [\n {\n field: \"temperature\",\n metrics: [\"min\", \"max\", \"sum\"],\n },\n {\n field: \"voltage\",\n metrics: [\"avg\"],\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.put_job(\n id: \"sensor\",\n body: {\n \"index_pattern\": \"sensor-*\",\n \"rollup_index\": \"sensor_rollup\",\n \"cron\": \"*/30 * * * * ?\",\n \"page_size\": 1000,\n \"groups\": {\n \"date_histogram\": {\n \"field\": \"timestamp\",\n \"fixed_interval\": \"1h\",\n \"delay\": \"7d\"\n },\n \"terms\": {\n \"fields\": [\n \"node\"\n ]\n }\n },\n \"metrics\": [\n {\n \"field\": \"temperature\",\n \"metrics\": [\n \"min\",\n \"max\",\n \"sum\"\n ]\n },\n {\n \"field\": \"voltage\",\n \"metrics\": [\n \"avg\"\n ]\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->putJob([\n \"id\" => \"sensor\",\n \"body\" => [\n \"index_pattern\" => \"sensor-*\",\n \"rollup_index\" => \"sensor_rollup\",\n \"cron\" => \"*/30 * * * * ?\",\n \"page_size\" => 1000,\n \"groups\" => [\n \"date_histogram\" => [\n \"field\" => \"timestamp\",\n \"fixed_interval\" => \"1h\",\n \"delay\" => \"7d\",\n ],\n \"terms\" => [\n \"fields\" => array(\n \"node\",\n ),\n ],\n ],\n \"metrics\" => array(\n [\n \"field\" => \"temperature\",\n \"metrics\" => array(\n \"min\",\n \"max\",\n \"sum\",\n ),\n ],\n [\n \"field\" => \"voltage\",\n \"metrics\" => array(\n \"avg\",\n ),\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_pattern\":\"sensor-*\",\"rollup_index\":\"sensor_rollup\",\"cron\":\"*/30 * * * * ?\",\"page_size\":1000,\"groups\":{\"date_histogram\":{\"field\":\"timestamp\",\"fixed_interval\":\"1h\",\"delay\":\"7d\"},\"terms\":{\"fields\":[\"node\"]}},\"metrics\":[{\"field\":\"temperature\",\"metrics\":[\"min\",\"max\",\"sum\"]},{\"field\":\"voltage\",\"metrics\":[\"avg\"]}]}' \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" - }, - { - "language": "Java", - "code": "client.rollup().putJob(p -> p\n .cron(\"*/30 * * * * ?\")\n .groups(g -> g\n .dateHistogram(d -> d\n .delay(de -> de\n .time(\"7d\")\n )\n .field(\"timestamp\")\n .fixedInterval(f -> f\n .time(\"1h\")\n )\n )\n .terms(t -> t\n .fields(\"node\")\n )\n )\n .id(\"sensor\")\n .indexPattern(\"sensor-*\")\n .metrics(List.of(FieldMetric.of(f -> f\n .field(\"temperature\")\n .metrics(List.of(Metric.Min,Metric.Max,Metric.Sum))),FieldMetric.of(f -> f\n .field(\"voltage\")\n .metrics(Metric.Avg))))\n .pageSize(1000)\n .rollupIndex(\"sensor_rollup\")\n);\n" - } - ], - "specification/rollup/delete_job/examples/request/DeleteRollupJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.delete_job(\n id=\"sensor\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.deleteJob({\n id: \"sensor\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.delete_job(\n id: \"sensor\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->deleteJob([\n \"id\" => \"sensor\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" - }, - { - "language": "Java", - "code": "client.rollup().deleteJob(d -> d\n .id(\"sensor\")\n);\n" - } - ], - "specification/rollup/start_job/examples/request/StartRollupJobRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.rollup.start_job(\n id=\"sensor\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.rollup.startJob({\n id: \"sensor\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.rollup.start_job(\n id: \"sensor\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->rollup()->startJob([\n \"id\" => \"sensor\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_rollup/job/sensor/_start\"" - }, - { - "language": "Java", - "code": "client.rollup().startJob(s -> s\n .id(\"sensor\")\n);\n" - } - ], - "specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_service_type(\n connector_id=\"my-connector\",\n service_type=\"sharepoint_online\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateServiceType({\n connector_id: \"my-connector\",\n service_type: \"sharepoint_online\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_service_type(\n connector_id: \"my-connector\",\n body: {\n \"service_type\": \"sharepoint_online\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateServiceType([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"service_type\" => \"sharepoint_online\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service_type\":\"sharepoint_online\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_service_type\"" - }, - { - "language": "Java", - "code": "client.connector().updateServiceType(u -> u\n .connectorId(\"my-connector\")\n .serviceType(\"sharepoint_online\")\n);\n" - } - ], - "specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_scheduling(\n connector_id=\"my-connector\",\n scheduling={\n \"full\": {\n \"enabled\": True,\n \"interval\": \"0 10 0 * * ?\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateScheduling({\n connector_id: \"my-connector\",\n scheduling: {\n full: {\n enabled: true,\n interval: \"0 10 0 * * ?\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_scheduling(\n connector_id: \"my-connector\",\n body: {\n \"scheduling\": {\n \"full\": {\n \"enabled\": true,\n \"interval\": \"0 10 0 * * ?\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateScheduling([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"scheduling\" => [\n \"full\" => [\n \"enabled\" => true,\n \"interval\" => \"0 10 0 * * ?\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scheduling\":{\"full\":{\"enabled\":true,\"interval\":\"0 10 0 * * ?\"}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_scheduling\"" - }, - { - "language": "Java", - "code": "client.connector().updateScheduling(u -> u\n .connectorId(\"my-connector\")\n .scheduling(s -> s\n .full(f -> f\n .enabled(true)\n .interval(\"0 10 0 * * ?\")\n )\n )\n);\n" - } - ], - "specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_scheduling(\n connector_id=\"my-connector\",\n scheduling={\n \"access_control\": {\n \"enabled\": True,\n \"interval\": \"0 10 0 * * ?\"\n },\n \"full\": {\n \"enabled\": True,\n \"interval\": \"0 20 0 * * ?\"\n },\n \"incremental\": {\n \"enabled\": False,\n \"interval\": \"0 30 0 * * ?\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateScheduling({\n connector_id: \"my-connector\",\n scheduling: {\n access_control: {\n enabled: true,\n interval: \"0 10 0 * * ?\",\n },\n full: {\n enabled: true,\n interval: \"0 20 0 * * ?\",\n },\n incremental: {\n enabled: false,\n interval: \"0 30 0 * * ?\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_scheduling(\n connector_id: \"my-connector\",\n body: {\n \"scheduling\": {\n \"access_control\": {\n \"enabled\": true,\n \"interval\": \"0 10 0 * * ?\"\n },\n \"full\": {\n \"enabled\": true,\n \"interval\": \"0 20 0 * * ?\"\n },\n \"incremental\": {\n \"enabled\": false,\n \"interval\": \"0 30 0 * * ?\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateScheduling([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"scheduling\" => [\n \"access_control\" => [\n \"enabled\" => true,\n \"interval\" => \"0 10 0 * * ?\",\n ],\n \"full\" => [\n \"enabled\" => true,\n \"interval\" => \"0 20 0 * * ?\",\n ],\n \"incremental\" => [\n \"enabled\" => false,\n \"interval\" => \"0 30 0 * * ?\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"scheduling\":{\"access_control\":{\"enabled\":true,\"interval\":\"0 10 0 * * ?\"},\"full\":{\"enabled\":true,\"interval\":\"0 20 0 * * ?\"},\"incremental\":{\"enabled\":false,\"interval\":\"0 30 0 * * ?\"}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_scheduling\"" - }, - { - "language": "Java", - "code": "client.connector().updateScheduling(u -> u\n .connectorId(\"my-connector\")\n .scheduling(s -> s\n .accessControl(a -> a\n .enabled(true)\n .interval(\"0 10 0 * * ?\")\n )\n .full(f -> f\n .enabled(true)\n .interval(\"0 20 0 * * ?\")\n )\n .incremental(i -> i\n .enabled(false)\n .interval(\"0 30 0 * * ?\")\n )\n )\n);\n" - } - ], - "specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_pipeline(\n connector_id=\"my-connector\",\n pipeline={\n \"extract_binary_content\": True,\n \"name\": \"my-connector-pipeline\",\n \"reduce_whitespace\": True,\n \"run_ml_inference\": True\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updatePipeline({\n connector_id: \"my-connector\",\n pipeline: {\n extract_binary_content: true,\n name: \"my-connector-pipeline\",\n reduce_whitespace: true,\n run_ml_inference: true,\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_pipeline(\n connector_id: \"my-connector\",\n body: {\n \"pipeline\": {\n \"extract_binary_content\": true,\n \"name\": \"my-connector-pipeline\",\n \"reduce_whitespace\": true,\n \"run_ml_inference\": true\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updatePipeline([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"pipeline\" => [\n \"extract_binary_content\" => true,\n \"name\" => \"my-connector-pipeline\",\n \"reduce_whitespace\" => true,\n \"run_ml_inference\" => true,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"pipeline\":{\"extract_binary_content\":true,\"name\":\"my-connector-pipeline\",\"reduce_whitespace\":true,\"run_ml_inference\":true}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_pipeline\"" - }, - { - "language": "Java", - "code": "client.connector().updatePipeline(u -> u\n .connectorId(\"my-connector\")\n .pipeline(p -> p\n .extractBinaryContent(true)\n .name(\"my-connector-pipeline\")\n .reduceWhitespace(true)\n .runMlInference(true)\n )\n);\n" - } - ], - "specification/connector/sync_job_get/examples/request/ConnectorSyncJobGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_get(\n connector_sync_job_id=\"my-connector-sync-job\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobGet({\n connector_sync_job_id: \"my-connector-sync-job\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_get(\n connector_sync_job_id: \"my-connector-sync-job\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobGet([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobGet(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n);\n" - } - ], - "specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_update_stats(\n connector_sync_job_id=\"my-connector-sync-job\",\n deleted_document_count=10,\n indexed_document_count=20,\n indexed_document_volume=1000,\n total_document_count=2000,\n last_seen=\"2023-01-02T10:00:00Z\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobUpdateStats({\n connector_sync_job_id: \"my-connector-sync-job\",\n deleted_document_count: 10,\n indexed_document_count: 20,\n indexed_document_volume: 1000,\n total_document_count: 2000,\n last_seen: \"2023-01-02T10:00:00Z\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_update_stats(\n connector_sync_job_id: \"my-connector-sync-job\",\n body: {\n \"deleted_document_count\": 10,\n \"indexed_document_count\": 20,\n \"indexed_document_volume\": 1000,\n \"total_document_count\": 2000,\n \"last_seen\": \"2023-01-02T10:00:00Z\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobUpdateStats([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n \"body\" => [\n \"deleted_document_count\" => 10,\n \"indexed_document_count\" => 20,\n \"indexed_document_volume\" => 1000,\n \"total_document_count\" => 2000,\n \"last_seen\" => \"2023-01-02T10:00:00Z\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"deleted_document_count\":10,\"indexed_document_count\":20,\"indexed_document_volume\":1000,\"total_document_count\":2000,\"last_seen\":\"2023-01-02T10:00:00Z\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_stats\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobUpdateStats(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n .deletedDocumentCount(10L)\n .indexedDocumentCount(20L)\n .indexedDocumentVolume(1000L)\n .lastSeen(l -> l\n .time(\"2023-01-02T10:00:00Z\")\n )\n .totalDocumentCount(2000)\n);\n" - } - ], - "specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_post(\n id=\"connector-id\",\n job_type=\"full\",\n trigger_method=\"on_demand\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobPost({\n id: \"connector-id\",\n job_type: \"full\",\n trigger_method: \"on_demand\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_post(\n body: {\n \"id\": \"connector-id\",\n \"job_type\": \"full\",\n \"trigger_method\": \"on_demand\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobPost([\n \"body\" => [\n \"id\" => \"connector-id\",\n \"job_type\" => \"full\",\n \"trigger_method\" => \"on_demand\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"connector-id\",\"job_type\":\"full\",\"trigger_method\":\"on_demand\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobPost(s -> s\n .id(\"connector-id\")\n .jobType(SyncJobType.Full)\n .triggerMethod(SyncJobTriggerMethod.OnDemand)\n);\n" - } - ], - "specification/connector/delete/examples/request/ConnectorDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.delete(\n connector_id=\"my-connector-id&delete_sync_jobs=true\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.delete({\n connector_id: \"my-connector-id&delete_sync_jobs=true\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.delete(\n connector_id: \"my-connector-id&delete_sync_jobs=true\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->delete([\n \"connector_id\" => \"my-connector-id&delete_sync_jobs=true\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector-id&delete_sync_jobs=true\"" - }, - { - "language": "Java", - "code": "client.connector().delete(d -> d\n .connectorId(\"my-connector-id&delete_sync_jobs=true\")\n);\n" - } - ], - "specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.put(\n connector_id=\"my-connector\",\n index_name=\"search-google-drive\",\n name=\"My Connector\",\n description=\"My Connector to sync data to Elastic index from Google Drive\",\n service_type=\"google_drive\",\n language=\"english\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.put({\n connector_id: \"my-connector\",\n index_name: \"search-google-drive\",\n name: \"My Connector\",\n description: \"My Connector to sync data to Elastic index from Google Drive\",\n service_type: \"google_drive\",\n language: \"english\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.put(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"search-google-drive\",\n \"name\": \"My Connector\",\n \"description\": \"My Connector to sync data to Elastic index from Google Drive\",\n \"service_type\": \"google_drive\",\n \"language\": \"english\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->put([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"search-google-drive\",\n \"name\" => \"My Connector\",\n \"description\" => \"My Connector to sync data to Elastic index from Google Drive\",\n \"service_type\" => \"google_drive\",\n \"language\" => \"english\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"search-google-drive\",\"name\":\"My Connector\",\"description\":\"My Connector to sync data to Elastic index from Google Drive\",\"service_type\":\"google_drive\",\"language\":\"english\"}' \"$ELASTICSEARCH_URL/_connector/my-connector\"" - }, - { - "language": "Java", - "code": "client.connector().put(p -> p\n .connectorId(\"my-connector\")\n .description(\"My Connector to sync data to Elastic index from Google Drive\")\n .indexName(\"search-google-drive\")\n .language(\"english\")\n .name(\"My Connector\")\n .serviceType(\"google_drive\")\n);\n" - } - ], - "specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.put(\n connector_id=\"my-connector\",\n index_name=\"search-google-drive\",\n name=\"My Connector\",\n service_type=\"google_drive\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.put({\n connector_id: \"my-connector\",\n index_name: \"search-google-drive\",\n name: \"My Connector\",\n service_type: \"google_drive\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.put(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"search-google-drive\",\n \"name\": \"My Connector\",\n \"service_type\": \"google_drive\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->put([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"search-google-drive\",\n \"name\" => \"My Connector\",\n \"service_type\" => \"google_drive\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"search-google-drive\",\"name\":\"My Connector\",\"service_type\":\"google_drive\"}' \"$ELASTICSEARCH_URL/_connector/my-connector\"" - }, - { - "language": "Java", - "code": "client.connector().put(p -> p\n .connectorId(\"my-connector\")\n .indexName(\"search-google-drive\")\n .name(\"My Connector\")\n .serviceType(\"google_drive\")\n);\n" - } - ], - "specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_features(\n connector_id=\"my-connector\",\n features={\n \"document_level_security\": {\n \"enabled\": True\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateFeatures({\n connector_id: \"my-connector\",\n features: {\n document_level_security: {\n enabled: true,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_features(\n connector_id: \"my-connector\",\n body: {\n \"features\": {\n \"document_level_security\": {\n \"enabled\": true\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateFeatures([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"features\" => [\n \"document_level_security\" => [\n \"enabled\" => true,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"features\":{\"document_level_security\":{\"enabled\":true}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_features\"" - }, - { - "language": "Java", - "code": "client.connector().updateFeatures(u -> u\n .connectorId(\"my-connector\")\n .features(f -> f\n .documentLevelSecurity(d -> d\n .enabled(true)\n )\n )\n);\n" - } - ], - "specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_features(\n connector_id=\"my-connector\",\n features={\n \"document_level_security\": {\n \"enabled\": True\n },\n \"incremental_sync\": {\n \"enabled\": True\n },\n \"sync_rules\": {\n \"advanced\": {\n \"enabled\": False\n },\n \"basic\": {\n \"enabled\": True\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateFeatures({\n connector_id: \"my-connector\",\n features: {\n document_level_security: {\n enabled: true,\n },\n incremental_sync: {\n enabled: true,\n },\n sync_rules: {\n advanced: {\n enabled: false,\n },\n basic: {\n enabled: true,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_features(\n connector_id: \"my-connector\",\n body: {\n \"features\": {\n \"document_level_security\": {\n \"enabled\": true\n },\n \"incremental_sync\": {\n \"enabled\": true\n },\n \"sync_rules\": {\n \"advanced\": {\n \"enabled\": false\n },\n \"basic\": {\n \"enabled\": true\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateFeatures([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"features\" => [\n \"document_level_security\" => [\n \"enabled\" => true,\n ],\n \"incremental_sync\" => [\n \"enabled\" => true,\n ],\n \"sync_rules\" => [\n \"advanced\" => [\n \"enabled\" => false,\n ],\n \"basic\" => [\n \"enabled\" => true,\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"features\":{\"document_level_security\":{\"enabled\":true},\"incremental_sync\":{\"enabled\":true},\"sync_rules\":{\"advanced\":{\"enabled\":false},\"basic\":{\"enabled\":true}}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_features\"" - }, - { - "language": "Java", - "code": "client.connector().updateFeatures(u -> u\n .connectorId(\"my-connector\")\n .features(f -> f\n .documentLevelSecurity(d -> d\n .enabled(true)\n )\n .incrementalSync(i -> i\n .enabled(true)\n )\n .syncRules(s -> s\n .advanced(a -> a\n .enabled(false)\n )\n .basic(b -> b\n .enabled(true)\n )\n )\n )\n);\n" - } - ], - "specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_configuration(\n connector_id=\"my-spo-connector\",\n values={\n \"tenant_id\": \"my-tenant-id\",\n \"tenant_name\": \"my-sharepoint-site\",\n \"client_id\": \"foo\",\n \"secret_value\": \"bar\",\n \"site_collections\": \"*\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateConfiguration({\n connector_id: \"my-spo-connector\",\n values: {\n tenant_id: \"my-tenant-id\",\n tenant_name: \"my-sharepoint-site\",\n client_id: \"foo\",\n secret_value: \"bar\",\n site_collections: \"*\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_configuration(\n connector_id: \"my-spo-connector\",\n body: {\n \"values\": {\n \"tenant_id\": \"my-tenant-id\",\n \"tenant_name\": \"my-sharepoint-site\",\n \"client_id\": \"foo\",\n \"secret_value\": \"bar\",\n \"site_collections\": \"*\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateConfiguration([\n \"connector_id\" => \"my-spo-connector\",\n \"body\" => [\n \"values\" => [\n \"tenant_id\" => \"my-tenant-id\",\n \"tenant_name\" => \"my-sharepoint-site\",\n \"client_id\" => \"foo\",\n \"secret_value\" => \"bar\",\n \"site_collections\" => \"*\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"values\":{\"tenant_id\":\"my-tenant-id\",\"tenant_name\":\"my-sharepoint-site\",\"client_id\":\"foo\",\"secret_value\":\"bar\",\"site_collections\":\"*\"}}' \"$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration\"" - }, - { - "language": "Java", - "code": "client.connector().updateConfiguration(u -> u\n .connectorId(\"my-spo-connector\")\n .values(Map.of(\"tenant_id\", JsonData.fromJson(\"\\\"my-tenant-id\\\"\"),\"tenant_name\", JsonData.fromJson(\"\\\"my-sharepoint-site\\\"\"),\"secret_value\", JsonData.fromJson(\"\\\"bar\\\"\"),\"client_id\", JsonData.fromJson(\"\\\"foo\\\"\"),\"site_collections\", JsonData.fromJson(\"\\\"*\\\"\")))\n);\n" - } - ], - "specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_configuration(\n connector_id=\"my-spo-connector\",\n values={\n \"secret_value\": \"foo-bar\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateConfiguration({\n connector_id: \"my-spo-connector\",\n values: {\n secret_value: \"foo-bar\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_configuration(\n connector_id: \"my-spo-connector\",\n body: {\n \"values\": {\n \"secret_value\": \"foo-bar\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateConfiguration([\n \"connector_id\" => \"my-spo-connector\",\n \"body\" => [\n \"values\" => [\n \"secret_value\" => \"foo-bar\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"values\":{\"secret_value\":\"foo-bar\"}}' \"$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration\"" - }, - { - "language": "Java", - "code": "client.connector().updateConfiguration(u -> u\n .connectorId(\"my-spo-connector\")\n .values(\"secret_value\", JsonData.fromJson(\"\\\"foo-bar\\\"\"))\n);\n" - } - ], - "specification/connector/sync_job_check_in/examples/request/ConnectorSyncJobCheckInExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_check_in(\n connector_sync_job_id=\"my-connector-sync-job\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobCheckIn({\n connector_sync_job_id: \"my-connector-sync-job\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_check_in(\n connector_sync_job_id: \"my-connector-sync-job\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobCheckIn([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_check_in\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobCheckIn(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n);\n" - } - ], - "specification/connector/get/examples/request/ConnectorGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.get(\n connector_id=\"my-connector-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.get({\n connector_id: \"my-connector-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.get(\n connector_id: \"my-connector-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->get([\n \"connector_id\" => \"my-connector-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector-id\"" - }, - { - "language": "Java", - "code": "client.connector().get(g -> g\n .connectorId(\"my-connector-id\")\n);\n" - } - ], - "specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_error(\n connector_sync_job_id=\"my-connector-sync-job\",\n error=\"some-error\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobError({\n connector_sync_job_id: \"my-connector-sync-job\",\n error: \"some-error\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_error(\n connector_sync_job_id: \"my-connector-sync-job\",\n body: {\n \"error\": \"some-error\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobError([\n \"connector_sync_job_id\" => \"my-connector-sync-job\",\n \"body\" => [\n \"error\" => \"some-error\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"error\":\"some-error\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_error\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobError(s -> s\n .connectorSyncJobId(\"my-connector-sync-job\")\n .error(\"some-error\")\n);\n" - } - ], - "specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_claim(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n worker_hostname=\"some-machine\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobClaim({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n worker_hostname: \"some-machine\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_claim(\n connector_sync_job_id: \"my-connector-sync-job-id\",\n body: {\n \"worker_hostname\": \"some-machine\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobClaim([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n \"body\" => [\n \"worker_hostname\" => \"some-machine\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"worker_hostname\":\"some-machine\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id/_claim\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobClaim(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n .workerHostname(\"some-machine\")\n);\n" - } - ], - "specification/connector/list/examples/request/ConnectorListExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.list()" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.list();" - }, - { - "language": "Ruby", - "code": "response = client.connector.list" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->list();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector\"" - }, - { - "language": "Java", - "code": "client.connector().list(l -> l);\n" - } - ], - "specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_error(\n connector_id=\"my-connector\",\n error=\"Houston, we have a problem!\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateError({\n connector_id: \"my-connector\",\n error: \"Houston, we have a problem!\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_error(\n connector_id: \"my-connector\",\n body: {\n \"error\": \"Houston, we have a problem!\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateError([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"error\" => \"Houston, we have a problem!\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"error\":\"Houston, we have a problem!\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_error\"" - }, - { - "language": "Java", - "code": "client.connector().updateError(u -> u\n .connectorId(\"my-connector\")\n .error(\"Houston, we have a problem!\")\n);\n" - } - ], - "specification/connector/sync_job_list/examples/request/ConnectorSyncJobListExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_list(\n connector_id=\"my-connector-id\",\n size=\"1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobList({\n connector_id: \"my-connector-id\",\n size: 1,\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_list(\n connector_id: \"my-connector-id\",\n size: \"1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobList([\n \"connector_id\" => \"my-connector-id\",\n \"size\" => \"1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job?connector_id=my-connector-id&size=1\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobList(s -> s\n .connectorId(\"my-connector-id\")\n .size(1)\n);\n" - } - ], - "specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_index_name(\n connector_id=\"my-connector\",\n index_name=\"data-from-my-google-drive\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateIndexName({\n connector_id: \"my-connector\",\n index_name: \"data-from-my-google-drive\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_index_name(\n connector_id: \"my-connector\",\n body: {\n \"index_name\": \"data-from-my-google-drive\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateIndexName([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"index_name\" => \"data-from-my-google-drive\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_name\":\"data-from-my-google-drive\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_index_name\"" - }, - { - "language": "Java", - "code": "client.connector().updateIndexName(u -> u\n .connectorId(\"my-connector\")\n .indexName(\"data-from-my-google-drive\")\n);\n" - } - ], - "specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_api_key_id(\n connector_id=\"my-connector\",\n api_key_id=\"my-api-key-id\",\n api_key_secret_id=\"my-connector-secret-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateApiKeyId({\n connector_id: \"my-connector\",\n api_key_id: \"my-api-key-id\",\n api_key_secret_id: \"my-connector-secret-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_api_key_id(\n connector_id: \"my-connector\",\n body: {\n \"api_key_id\": \"my-api-key-id\",\n \"api_key_secret_id\": \"my-connector-secret-id\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateApiKeyId([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"api_key_id\" => \"my-api-key-id\",\n \"api_key_secret_id\" => \"my-connector-secret-id\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"api_key_id\":\"my-api-key-id\",\"api_key_secret_id\":\"my-connector-secret-id\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_api_key_id\"" - }, - { - "language": "Java", - "code": "client.connector().updateApiKeyId(u -> u\n .apiKeyId(\"my-api-key-id\")\n .apiKeySecretId(\"my-connector-secret-id\")\n .connectorId(\"my-connector\")\n);\n" - } - ], - "specification/connector/check_in/examples/request/ConnectorCheckInExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.check_in(\n connector_id=\"my-connector\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.checkIn({\n connector_id: \"my-connector\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.check_in(\n connector_id: \"my-connector\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->checkIn([\n \"connector_id\" => \"my-connector\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/my-connector/_check_in\"" - }, - { - "language": "Java", - "code": "client.connector().checkIn(c -> c\n .connectorId(\"my-connector\")\n);\n" - } - ], - "specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_status(\n connector_id=\"my-connector\",\n status=\"needs_configuration\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateStatus({\n connector_id: \"my-connector\",\n status: \"needs_configuration\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_status(\n connector_id: \"my-connector\",\n body: {\n \"status\": \"needs_configuration\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateStatus([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"status\" => \"needs_configuration\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"status\":\"needs_configuration\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_status\"" - }, - { - "language": "Java", - "code": "client.connector().updateStatus(u -> u\n .connectorId(\"my-connector\")\n .status(ConnectorStatus.NeedsConfiguration)\n);\n" - } - ], - "specification/connector/sync_job_cancel/examples/request/ConnectorSyncJobCancelExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_cancel(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobCancel({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_cancel(\n connector_sync_job_id: \"my-connector-sync-job-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobCancel([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id/_cancel\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobCancel(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n);\n" - } - ], - "specification/connector/sync_job_delete/examples/request/ConnectorSyncJobDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.sync_job_delete(\n connector_sync_job_id=\"my-connector-sync-job-id\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.syncJobDelete({\n connector_sync_job_id: \"my-connector-sync-job-id\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.sync_job_delete(\n connector_sync_job_id: \"my-connector-sync-job-id\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->syncJobDelete([\n \"connector_sync_job_id\" => \"my-connector-sync-job-id\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id\"" - }, - { - "language": "Java", - "code": "client.connector().syncJobDelete(s -> s\n .connectorSyncJobId(\"my-connector-sync-job-id\")\n);\n" - } - ], - "specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_name(\n connector_id=\"my-connector\",\n name=\"Custom connector\",\n description=\"This is my customized connector\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateName({\n connector_id: \"my-connector\",\n name: \"Custom connector\",\n description: \"This is my customized connector\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_name(\n connector_id: \"my-connector\",\n body: {\n \"name\": \"Custom connector\",\n \"description\": \"This is my customized connector\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateName([\n \"connector_id\" => \"my-connector\",\n \"body\" => [\n \"name\" => \"Custom connector\",\n \"description\" => \"This is my customized connector\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"Custom connector\",\"description\":\"This is my customized connector\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_name\"" - }, - { - "language": "Java", - "code": "client.connector().updateName(u -> u\n .connectorId(\"my-connector\")\n .description(\"This is my customized connector\")\n .name(\"Custom connector\")\n);\n" - } - ], - "specification/connector/last_sync/examples/request/ConnectorUpdateLastSyncRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.perform_request(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n headers={\"Content-Type\": \"application/json\"},\n body={\n \"last_access_control_sync_error\": \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\": \"pending\",\n \"last_deleted_document_count\": 42,\n \"last_incremental_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\": 42,\n \"last_sync_error\": \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\": \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\": \"completed\",\n \"last_synced\": \"2024-11-09T15:13:08.231Z\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transport.request({\n method: \"PUT\",\n path: \"/_connector/my-connector/_last_sync\",\n body: {\n last_access_control_sync_error: \"Houston, we have a problem!\",\n last_access_control_sync_scheduled_at: \"2023-11-09T15:13:08.231Z\",\n last_access_control_sync_status: \"pending\",\n last_deleted_document_count: 42,\n last_incremental_sync_scheduled_at: \"2023-11-09T15:13:08.231Z\",\n last_indexed_document_count: 42,\n last_sync_error: \"Houston, we have a problem!\",\n last_sync_scheduled_at: \"2024-11-09T15:13:08.231Z\",\n last_sync_status: \"completed\",\n last_synced: \"2024-11-09T15:13:08.231Z\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.perform_request(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n {},\n {\n \"last_access_control_sync_error\": \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\": \"pending\",\n \"last_deleted_document_count\": 42,\n \"last_incremental_sync_scheduled_at\": \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\": 42,\n \"last_sync_error\": \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\": \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\": \"completed\",\n \"last_synced\": \"2024-11-09T15:13:08.231Z\"\n },\n { \"Content-Type\": \"application/json\" },\n)" - }, - { - "language": "PHP", - "code": "$requestFactory = Psr17FactoryDiscovery::findRequestFactory();\n$streamFactory = Psr17FactoryDiscovery::findStreamFactory();\n$request = $requestFactory->createRequest(\n \"PUT\",\n \"/_connector/my-connector/_last_sync\",\n);\n$request = $request->withHeader(\"Content-Type\", \"application/json\");\n$request = $request->withBody($streamFactory->createStream(\n json_encode([\n \"last_access_control_sync_error\" => \"Houston, we have a problem!\",\n \"last_access_control_sync_scheduled_at\" => \"2023-11-09T15:13:08.231Z\",\n \"last_access_control_sync_status\" => \"pending\",\n \"last_deleted_document_count\" => 42,\n \"last_incremental_sync_scheduled_at\" => \"2023-11-09T15:13:08.231Z\",\n \"last_indexed_document_count\" => 42,\n \"last_sync_error\" => \"Houston, we have a problem!\",\n \"last_sync_scheduled_at\" => \"2024-11-09T15:13:08.231Z\",\n \"last_sync_status\" => \"completed\",\n \"last_synced\" => \"2024-11-09T15:13:08.231Z\",\n ]),\n));\n$resp = $client->sendRequest($request);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"last_access_control_sync_error\":\"Houston, we have a problem!\",\"last_access_control_sync_scheduled_at\":\"2023-11-09T15:13:08.231Z\",\"last_access_control_sync_status\":\"pending\",\"last_deleted_document_count\":42,\"last_incremental_sync_scheduled_at\":\"2023-11-09T15:13:08.231Z\",\"last_indexed_document_count\":42,\"last_sync_error\":\"Houston, we have a problem!\",\"last_sync_scheduled_at\":\"2024-11-09T15:13:08.231Z\",\"last_sync_status\":\"completed\",\"last_synced\":\"2024-11-09T15:13:08.231Z\"}' \"$ELASTICSEARCH_URL/_connector/my-connector/_last_sync\"" - } - ], - "specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_filtering(\n connector_id=\"my-sql-connector\",\n advanced_snippet={\n \"value\": [\n {\n \"tables\": [\n \"users\",\n \"orders\"\n ],\n \"query\": \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateFiltering({\n connector_id: \"my-sql-connector\",\n advanced_snippet: {\n value: [\n {\n tables: [\"users\", \"orders\"],\n query:\n \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\",\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_filtering(\n connector_id: \"my-sql-connector\",\n body: {\n \"advanced_snippet\": {\n \"value\": [\n {\n \"tables\": [\n \"users\",\n \"orders\"\n ],\n \"query\": \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateFiltering([\n \"connector_id\" => \"my-sql-connector\",\n \"body\" => [\n \"advanced_snippet\" => [\n \"value\" => array(\n [\n \"tables\" => array(\n \"users\",\n \"orders\",\n ),\n \"query\" => \"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\",\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"advanced_snippet\":{\"value\":[{\"tables\":[\"users\",\"orders\"],\"query\":\"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"}]}}' \"$ELASTICSEARCH_URL/_connector/my-sql-connector/_filtering\"" - }, - { - "language": "Java", - "code": "client.connector().updateFiltering(u -> u\n .advancedSnippet(a -> a\n .value(JsonData.fromJson(\"[{\\\"tables\\\":[\\\"users\\\",\\\"orders\\\"],\\\"query\\\":\\\"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\\\"}]\"))\n )\n .connectorId(\"my-sql-connector\")\n);\n" - } - ], - "specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.connector.update_filtering(\n connector_id=\"my-g-drive-connector\",\n rules=[\n {\n \"field\": \"file_extension\",\n \"id\": \"exclude-txt-files\",\n \"order\": 0,\n \"policy\": \"exclude\",\n \"rule\": \"equals\",\n \"value\": \"txt\"\n },\n {\n \"field\": \"_\",\n \"id\": \"DEFAULT\",\n \"order\": 1,\n \"policy\": \"include\",\n \"rule\": \"regex\",\n \"value\": \".*\"\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.connector.updateFiltering({\n connector_id: \"my-g-drive-connector\",\n rules: [\n {\n field: \"file_extension\",\n id: \"exclude-txt-files\",\n order: 0,\n policy: \"exclude\",\n rule: \"equals\",\n value: \"txt\",\n },\n {\n field: \"_\",\n id: \"DEFAULT\",\n order: 1,\n policy: \"include\",\n rule: \"regex\",\n value: \".*\",\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.connector.update_filtering(\n connector_id: \"my-g-drive-connector\",\n body: {\n \"rules\": [\n {\n \"field\": \"file_extension\",\n \"id\": \"exclude-txt-files\",\n \"order\": 0,\n \"policy\": \"exclude\",\n \"rule\": \"equals\",\n \"value\": \"txt\"\n },\n {\n \"field\": \"_\",\n \"id\": \"DEFAULT\",\n \"order\": 1,\n \"policy\": \"include\",\n \"rule\": \"regex\",\n \"value\": \".*\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->connector()->updateFiltering([\n \"connector_id\" => \"my-g-drive-connector\",\n \"body\" => [\n \"rules\" => array(\n [\n \"field\" => \"file_extension\",\n \"id\" => \"exclude-txt-files\",\n \"order\" => 0,\n \"policy\" => \"exclude\",\n \"rule\" => \"equals\",\n \"value\" => \"txt\",\n ],\n [\n \"field\" => \"_\",\n \"id\" => \"DEFAULT\",\n \"order\" => 1,\n \"policy\" => \"include\",\n \"rule\" => \"regex\",\n \"value\" => \".*\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"field\":\"file_extension\",\"id\":\"exclude-txt-files\",\"order\":0,\"policy\":\"exclude\",\"rule\":\"equals\",\"value\":\"txt\"},{\"field\":\"_\",\"id\":\"DEFAULT\",\"order\":1,\"policy\":\"include\",\"rule\":\"regex\",\"value\":\".*\"}]}' \"$ELASTICSEARCH_URL/_connector/my-g-drive-connector/_filtering\"" - }, - { - "language": "Java", - "code": "client.connector().updateFiltering(u -> u\n .connectorId(\"my-g-drive-connector\")\n .rules(List.of(FilteringRule.of(f -> f\n .field(\"file_extension\")\n .id(\"exclude-txt-files\")\n .order(0)\n .policy(FilteringPolicy.Exclude)\n .rule(FilteringRuleRule.Equals)\n .value(\"txt\")),FilteringRule.of(f -> f\n .field(\"_\")\n .id(\"DEFAULT\")\n .order(1)\n .policy(FilteringPolicy.Include)\n .rule(FilteringRuleRule.Regex)\n .value(\".*\"))))\n);\n" - } - ], - "specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"mistral-embeddings-test\",\n inference_config={\n \"service\": \"mistral\",\n \"service_settings\": {\n \"api_key\": \"Mistral-API-Key\",\n \"model\": \"mistral-embed\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"mistral-embeddings-test\",\n inference_config: {\n service: \"mistral\",\n service_settings: {\n api_key: \"Mistral-API-Key\",\n model: \"mistral-embed\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"mistral-embeddings-test\",\n body: {\n \"service\": \"mistral\",\n \"service_settings\": {\n \"api_key\": \"Mistral-API-Key\",\n \"model\": \"mistral-embed\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"mistral-embeddings-test\",\n \"body\" => [\n \"service\" => \"mistral\",\n \"service_settings\" => [\n \"api_key\" => \"Mistral-API-Key\",\n \"model\" => \"mistral-embed\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"mistral\",\"service_settings\":{\"api_key\":\"Mistral-API-Key\",\"model\":\"mistral-embed\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/mistral-embeddings-test\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"mistral-embeddings-test\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"mistral\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Mistral-API-Key\\\",\\\"model\\\":\\\"mistral-embed\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is Elastic?\"\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n model: \"gpt-4o\",\n messages: [\n {\n role: \"user\",\n content: \"What is Elastic?\",\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is Elastic?\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"model\" => \"gpt-4o\",\n \"messages\" => array(\n [\n \"role\" => \"user\",\n \"content\" => \"What is Elastic?\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"model\":\"gpt-4o\",\"messages\":[{\"role\":\"user\",\"content\":\"What is Elastic?\"}]}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" - }, - { - "language": "Java", - "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(m -> m\n .content(co -> co\n .string(\"What is Elastic?\")\n )\n .role(\"user\")\n )\n .model(\"gpt-4o\")\n )\n);\n" - } - ], - "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What's the price of a scarf?\"\n }\n ]\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\",\n \"description\": \"Get the current price of a item\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"id\": \"123\"\n }\n }\n }\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n messages: [\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: \"What's the price of a scarf?\",\n },\n ],\n },\n ],\n tools: [\n {\n type: \"function\",\n function: {\n name: \"get_current_price\",\n description: \"Get the current price of a item\",\n parameters: {\n type: \"object\",\n properties: {\n item: {\n id: \"123\",\n },\n },\n },\n },\n },\n ],\n tool_choice: {\n type: \"function\",\n function: {\n name: \"get_current_price\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What's the price of a scarf?\"\n }\n ]\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\",\n \"description\": \"Get the current price of a item\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"id\": \"123\"\n }\n }\n }\n }\n }\n ],\n \"tool_choice\": {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_price\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"messages\" => array(\n [\n \"role\" => \"user\",\n \"content\" => array(\n [\n \"type\" => \"text\",\n \"text\" => \"What's the price of a scarf?\",\n ],\n ),\n ],\n ),\n \"tools\" => array(\n [\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_price\",\n \"description\" => \"Get the current price of a item\",\n \"parameters\" => [\n \"type\" => \"object\",\n \"properties\" => [\n \"item\" => [\n \"id\" => \"123\",\n ],\n ],\n ],\n ],\n ],\n ),\n \"tool_choice\" => [\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_price\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What'\"'\"'s the price of a scarf?\"}]}],\"tools\":[{\"type\":\"function\",\"function\":{\"name\":\"get_current_price\",\"description\":\"Get the current price of a item\",\"parameters\":{\"type\":\"object\",\"properties\":{\"item\":{\"id\":\"123\"}}}}}],\"tool_choice\":{\"type\":\"function\",\"function\":{\"name\":\"get_current_price\"}}}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" - }, - { - "language": "Java", - "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(m -> m\n .content(co -> co\n .string(\"What's the price of a scarf?\")\n )\n .role(\"user\")\n )\n .toolChoice(t -> t\n .object(o -> o\n .type(\"function\")\n .function(f -> f\n .name(\"get_current_price\")\n )\n )\n )\n .tools(to -> to\n .type(\"function\")\n .function(f -> f\n .description(\"Get the current price of a item\")\n .name(\"get_current_price\")\n .parameters(JsonData.fromJson(\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"item\\\":{\\\"id\\\":\\\"123\\\"}}}\"))\n )\n )\n )\n);\n" - } - ], - "specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.chat_completion_unified(\n inference_id=\"openai-completion\",\n chat_completion_request={\n \"messages\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Let's find out what the weather is\",\n \"tool_calls\": [\n {\n \"id\": \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\\"location\\\":\\\"Boston, MA\\\"}\"\n }\n }\n ]\n },\n {\n \"role\": \"tool\",\n \"content\": \"The weather is cold\",\n \"tool_call_id\": \"call_KcAjWtAww20AihPHphUh46Gd\"\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.chatCompletionUnified({\n inference_id: \"openai-completion\",\n chat_completion_request: {\n messages: [\n {\n role: \"assistant\",\n content: \"Let's find out what the weather is\",\n tool_calls: [\n {\n id: \"call_KcAjWtAww20AihPHphUh46Gd\",\n type: \"function\",\n function: {\n name: \"get_current_weather\",\n arguments: '{\"location\":\"Boston, MA\"}',\n },\n },\n ],\n },\n {\n role: \"tool\",\n content: \"The weather is cold\",\n tool_call_id: \"call_KcAjWtAww20AihPHphUh46Gd\",\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.chat_completion_unified(\n inference_id: \"openai-completion\",\n body: {\n \"messages\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Let's find out what the weather is\",\n \"tool_calls\": [\n {\n \"id\": \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\\"location\\\":\\\"Boston, MA\\\"}\"\n }\n }\n ]\n },\n {\n \"role\": \"tool\",\n \"content\": \"The weather is cold\",\n \"tool_call_id\": \"call_KcAjWtAww20AihPHphUh46Gd\"\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->chatCompletionUnified([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"messages\" => array(\n [\n \"role\" => \"assistant\",\n \"content\" => \"Let's find out what the weather is\",\n \"tool_calls\" => array(\n [\n \"id\" => \"call_KcAjWtAww20AihPHphUh46Gd\",\n \"type\" => \"function\",\n \"function\" => [\n \"name\" => \"get_current_weather\",\n \"arguments\" => \"{\\\"location\\\":\\\"Boston, MA\\\"}\",\n ],\n ],\n ),\n ],\n [\n \"role\" => \"tool\",\n \"content\" => \"The weather is cold\",\n \"tool_call_id\" => \"call_KcAjWtAww20AihPHphUh46Gd\",\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"messages\":[{\"role\":\"assistant\",\"content\":\"Let'\"'\"'s find out what the weather is\",\"tool_calls\":[{\"id\":\"call_KcAjWtAww20AihPHphUh46Gd\",\"type\":\"function\",\"function\":{\"name\":\"get_current_weather\",\"arguments\":\"{\\\"location\\\":\\\"Boston, MA\\\"}\"}}]},{\"role\":\"tool\",\"content\":\"The weather is cold\",\"tool_call_id\":\"call_KcAjWtAww20AihPHphUh46Gd\"}]}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" - }, - { - "language": "Java", - "code": "client.inference().chatCompletionUnified(c -> c\n .inferenceId(\"openai-completion\")\n .chatCompletionRequest(ch -> ch\n .messages(List.of(Message.of(m -> m\n .content(co -> co\n .string(\"Let's find out what the weather is\")\n )\n .role(\"assistant\")\n .toolCalls(t -> t\n .id(\"call_KcAjWtAww20AihPHphUh46Gd\")\n .function(f -> f\n .arguments(\"{\\\"location\\\":\\\"Boston, MA\\\"}\")\n .name(\"get_current_weather\")\n )\n .type(\"function\")\n )),Message.of(me -> me\n .content(co -> co\n .string(\"The weather is cold\")\n )\n .role(\"tool\")\n .toolCallId(\"call_KcAjWtAww20AihPHphUh46Gd\"))))\n )\n);\n" - } - ], - "specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.text_embedding(\n inference_id=\"my-cohere-endpoint\",\n input=\"The sky above the port was the color of television tuned to a dead channel.\",\n task_settings={\n \"input_type\": \"ingest\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.textEmbedding({\n inference_id: \"my-cohere-endpoint\",\n input:\n \"The sky above the port was the color of television tuned to a dead channel.\",\n task_settings: {\n input_type: \"ingest\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.text_embedding(\n inference_id: \"my-cohere-endpoint\",\n body: {\n \"input\": \"The sky above the port was the color of television tuned to a dead channel.\",\n \"task_settings\": {\n \"input_type\": \"ingest\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->textEmbedding([\n \"inference_id\" => \"my-cohere-endpoint\",\n \"body\" => [\n \"input\" => \"The sky above the port was the color of television tuned to a dead channel.\",\n \"task_settings\" => [\n \"input_type\" => \"ingest\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"The sky above the port was the color of television tuned to a dead channel.\",\"task_settings\":{\"input_type\":\"ingest\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-cohere-endpoint\"" - }, - { - "language": "Java", - "code": "client.inference().textEmbedding(t -> t\n .inferenceId(\"my-cohere-endpoint\")\n .input(\"The sky above the port was the color of television tuned to a dead channel.\")\n .taskSettings(JsonData.fromJson(\"{\\\"input_type\\\":\\\"ingest\\\"}\"))\n);\n" - } - ], - "specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"jinaai-embeddings\",\n inference_config={\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"model_id\": \"jina-embeddings-v3\",\n \"api_key\": \"JinaAi-Api-key\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"jinaai-embeddings\",\n inference_config: {\n service: \"jinaai\",\n service_settings: {\n model_id: \"jina-embeddings-v3\",\n api_key: \"JinaAi-Api-key\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"jinaai-embeddings\",\n body: {\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"model_id\": \"jina-embeddings-v3\",\n \"api_key\": \"JinaAi-Api-key\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"jinaai-embeddings\",\n \"body\" => [\n \"service\" => \"jinaai\",\n \"service_settings\" => [\n \"model_id\" => \"jina-embeddings-v3\",\n \"api_key\" => \"JinaAi-Api-key\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"jinaai\",\"service_settings\":{\"model_id\":\"jina-embeddings-v3\",\"api_key\":\"JinaAi-Api-key\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/jinaai-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"jinaai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"jinaai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"jina-embeddings-v3\\\",\\\"api_key\\\":\\\"JinaAi-Api-key\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"jinaai-rerank\",\n inference_config={\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"api_key\": \"JinaAI-Api-key\",\n \"model_id\": \"jina-reranker-v2-base-multilingual\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": True\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"jinaai-rerank\",\n inference_config: {\n service: \"jinaai\",\n service_settings: {\n api_key: \"JinaAI-Api-key\",\n model_id: \"jina-reranker-v2-base-multilingual\",\n },\n task_settings: {\n top_n: 10,\n return_documents: true,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"jinaai-rerank\",\n body: {\n \"service\": \"jinaai\",\n \"service_settings\": {\n \"api_key\": \"JinaAI-Api-key\",\n \"model_id\": \"jina-reranker-v2-base-multilingual\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"jinaai-rerank\",\n \"body\" => [\n \"service\" => \"jinaai\",\n \"service_settings\" => [\n \"api_key\" => \"JinaAI-Api-key\",\n \"model_id\" => \"jina-reranker-v2-base-multilingual\",\n ],\n \"task_settings\" => [\n \"top_n\" => 10,\n \"return_documents\" => true,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"jinaai\",\"service_settings\":{\"api_key\":\"JinaAI-Api-key\",\"model_id\":\"jina-reranker-v2-base-multilingual\"},\"task_settings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/jinaai-rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"jinaai-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"jinaai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"JinaAI-Api-key\\\",\\\"model_id\\\":\\\"jina-reranker-v2-base-multilingual\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"top_n\\\":10,\\\"return_documents\\\":true}\"))\n )\n);\n" - } - ], - "specification/inference/update/examples/request/InferenceUpdateExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.update(\n inference_id=\"my-inference-endpoint\",\n inference_config={\n \"service_settings\": {\n \"api_key\": \"\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.update({\n inference_id: \"my-inference-endpoint\",\n inference_config: {\n service_settings: {\n api_key: \"\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.update(\n inference_id: \"my-inference-endpoint\",\n body: {\n \"service_settings\": {\n \"api_key\": \"\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->update([\n \"inference_id\" => \"my-inference-endpoint\",\n \"body\" => [\n \"service_settings\" => [\n \"api_key\" => \"\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service_settings\":{\"api_key\":\"\"}}' \"$ELASTICSEARCH_URL/_inference/my-inference-endpoint/_update\"" - } - ], - "specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elser\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elser\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elser\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elser\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elser\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elser\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1}\"))\n )\n);\n" - } - ], - "specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elser\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elser\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 3,\n max_number_of_allocations: 10,\n },\n num_threads: 1,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elser\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elser\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 3,\n \"max_number_of_allocations\" => 10,\n ],\n \"num_threads\" => 1,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elser\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elser\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":3,\\\"max_number_of_allocations\\\":10},\\\"num_threads\\\":1}\"))\n )\n);\n" - } - ], - "specification/inference/delete/examples/request/InferenceDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.delete(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.delete({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.delete(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->delete([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().delete(d -> d\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n);\n" - } - ], - "specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"cohere-embeddings\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"cohere-embeddings\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-Api-key\",\n model_id: \"embed-english-light-v3.0\",\n embedding_type: \"byte\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"cohere-embeddings\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"cohere-embeddings\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-Api-key\",\n \"model_id\" => \"embed-english-light-v3.0\",\n \"embedding_type\" => \"byte\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-Api-key\",\"model_id\":\"embed-english-light-v3.0\",\"embedding_type\":\"byte\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/cohere-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"cohere-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Cohere-Api-key\\\",\\\"model_id\\\":\\\"embed-english-light-v3.0\\\",\\\"embedding_type\\\":\\\"byte\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"cohere-rerank\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": True\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"cohere-rerank\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-API-key\",\n model_id: \"rerank-english-v3.0\",\n },\n task_settings: {\n top_n: 10,\n return_documents: true,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"cohere-rerank\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"cohere-rerank\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-API-key\",\n \"model_id\" => \"rerank-english-v3.0\",\n ],\n \"task_settings\" => [\n \"top_n\" => 10,\n \"return_documents\" => true,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-API-key\",\"model_id\":\"rerank-english-v3.0\"},\"task_settings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/cohere-rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"cohere-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Cohere-API-key\\\",\\\"model_id\\\":\\\"rerank-english-v3.0\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"top_n\\\":10,\\\"return_documents\\\":true}\"))\n )\n);\n" - } - ], - "specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"google_ai_studio_completion\",\n inference_config={\n \"service\": \"googleaistudio\",\n \"service_settings\": {\n \"api_key\": \"api-key\",\n \"model_id\": \"model-id\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"google_ai_studio_completion\",\n inference_config: {\n service: \"googleaistudio\",\n service_settings: {\n api_key: \"api-key\",\n model_id: \"model-id\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"google_ai_studio_completion\",\n body: {\n \"service\": \"googleaistudio\",\n \"service_settings\": {\n \"api_key\": \"api-key\",\n \"model_id\": \"model-id\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"google_ai_studio_completion\",\n \"body\" => [\n \"service\" => \"googleaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"api-key\",\n \"model_id\" => \"model-id\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googleaistudio\",\"service_settings\":{\"api_key\":\"api-key\",\"model_id\":\"model-id\"}}' \"$ELASTICSEARCH_URL/_inference/completion/google_ai_studio_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"google_ai_studio_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"googleaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"api-key\\\",\\\"model_id\\\":\\\"model-id\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put/examples/request/InferencePutExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"my-rerank-model\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"model_id\": \"rerank-english-v3.0\",\n \"api_key\": \"{{COHERE_API_KEY}}\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"my-rerank-model\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n model_id: \"rerank-english-v3.0\",\n api_key: \"{{COHERE_API_KEY}}\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"my-rerank-model\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"model_id\": \"rerank-english-v3.0\",\n \"api_key\": \"{{COHERE_API_KEY}}\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"my-rerank-model\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"model_id\" => \"rerank-english-v3.0\",\n \"api_key\" => \"{{COHERE_API_KEY}}\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"model_id\":\"rerank-english-v3.0\",\"api_key\":\"{{COHERE_API_KEY}}\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/my-rerank-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-rerank-model\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"cohere\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"rerank-english-v3.0\\\",\\\"api_key\\\":\\\"{{COHERE_API_KEY}}\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"voyageai-rerank\",\n inference_config={\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"rerank-2\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"voyageai-rerank\",\n inference_config: {\n service: \"voyageai\",\n service_settings: {\n model_id: \"rerank-2\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"voyageai-rerank\",\n body: {\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"rerank-2\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"voyageai-rerank\",\n \"body\" => [\n \"service\" => \"voyageai\",\n \"service_settings\" => [\n \"model_id\" => \"rerank-2\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"voyageai\",\"service_settings\":{\"model_id\":\"rerank-2\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/voyageai-rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"voyageai-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"voyageai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"rerank-2\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"openai-embeddings\",\n inference_config={\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"voyage-3-large\",\n \"dimensions\": 512\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n inference_config: {\n service: \"voyageai\",\n service_settings: {\n model_id: \"voyage-3-large\",\n dimensions: 512,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n body: {\n \"service\": \"voyageai\",\n \"service_settings\": {\n \"model_id\": \"voyage-3-large\",\n \"dimensions\": 512\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"openai-embeddings\",\n \"body\" => [\n \"service\" => \"voyageai\",\n \"service_settings\" => [\n \"model_id\" => \"voyage-3-large\",\n \"dimensions\" => 512,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"voyageai\",\"service_settings\":{\"model_id\":\"voyage-3-large\",\"dimensions\":512}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"openai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"voyageai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\"voyage-3-large\\\",\\\"dimensions\\\":512}\"))\n )\n);\n" - } - ], - "specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"watsonx-embeddings\",\n inference_config={\n \"service\": \"watsonxai\",\n \"service_settings\": {\n \"api_key\": \"Watsonx-API-Key\",\n \"url\": \"Wastonx-URL\",\n \"model_id\": \"ibm/slate-30m-english-rtrvr\",\n \"project_id\": \"IBM-Cloud-ID\",\n \"api_version\": \"2024-03-14\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"watsonx-embeddings\",\n inference_config: {\n service: \"watsonxai\",\n service_settings: {\n api_key: \"Watsonx-API-Key\",\n url: \"Wastonx-URL\",\n model_id: \"ibm/slate-30m-english-rtrvr\",\n project_id: \"IBM-Cloud-ID\",\n api_version: \"2024-03-14\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"watsonx-embeddings\",\n body: {\n \"service\": \"watsonxai\",\n \"service_settings\": {\n \"api_key\": \"Watsonx-API-Key\",\n \"url\": \"Wastonx-URL\",\n \"model_id\": \"ibm/slate-30m-english-rtrvr\",\n \"project_id\": \"IBM-Cloud-ID\",\n \"api_version\": \"2024-03-14\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"watsonx-embeddings\",\n \"body\" => [\n \"service\" => \"watsonxai\",\n \"service_settings\" => [\n \"api_key\" => \"Watsonx-API-Key\",\n \"url\" => \"Wastonx-URL\",\n \"model_id\" => \"ibm/slate-30m-english-rtrvr\",\n \"project_id\" => \"IBM-Cloud-ID\",\n \"api_version\" => \"2024-03-14\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"watsonxai\",\"service_settings\":{\"api_key\":\"Watsonx-API-Key\",\"url\":\"Wastonx-URL\",\"model_id\":\"ibm/slate-30m-english-rtrvr\",\"project_id\":\"IBM-Cloud-ID\",\"api_version\":\"2024-03-14\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/watsonx-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"watsonx-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"watsonxai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Watsonx-API-Key\\\",\\\"url\\\":\\\"Wastonx-URL\\\",\\\"model_id\\\":\\\"ibm/slate-30m-english-rtrvr\\\",\\\"project_id\\\":\\\"IBM-Cloud-ID\\\",\\\"api_version\\\":\\\"2024-03-14\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/completion/examples/request/CompletionRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.completion(\n inference_id=\"openai_chat_completions\",\n input=\"What is Elastic?\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.completion({\n inference_id: \"openai_chat_completions\",\n input: \"What is Elastic?\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.completion(\n inference_id: \"openai_chat_completions\",\n body: {\n \"input\": \"What is Elastic?\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->completion([\n \"inference_id\" => \"openai_chat_completions\",\n \"body\" => [\n \"input\" => \"What is Elastic?\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"What is Elastic?\"}' \"$ELASTICSEARCH_URL/_inference/completion/openai_chat_completions\"" - }, - { - "language": "Java", - "code": "client.inference().completion(c -> c\n .inferenceId(\"openai_chat_completions\")\n .input(\"What is Elastic?\")\n);\n" - } - ], - "specification/inference/get/examples/request/InferenceGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.get(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.get({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.get(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->get([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().get(g -> g\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n);\n" - } - ], - "specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"anthropic_completion\",\n inference_config={\n \"service\": \"anthropic\",\n \"service_settings\": {\n \"api_key\": \"Anthropic-Api-Key\",\n \"model_id\": \"Model-ID\"\n },\n \"task_settings\": {\n \"max_tokens\": 1024\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"anthropic_completion\",\n inference_config: {\n service: \"anthropic\",\n service_settings: {\n api_key: \"Anthropic-Api-Key\",\n model_id: \"Model-ID\",\n },\n task_settings: {\n max_tokens: 1024,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"anthropic_completion\",\n body: {\n \"service\": \"anthropic\",\n \"service_settings\": {\n \"api_key\": \"Anthropic-Api-Key\",\n \"model_id\": \"Model-ID\"\n },\n \"task_settings\": {\n \"max_tokens\": 1024\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"anthropic_completion\",\n \"body\" => [\n \"service\" => \"anthropic\",\n \"service_settings\" => [\n \"api_key\" => \"Anthropic-Api-Key\",\n \"model_id\" => \"Model-ID\",\n ],\n \"task_settings\" => [\n \"max_tokens\" => 1024,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"anthropic\",\"service_settings\":{\"api_key\":\"Anthropic-Api-Key\",\"model_id\":\"Model-ID\"},\"task_settings\":{\"max_tokens\":1024}}' \"$ELASTICSEARCH_URL/_inference/completion/anthropic_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"anthropic_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"anthropic\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Anthropic-Api-Key\\\",\\\"model_id\\\":\\\"Model-ID\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"max_tokens\\\":1024}\"))\n )\n);\n" - } - ], - "specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.sparse_embedding(\n inference_id=\"my-elser-model\",\n input=\"The sky above the port was the color of television tuned to a dead channel.\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.sparseEmbedding({\n inference_id: \"my-elser-model\",\n input:\n \"The sky above the port was the color of television tuned to a dead channel.\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.sparse_embedding(\n inference_id: \"my-elser-model\",\n body: {\n \"input\": \"The sky above the port was the color of television tuned to a dead channel.\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->sparseEmbedding([\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"input\" => \"The sky above the port was the color of television tuned to a dead channel.\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"The sky above the port was the color of television tuned to a dead channel.\"}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().sparseEmbedding(s -> s\n .inferenceId(\"my-elser-model\")\n .input(\"The sky above the port was the color of television tuned to a dead channel.\")\n);\n" - } - ], - "specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"google_vertex_ai_rerank\",\n inference_config={\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"project_id\": \"project-id\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"google_vertex_ai_rerank\",\n inference_config: {\n service: \"googlevertexai\",\n service_settings: {\n service_account_json: \"service-account-json\",\n project_id: \"project-id\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"google_vertex_ai_rerank\",\n body: {\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"project_id\": \"project-id\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"google_vertex_ai_rerank\",\n \"body\" => [\n \"service\" => \"googlevertexai\",\n \"service_settings\" => [\n \"service_account_json\" => \"service-account-json\",\n \"project_id\" => \"project-id\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"project_id\":\"project-id\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/google_vertex_ai_rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"google_vertex_ai_rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"googlevertexai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"service_account_json\\\":\\\"service-account-json\\\",\\\"project_id\\\":\\\"project-id\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"google_vertex_ai_embeddingss\",\n inference_config={\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"model_id\": \"model-id\",\n \"location\": \"location\",\n \"project_id\": \"project-id\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"google_vertex_ai_embeddingss\",\n inference_config: {\n service: \"googlevertexai\",\n service_settings: {\n service_account_json: \"service-account-json\",\n model_id: \"model-id\",\n location: \"location\",\n project_id: \"project-id\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"google_vertex_ai_embeddingss\",\n body: {\n \"service\": \"googlevertexai\",\n \"service_settings\": {\n \"service_account_json\": \"service-account-json\",\n \"model_id\": \"model-id\",\n \"location\": \"location\",\n \"project_id\": \"project-id\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"google_vertex_ai_embeddingss\",\n \"body\" => [\n \"service\" => \"googlevertexai\",\n \"service_settings\" => [\n \"service_account_json\" => \"service-account-json\",\n \"model_id\" => \"model-id\",\n \"location\" => \"location\",\n \"project_id\" => \"project-id\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"model_id\":\"model-id\",\"location\":\"location\",\"project_id\":\"project-id\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/google_vertex_ai_embeddingss\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"google_vertex_ai_embeddingss\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"googlevertexai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"service_account_json\\\":\\\"service-account-json\\\",\\\"model_id\\\":\\\"model-id\\\",\\\"location\\\":\\\"location\\\",\\\"project_id\\\":\\\"project-id\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"hugging-face-embeddings\",\n inference_config={\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"hugging-face-embeddings\",\n inference_config: {\n service: \"hugging_face\",\n service_settings: {\n api_key: \"hugging-face-access-token\",\n url: \"url-endpoint\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"hugging-face-embeddings\",\n body: {\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"hugging-face-embeddings\",\n \"body\" => [\n \"service\" => \"hugging_face\",\n \"service_settings\" => [\n \"api_key\" => \"hugging-face-access-token\",\n \"url\" => \"url-endpoint\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"hugging_face\",\"service_settings\":{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/hugging-face-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"hugging-face-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"hugging_face\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"hugging-face-access-token\\\",\\\"url\\\":\\\"url-endpoint\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"hugging-face-rerank\",\n inference_config={\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n },\n \"task_settings\": {\n \"return_documents\": True,\n \"top_n\": 3\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"hugging-face-rerank\",\n inference_config: {\n service: \"hugging_face\",\n service_settings: {\n api_key: \"hugging-face-access-token\",\n url: \"url-endpoint\",\n },\n task_settings: {\n return_documents: true,\n top_n: 3,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"hugging-face-rerank\",\n body: {\n \"service\": \"hugging_face\",\n \"service_settings\": {\n \"api_key\": \"hugging-face-access-token\",\n \"url\": \"url-endpoint\"\n },\n \"task_settings\": {\n \"return_documents\": true,\n \"top_n\": 3\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"hugging-face-rerank\",\n \"body\" => [\n \"service\" => \"hugging_face\",\n \"service_settings\" => [\n \"api_key\" => \"hugging-face-access-token\",\n \"url\" => \"url-endpoint\",\n ],\n \"task_settings\" => [\n \"return_documents\" => true,\n \"top_n\" => 3,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"hugging_face\",\"service_settings\":{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"},\"task_settings\":{\"return_documents\":true,\"top_n\":3}}' \"$ELASTICSEARCH_URL/_inference/rerank/hugging-face-rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"hugging-face-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"hugging_face\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"hugging-face-access-token\\\",\\\"url\\\":\\\"url-endpoint\\\"}\"))\n .taskSettings(JsonData.fromJson(\"{\\\"return_documents\\\":true,\\\"top_n\\\":3}\"))\n )\n);\n" - } - ], - "specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"amazon_bedrock_embeddings\",\n inference_config={\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-embed-text-v2:0\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"amazon_bedrock_embeddings\",\n inference_config: {\n service: \"amazonbedrock\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n provider: \"amazontitan\",\n model: \"amazon.titan-embed-text-v2:0\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"amazon_bedrock_embeddings\",\n body: {\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-embed-text-v2:0\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"amazon_bedrock_embeddings\",\n \"body\" => [\n \"service\" => \"amazonbedrock\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"provider\" => \"amazontitan\",\n \"model\" => \"amazon.titan-embed-text-v2:0\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-embed-text-v2:0\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/amazon_bedrock_embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"amazon_bedrock_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"amazonbedrock\")\n .serviceSettings(JsonData.fromJson(\"{\\\"access_key\\\":\\\"AWS-access-key\\\",\\\"secret_key\\\":\\\"AWS-secret-key\\\",\\\"region\\\":\\\"us-east-1\\\",\\\"provider\\\":\\\"amazontitan\\\",\\\"model\\\":\\\"amazon.titan-embed-text-v2:0\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"openai-completion\",\n inference_config={\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"gpt-3.5-turbo\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"openai-completion\",\n inference_config: {\n service: \"openai\",\n service_settings: {\n api_key: \"OpenAI-API-Key\",\n model_id: \"gpt-3.5-turbo\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"openai-completion\",\n body: {\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"gpt-3.5-turbo\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"service\" => \"openai\",\n \"service_settings\" => [\n \"api_key\" => \"OpenAI-API-Key\",\n \"model_id\" => \"gpt-3.5-turbo\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"openai\",\"service_settings\":{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"gpt-3.5-turbo\"}}' \"$ELASTICSEARCH_URL/_inference/completion/openai-completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"openai-completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"openai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"OpenAI-API-Key\\\",\\\"model_id\\\":\\\"gpt-3.5-turbo\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"amazon_bedrock_completion\",\n inference_config={\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-text-premier-v1:0\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"amazon_bedrock_completion\",\n inference_config: {\n service: \"amazonbedrock\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n provider: \"amazontitan\",\n model: \"amazon.titan-text-premier-v1:0\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"amazon_bedrock_completion\",\n body: {\n \"service\": \"amazonbedrock\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"provider\": \"amazontitan\",\n \"model\": \"amazon.titan-text-premier-v1:0\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"amazon_bedrock_completion\",\n \"body\" => [\n \"service\" => \"amazonbedrock\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"provider\" => \"amazontitan\",\n \"model\" => \"amazon.titan-text-premier-v1:0\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-text-premier-v1:0\"}}' \"$ELASTICSEARCH_URL/_inference/completion/amazon_bedrock_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"amazon_bedrock_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"amazonbedrock\")\n .serviceSettings(JsonData.fromJson(\"{\\\"access_key\\\":\\\"AWS-access-key\\\",\\\"secret_key\\\":\\\"AWS-secret-key\\\",\\\"region\\\":\\\"us-east-1\\\",\\\"provider\\\":\\\"amazontitan\\\",\\\"model\\\":\\\"amazon.titan-text-premier-v1:0\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"openai-embeddings\",\n inference_config={\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"text-embedding-3-small\",\n \"dimensions\": 128\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n inference_config: {\n service: \"openai\",\n service_settings: {\n api_key: \"OpenAI-API-Key\",\n model_id: \"text-embedding-3-small\",\n dimensions: 128,\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"openai-embeddings\",\n body: {\n \"service\": \"openai\",\n \"service_settings\": {\n \"api_key\": \"OpenAI-API-Key\",\n \"model_id\": \"text-embedding-3-small\",\n \"dimensions\": 128\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"openai-embeddings\",\n \"body\" => [\n \"service\" => \"openai\",\n \"service_settings\" => [\n \"api_key\" => \"OpenAI-API-Key\",\n \"model_id\" => \"text-embedding-3-small\",\n \"dimensions\" => 128,\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"openai\",\"service_settings\":{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"text-embedding-3-small\",\"dimensions\":128}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"openai-embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"openai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"OpenAI-API-Key\\\",\\\"model_id\\\":\\\"text-embedding-3-small\\\",\\\"dimensions\\\":128}\"))\n )\n);\n" - } - ], - "specification/inference/rerank/examples/request/RerankRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.rerank(\n inference_id=\"cohere_rerank\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.rerank({\n inference_id: \"cohere_rerank\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.rerank(\n inference_id: \"cohere_rerank\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"cohere_rerank\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\"}' \"$ELASTICSEARCH_URL/_inference/rerank/cohere_rerank\"" - }, - { - "language": "Java", - "code": "client.inference().rerank(r -> r\n .inferenceId(\"cohere_rerank\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" - } - ], - "specification/inference/rerank/examples/request/RerankRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.rerank(\n inference_id=\"bge-reranker-base-mkn\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n return_documents=False,\n top_n=2,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.rerank({\n inference_id: \"bge-reranker-base-mkn\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n return_documents: false,\n top_n: 2,\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.rerank(\n inference_id: \"bge-reranker-base-mkn\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\",\n \"return_documents\": false,\n \"top_n\": 2\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"bge-reranker-base-mkn\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n \"return_documents\" => false,\n \"top_n\" => 2,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\",\"return_documents\":false,\"top_n\":2}' \"$ELASTICSEARCH_URL/_inference/rerank/bge-reranker-base-mkn\"" - }, - { - "language": "Java", - "code": "client.inference().rerank(r -> r\n .inferenceId(\"bge-reranker-base-mkn\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" - } - ], - "specification/inference/rerank/examples/request/RerankRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.rerank(\n inference_id=\"bge-reranker-base-mkn\",\n input=[\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n query=\"star wars main character\",\n return_documents=True,\n top_n=3,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.rerank({\n inference_id: \"bge-reranker-base-mkn\",\n input: [\"luke\", \"like\", \"leia\", \"chewy\", \"r2d2\", \"star\", \"wars\"],\n query: \"star wars main character\",\n return_documents: true,\n top_n: 3,\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.rerank(\n inference_id: \"bge-reranker-base-mkn\",\n body: {\n \"input\": [\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\"\n ],\n \"query\": \"star wars main character\",\n \"return_documents\": true,\n \"top_n\": 3\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->rerank([\n \"inference_id\" => \"bge-reranker-base-mkn\",\n \"body\" => [\n \"input\" => array(\n \"luke\",\n \"like\",\n \"leia\",\n \"chewy\",\n \"r2d2\",\n \"star\",\n \"wars\",\n ),\n \"query\" => \"star wars main character\",\n \"return_documents\" => true,\n \"top_n\" => 3,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":[\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"],\"query\":\"star wars main character\",\"return_documents\":true,\"top_n\":3}' \"$ELASTICSEARCH_URL/_inference/rerank/bge-reranker-base-mkn\"" - }, - { - "language": "Java", - "code": "client.inference().rerank(r -> r\n .inferenceId(\"bge-reranker-base-mkn\")\n .input(List.of(\"luke\",\"like\",\"leia\",\"chewy\",\"r2d2\",\"star\",\"wars\"))\n .query(\"star wars main character\")\n);\n" - } - ], - "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"alibabacloud_ai_search_embeddings\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"alibabacloud_ai_search_embeddings\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-text-embedding-001\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"alibabacloud_ai_search_embeddings\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"alibabacloud_ai_search_embeddings\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-text-embedding-001\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/alibabacloud_ai_search_embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-text-embedding-001\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"alibabacloud_ai_search_sparse\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-sparse-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"alibabacloud_ai_search_sparse\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-text-sparse-embedding-001\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"alibabacloud_ai_search_sparse\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-text-sparse-embedding-001\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"alibabacloud_ai_search_sparse\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-text-sparse-embedding-001\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-sparse-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/alibabacloud_ai_search_sparse\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_sparse\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-text-sparse-embedding-001\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"alibabacloud_ai_search_rerank\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-bge-reranker-larger\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"alibabacloud_ai_search_rerank\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-bge-reranker-larger\",\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n workspace: \"default\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"alibabacloud_ai_search_rerank\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-bge-reranker-larger\",\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\": \"default\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"alibabacloud_ai_search_rerank\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-bge-reranker-larger\",\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-bge-reranker-larger\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/alibabacloud_ai_search_rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-bge-reranker-larger\\\",\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"alibabacloud_ai_search_completion\",\n inference_config={\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-qwen-turbo\",\n \"workspace\": \"default\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"alibabacloud_ai_search_completion\",\n inference_config: {\n service: \"alibabacloud-ai-search\",\n service_settings: {\n host: \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n api_key: \"AlibabaCloud-API-Key\",\n service_id: \"ops-qwen-turbo\",\n workspace: \"default\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"alibabacloud_ai_search_completion\",\n body: {\n \"service\": \"alibabacloud-ai-search\",\n \"service_settings\": {\n \"host\": \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\": \"AlibabaCloud-API-Key\",\n \"service_id\": \"ops-qwen-turbo\",\n \"workspace\": \"default\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"alibabacloud_ai_search_completion\",\n \"body\" => [\n \"service\" => \"alibabacloud-ai-search\",\n \"service_settings\" => [\n \"host\" => \"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\n \"api_key\" => \"AlibabaCloud-API-Key\",\n \"service_id\" => \"ops-qwen-turbo\",\n \"workspace\" => \"default\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-qwen-turbo\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/completion/alibabacloud_ai_search_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"alibabacloud_ai_search_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"alibabacloud-ai-search\")\n .serviceSettings(JsonData.fromJson(\"{\\\"host\\\":\\\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\\\",\\\"api_key\\\":\\\"AlibabaCloud-API-Key\\\",\\\"service_id\\\":\\\"ops-qwen-turbo\\\",\\\"workspace\\\":\\\"default\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"azure_openai_embeddings\",\n inference_config={\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"azure_openai_embeddings\",\n inference_config: {\n service: \"azureopenai\",\n service_settings: {\n api_key: \"Api-Key\",\n resource_name: \"Resource-name\",\n deployment_id: \"Deployment-id\",\n api_version: \"2024-02-01\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"azure_openai_embeddings\",\n body: {\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"azure_openai_embeddings\",\n \"body\" => [\n \"service\" => \"azureopenai\",\n \"service_settings\" => [\n \"api_key\" => \"Api-Key\",\n \"resource_name\" => \"Resource-name\",\n \"deployment_id\" => \"Deployment-id\",\n \"api_version\" => \"2024-02-01\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_openai_embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"azure_openai_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"azureopenai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Api-Key\\\",\\\"resource_name\\\":\\\"Resource-name\\\",\\\"deployment_id\\\":\\\"Deployment-id\\\",\\\"api_version\\\":\\\"2024-02-01\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"azure_openai_completion\",\n inference_config={\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"azure_openai_completion\",\n inference_config: {\n service: \"azureopenai\",\n service_settings: {\n api_key: \"Api-Key\",\n resource_name: \"Resource-name\",\n deployment_id: \"Deployment-id\",\n api_version: \"2024-02-01\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"azure_openai_completion\",\n body: {\n \"service\": \"azureopenai\",\n \"service_settings\": {\n \"api_key\": \"Api-Key\",\n \"resource_name\": \"Resource-name\",\n \"deployment_id\": \"Deployment-id\",\n \"api_version\": \"2024-02-01\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"azure_openai_completion\",\n \"body\" => [\n \"service\" => \"azureopenai\",\n \"service_settings\" => [\n \"api_key\" => \"Api-Key\",\n \"resource_name\" => \"Resource-name\",\n \"deployment_id\" => \"Deployment-id\",\n \"api_version\" => \"2024-02-01\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_openai_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"azure_openai_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"azureopenai\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Api-Key\\\",\\\"resource_name\\\":\\\"Resource-name\\\",\\\"deployment_id\\\":\\\"Deployment-id\\\",\\\"api_version\\\":\\\"2024-02-01\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.stream_completion(\n inference_id=\"openai-completion\",\n input=\"What is Elastic?\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.streamCompletion({\n inference_id: \"openai-completion\",\n input: \"What is Elastic?\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.stream_completion(\n inference_id: \"openai-completion\",\n body: {\n \"input\": \"What is Elastic?\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->streamCompletion([\n \"inference_id\" => \"openai-completion\",\n \"body\" => [\n \"input\" => \"What is Elastic?\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"input\":\"What is Elastic?\"}' \"$ELASTICSEARCH_URL/_inference/completion/openai-completion/_stream\"" - }, - { - "language": "Java", - "code": "client.inference().streamCompletion(s -> s\n .inferenceId(\"openai-completion\")\n .input(\"What is Elastic?\")\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-e5-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 3,\n max_number_of_allocations: 10,\n },\n num_threads: 1,\n model_id: \".multilingual-e5-small\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 3,\n \"max_number_of_allocations\": 10\n },\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-e5-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 3,\n \"max_number_of_allocations\" => 10,\n ],\n \"num_threads\" => 1,\n \"model_id\" => \".multilingual-e5-small\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-e5-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":3,\\\"max_number_of_allocations\\\":10},\\\"num_threads\\\":1,\\\"model_id\\\":\\\".multilingual-e5-small\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-msmarco-minilm-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \"msmarco-MiniLM-L12-cos-v5\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-msmarco-minilm-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n model_id: \"msmarco-MiniLM-L12-cos-v5\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-msmarco-minilm-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \"msmarco-MiniLM-L12-cos-v5\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-msmarco-minilm-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n \"model_id\" => \"msmarco-MiniLM-L12-cos-v5\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\"msmarco-MiniLM-L12-cos-v5\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-msmarco-minilm-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-msmarco-minilm-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1,\\\"model_id\\\":\\\"msmarco-MiniLM-L12-cos-v5\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"my-e5-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n num_allocations: 1,\n num_threads: 1,\n model_id: \".multilingual-e5-small\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"my-e5-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"num_allocations\": 1,\n \"num_threads\": 1,\n \"model_id\": \".multilingual-e5-small\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"my-e5-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"num_allocations\" => 1,\n \"num_threads\" => 1,\n \"model_id\" => \".multilingual-e5-small\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-e5-model\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"num_allocations\\\":1,\\\"num_threads\\\":1,\\\"model_id\\\":\\\".multilingual-e5-small\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"my-elastic-rerank\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"model_id\": \".rerank-v1\",\n \"num_threads\": 1,\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"my-elastic-rerank\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n model_id: \".rerank-v1\",\n num_threads: 1,\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 1,\n max_number_of_allocations: 4,\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"my-elastic-rerank\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"model_id\": \".rerank-v1\",\n \"num_threads\": 1,\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"my-elastic-rerank\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"model_id\" => \".rerank-v1\",\n \"num_threads\" => 1,\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 1,\n \"max_number_of_allocations\" => 4,\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"model_id\":\".rerank-v1\",\"num_threads\":1,\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4}}}' \"$ELASTICSEARCH_URL/_inference/rerank/my-elastic-rerank\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-elastic-rerank\")\n .taskType(TaskType.Rerank)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"model_id\\\":\\\".rerank-v1\\\",\\\"num_threads\\\":1,\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":1,\\\"max_number_of_allocations\\\":4}}\"))\n )\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"my-elser-model\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": True,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n },\n \"num_threads\": 1,\n \"model_id\": \".elser_model_2\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n adaptive_allocations: {\n enabled: true,\n min_number_of_allocations: 1,\n max_number_of_allocations: 4,\n },\n num_threads: 1,\n model_id: \".elser_model_2\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"my-elser-model\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"adaptive_allocations\": {\n \"enabled\": true,\n \"min_number_of_allocations\": 1,\n \"max_number_of_allocations\": 4\n },\n \"num_threads\": 1,\n \"model_id\": \".elser_model_2\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"my-elser-model\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"adaptive_allocations\" => [\n \"enabled\" => true,\n \"min_number_of_allocations\" => 1,\n \"max_number_of_allocations\" => 4,\n ],\n \"num_threads\" => 1,\n \"model_id\" => \".elser_model_2\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4},\"num_threads\":1,\"model_id\":\".elser_model_2\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"my-elser-model\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"adaptive_allocations\\\":{\\\"enabled\\\":true,\\\"min_number_of_allocations\\\":1,\\\"max_number_of_allocations\\\":4},\\\"num_threads\\\":1,\\\"model_id\\\":\\\".elser_model_2\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"use_existing_deployment\",\n inference_config={\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"deployment_id\": \".elser_model_2\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"use_existing_deployment\",\n inference_config: {\n service: \"elasticsearch\",\n service_settings: {\n deployment_id: \".elser_model_2\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"use_existing_deployment\",\n body: {\n \"service\": \"elasticsearch\",\n \"service_settings\": {\n \"deployment_id\": \".elser_model_2\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"use_existing_deployment\",\n \"body\" => [\n \"service\" => \"elasticsearch\",\n \"service_settings\" => [\n \"deployment_id\" => \".elser_model_2\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"deployment_id\":\".elser_model_2\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/use_existing_deployment\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"use_existing_deployment\")\n .taskType(TaskType.SparseEmbedding)\n .inferenceConfig(i -> i\n .service(\"elasticsearch\")\n .serviceSettings(JsonData.fromJson(\"{\\\"deployment_id\\\":\\\".elser_model_2\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"azure_ai_studio_completion\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"databricks\",\n \"endpoint_type\": \"realtime\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"azure_ai_studio_completion\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-URI\",\n provider: \"databricks\",\n endpoint_type: \"realtime\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"azure_ai_studio_completion\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"databricks\",\n \"endpoint_type\": \"realtime\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"azure_ai_studio_completion\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-URI\",\n \"provider\" => \"databricks\",\n \"endpoint_type\" => \"realtime\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"provider\":\"databricks\",\"endpoint_type\":\"realtime\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_ai_studio_completion\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"azure_ai_studio_completion\")\n .taskType(TaskType.Completion)\n .inferenceConfig(i -> i\n .service(\"azureaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Azure-AI-Studio-API-key\\\",\\\"target\\\":\\\"Target-URI\\\",\\\"provider\\\":\\\"databricks\\\",\\\"endpoint_type\\\":\\\"realtime\\\"}\"))\n )\n);\n" - } - ], - "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"azure_ai_studio_embeddings\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-Uri\",\n \"provider\": \"openai\",\n \"endpoint_type\": \"token\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"azure_ai_studio_embeddings\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-Uri\",\n provider: \"openai\",\n endpoint_type: \"token\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"azure_ai_studio_embeddings\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-Uri\",\n \"provider\": \"openai\",\n \"endpoint_type\": \"token\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"azure_ai_studio_embeddings\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-Uri\",\n \"provider\" => \"openai\",\n \"endpoint_type\" => \"token\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-Uri\",\"provider\":\"openai\",\"endpoint_type\":\"token\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_ai_studio_embeddings\"" - }, - { - "language": "Java", - "code": "client.inference().put(p -> p\n .inferenceId(\"azure_ai_studio_embeddings\")\n .taskType(TaskType.TextEmbedding)\n .inferenceConfig(i -> i\n .service(\"azureaistudio\")\n .serviceSettings(JsonData.fromJson(\"{\\\"api_key\\\":\\\"Azure-AI-Studio-API-key\\\",\\\"target\\\":\\\"Target-Uri\\\",\\\"provider\\\":\\\"openai\\\",\\\"endpoint_type\\\":\\\"token\\\"}\"))\n )\n);\n" - } - ], - "specification/query_rules/list_rulesets/examples/request/QueryRulesetListRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.list_rulesets(\n from=\"0\",\n size=\"3\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.listRulesets({\n from: 0,\n size: 3,\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.list_rulesets(\n from: \"0\",\n size: \"3\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->listRulesets([\n \"from\" => \"0\",\n \"size\" => \"3\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/?from=0&size=3\"" - }, - { - "language": "Java", - "code": "client.queryRules().listRulesets(l -> l\n .from(0)\n .size(3)\n);\n" - } - ], - "specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.put_ruleset(\n ruleset_id=\"my-ruleset\",\n rules=[\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.putRuleset({\n ruleset_id: \"my-ruleset\",\n rules: [\n {\n rule_id: \"my-rule1\",\n type: \"pinned\",\n criteria: [\n {\n type: \"contains\",\n metadata: \"user_query\",\n values: [\"pugs\", \"puggles\"],\n },\n {\n type: \"exact\",\n metadata: \"user_country\",\n values: [\"us\"],\n },\n ],\n actions: {\n ids: [\"id1\", \"id2\"],\n },\n },\n {\n rule_id: \"my-rule2\",\n type: \"pinned\",\n criteria: [\n {\n type: \"fuzzy\",\n metadata: \"user_query\",\n values: [\"rescue dogs\"],\n },\n ],\n actions: {\n docs: [\n {\n _index: \"index1\",\n _id: \"id3\",\n },\n {\n _index: \"index2\",\n _id: \"id4\",\n },\n ],\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.put_ruleset(\n ruleset_id: \"my-ruleset\",\n body: {\n \"rules\": [\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->putRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"rules\" => array(\n [\n \"rule_id\" => \"my-rule1\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"contains\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"pugs\",\n \"puggles\",\n ),\n ],\n [\n \"type\" => \"exact\",\n \"metadata\" => \"user_country\",\n \"values\" => array(\n \"us\",\n ),\n ],\n ),\n \"actions\" => [\n \"ids\" => array(\n \"id1\",\n \"id2\",\n ),\n ],\n ],\n [\n \"rule_id\" => \"my-rule2\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"fuzzy\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"rescue dogs\",\n ),\n ],\n ),\n \"actions\" => [\n \"docs\" => array(\n [\n \"_index\" => \"index1\",\n \"_id\" => \"id3\",\n ],\n [\n \"_index\" => \"index2\",\n \"_id\" => \"id4\",\n ],\n ),\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"rule_id\":\"my-rule1\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"contains\",\"metadata\":\"user_query\",\"values\":[\"pugs\",\"puggles\"]},{\"type\":\"exact\",\"metadata\":\"user_country\",\"values\":[\"us\"]}],\"actions\":{\"ids\":[\"id1\",\"id2\"]}},{\"rule_id\":\"my-rule2\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"fuzzy\",\"metadata\":\"user_query\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" - }, - { - "language": "Java", - "code": "client.queryRules().putRuleset(p -> p\n .rules(List.of(QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule1\")\n .type(QueryRuleType.Pinned)\n .criteria(List.of(QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Contains)\n .metadata(\"user_query\")\n .values(List.of(JsonData.fromJson(\"\\\"pugs\\\"\"),JsonData.fromJson(\"\\\"puggles\\\"\")))),QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Exact)\n .metadata(\"user_country\")\n .values(JsonData.fromJson(\"\\\"us\\\"\")))))\n .actions(a -> a\n .ids(List.of(\"id1\",\"id2\"))\n )),QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule2\")\n .type(QueryRuleType.Pinned)\n .criteria(c -> c\n .type(QueryRuleCriteriaType.Fuzzy)\n .metadata(\"user_query\")\n .values(JsonData.fromJson(\"\\\"rescue dogs\\\"\"))\n )\n .actions(a -> a\n .docs(List.of(PinnedDoc.of(pi -> pi\n .id(\"id3\")\n .index(\"index1\")),PinnedDoc.of(pi -> pi\n .id(\"id4\")\n .index(\"index2\"))))\n ))))\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.test(\n ruleset_id=\"my-ruleset\",\n match_criteria={\n \"query_string\": \"puggles\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.test({\n ruleset_id: \"my-ruleset\",\n match_criteria: {\n query_string: \"puggles\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.test(\n ruleset_id: \"my-ruleset\",\n body: {\n \"match_criteria\": {\n \"query_string\": \"puggles\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->test([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"match_criteria\" => [\n \"query_string\" => \"puggles\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"match_criteria\":{\"query_string\":\"puggles\"}}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_test\"" - }, - { - "language": "Java", - "code": "client.queryRules().test(t -> t\n .matchCriteria(\"query_string\", JsonData.fromJson(\"\\\"puggles\\\"\"))\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/delete_rule/examples/request/QueryRulesDeleteRuleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.delete_rule(\n ruleset_id=\"my-ruleset\",\n rule_id=\"my-rule1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.deleteRule({\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.delete_rule(\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->deleteRule([\n \"ruleset_id\" => \"my-ruleset\",\n \"rule_id\" => \"my-rule1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_rule/my-rule1\"" - }, - { - "language": "Java", - "code": "client.queryRules().deleteRule(d -> d\n .ruleId(\"my-rule1\")\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/get_rule/examples/request/QueryRuleGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.get_rule(\n ruleset_id=\"my-ruleset\",\n rule_id=\"my-rule1\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.getRule({\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.get_rule(\n ruleset_id: \"my-ruleset\",\n rule_id: \"my-rule1\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->getRule([\n \"ruleset_id\" => \"my-ruleset\",\n \"rule_id\" => \"my-rule1\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/_rule/my-rule1\"" - }, - { - "language": "Java", - "code": "client.queryRules().getRule(g -> g\n .ruleId(\"my-rule1\")\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/get_ruleset/examples/request/QueryRulesetGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.get_ruleset(\n ruleset_id=\"my-ruleset\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.getRuleset({\n ruleset_id: \"my-ruleset\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.get_ruleset(\n ruleset_id: \"my-ruleset\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->getRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/\"" - }, - { - "language": "Java", - "code": "client.queryRules().getRuleset(g -> g\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/delete_ruleset/examples/request/QueryRulesDeleteRulesetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.delete_ruleset(\n ruleset_id=\"my-ruleset\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.deleteRuleset({\n ruleset_id: \"my-ruleset\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.delete_ruleset(\n ruleset_id: \"my-ruleset\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->deleteRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query_rules/my-ruleset/\"" - }, - { - "language": "Java", - "code": "client.queryRules().deleteRuleset(d -> d\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.query_rules.put_ruleset(\n ruleset_id=\"my-ruleset\",\n rules=[\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ],\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.queryRules.putRuleset({\n ruleset_id: \"my-ruleset\",\n rules: [\n {\n rule_id: \"my-rule1\",\n type: \"pinned\",\n criteria: [\n {\n type: \"contains\",\n metadata: \"user_query\",\n values: [\"pugs\", \"puggles\"],\n },\n {\n type: \"exact\",\n metadata: \"user_country\",\n values: [\"us\"],\n },\n ],\n actions: {\n ids: [\"id1\", \"id2\"],\n },\n },\n {\n rule_id: \"my-rule2\",\n type: \"pinned\",\n criteria: [\n {\n type: \"fuzzy\",\n metadata: \"user_query\",\n values: [\"rescue dogs\"],\n },\n ],\n actions: {\n docs: [\n {\n _index: \"index1\",\n _id: \"id3\",\n },\n {\n _index: \"index2\",\n _id: \"id4\",\n },\n ],\n },\n },\n ],\n});" - }, - { - "language": "Ruby", - "code": "response = client.query_rules.put_ruleset(\n ruleset_id: \"my-ruleset\",\n body: {\n \"rules\": [\n {\n \"rule_id\": \"my-rule1\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"contains\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"pugs\",\n \"puggles\"\n ]\n },\n {\n \"type\": \"exact\",\n \"metadata\": \"user_country\",\n \"values\": [\n \"us\"\n ]\n }\n ],\n \"actions\": {\n \"ids\": [\n \"id1\",\n \"id2\"\n ]\n }\n },\n {\n \"rule_id\": \"my-rule2\",\n \"type\": \"pinned\",\n \"criteria\": [\n {\n \"type\": \"fuzzy\",\n \"metadata\": \"user_query\",\n \"values\": [\n \"rescue dogs\"\n ]\n }\n ],\n \"actions\": {\n \"docs\": [\n {\n \"_index\": \"index1\",\n \"_id\": \"id3\"\n },\n {\n \"_index\": \"index2\",\n \"_id\": \"id4\"\n }\n ]\n }\n }\n ]\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->queryRules()->putRuleset([\n \"ruleset_id\" => \"my-ruleset\",\n \"body\" => [\n \"rules\" => array(\n [\n \"rule_id\" => \"my-rule1\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"contains\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"pugs\",\n \"puggles\",\n ),\n ],\n [\n \"type\" => \"exact\",\n \"metadata\" => \"user_country\",\n \"values\" => array(\n \"us\",\n ),\n ],\n ),\n \"actions\" => [\n \"ids\" => array(\n \"id1\",\n \"id2\",\n ),\n ],\n ],\n [\n \"rule_id\" => \"my-rule2\",\n \"type\" => \"pinned\",\n \"criteria\" => array(\n [\n \"type\" => \"fuzzy\",\n \"metadata\" => \"user_query\",\n \"values\" => array(\n \"rescue dogs\",\n ),\n ],\n ),\n \"actions\" => [\n \"docs\" => array(\n [\n \"_index\" => \"index1\",\n \"_id\" => \"id3\",\n ],\n [\n \"_index\" => \"index2\",\n \"_id\" => \"id4\",\n ],\n ),\n ],\n ],\n ),\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":[{\"rule_id\":\"my-rule1\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"contains\",\"metadata\":\"user_query\",\"values\":[\"pugs\",\"puggles\"]},{\"type\":\"exact\",\"metadata\":\"user_country\",\"values\":[\"us\"]}],\"actions\":{\"ids\":[\"id1\",\"id2\"]}},{\"rule_id\":\"my-rule2\",\"type\":\"pinned\",\"criteria\":[{\"type\":\"fuzzy\",\"metadata\":\"user_query\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" - }, - { - "language": "Java", - "code": "client.queryRules().putRuleset(p -> p\n .rules(List.of(QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule1\")\n .type(QueryRuleType.Pinned)\n .criteria(List.of(QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Contains)\n .metadata(\"user_query\")\n .values(List.of(JsonData.fromJson(\"\\\"pugs\\\"\"),JsonData.fromJson(\"\\\"puggles\\\"\")))),QueryRuleCriteria.of(qu -> qu\n .type(QueryRuleCriteriaType.Exact)\n .metadata(\"user_country\")\n .values(JsonData.fromJson(\"\\\"us\\\"\")))))\n .actions(a -> a\n .ids(List.of(\"id1\",\"id2\"))\n )),QueryRule.queryRuleOf(q -> q\n .ruleId(\"my-rule2\")\n .type(QueryRuleType.Pinned)\n .criteria(c -> c\n .type(QueryRuleCriteriaType.Fuzzy)\n .metadata(\"user_query\")\n .values(JsonData.fromJson(\"\\\"rescue dogs\\\"\"))\n )\n .actions(a -> a\n .docs(List.of(PinnedDoc.of(pi -> pi\n .id(\"id3\")\n .index(\"index1\")),PinnedDoc.of(pi -> pi\n .id(\"id4\")\n .index(\"index2\"))))\n ))))\n .rulesetId(\"my-ruleset\")\n);\n" - } - ], - "specification/enrich/delete_policy/examples/request/EnrichDeletePolicyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.enrich.delete_policy(\n name=\"my-policy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.enrich.deletePolicy({\n name: \"my-policy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.enrich.delete_policy(\n name: \"my-policy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->enrich()->deletePolicy([\n \"name\" => \"my-policy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy\"" - }, - { - "language": "Java", - "code": "client.enrich().deletePolicy(d -> d\n .name(\"my-policy\")\n);\n" - } - ], - "specification/enrich/execute_policy/examples/request/EnrichExecutePolicyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.enrich.execute_policy(\n name=\"my-policy\",\n wait_for_completion=False,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.enrich.executePolicy({\n name: \"my-policy\",\n wait_for_completion: \"false\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.enrich.execute_policy(\n name: \"my-policy\",\n wait_for_completion: \"false\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->enrich()->executePolicy([\n \"name\" => \"my-policy\",\n \"wait_for_completion\" => \"false\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy/_execute?wait_for_completion=false\"" - }, - { - "language": "Java", - "code": "client.enrich().executePolicy(e -> e\n .name(\"my-policy\")\n .waitForCompletion(false)\n);\n" - } - ], - "specification/enrich/get_policy/examples/request/EnrichGetPolicyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.enrich.get_policy(\n name=\"my-policy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.enrich.getPolicy({\n name: \"my-policy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.enrich.get_policy(\n name: \"my-policy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->enrich()->getPolicy([\n \"name\" => \"my-policy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/policy/my-policy\"" - }, - { - "language": "Java", - "code": "client.enrich().getPolicy(g -> g\n .name(\"my-policy\")\n);\n" - } - ], - "specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.enrich.put_policy(\n name=\"postal_policy\",\n geo_match={\n \"indices\": \"postal_codes\",\n \"match_field\": \"location\",\n \"enrich_fields\": [\n \"location\",\n \"postal_code\"\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.enrich.putPolicy({\n name: \"postal_policy\",\n geo_match: {\n indices: \"postal_codes\",\n match_field: \"location\",\n enrich_fields: [\"location\", \"postal_code\"],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.enrich.put_policy(\n name: \"postal_policy\",\n body: {\n \"geo_match\": {\n \"indices\": \"postal_codes\",\n \"match_field\": \"location\",\n \"enrich_fields\": [\n \"location\",\n \"postal_code\"\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->enrich()->putPolicy([\n \"name\" => \"postal_policy\",\n \"body\" => [\n \"geo_match\" => [\n \"indices\" => \"postal_codes\",\n \"match_field\" => \"location\",\n \"enrich_fields\" => array(\n \"location\",\n \"postal_code\",\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"geo_match\":{\"indices\":\"postal_codes\",\"match_field\":\"location\",\"enrich_fields\":[\"location\",\"postal_code\"]}}' \"$ELASTICSEARCH_URL/_enrich/policy/postal_policy\"" - }, - { - "language": "Java", - "code": "client.enrich().putPolicy(p -> p\n .geoMatch(g -> g\n .enrichFields(List.of(\"location\",\"postal_code\"))\n .indices(\"postal_codes\")\n .matchField(\"location\")\n )\n .name(\"postal_policy\")\n);\n" - } - ], - "specification/enrich/stats/examples/request/EnrichStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.enrich.stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.enrich.stats();" - }, - { - "language": "Ruby", - "code": "response = client.enrich.stats" - }, - { - "language": "PHP", - "code": "$resp = $client->enrich()->stats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_enrich/_stats\"" - }, - { - "language": "Java", - "code": "client.enrich().stats(s -> s);\n" - } - ], - "specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.async_search.submit(\n index=\"sales*\",\n size=\"0\",\n sort=[\n {\n \"date\": {\n \"order\": \"asc\"\n }\n }\n ],\n aggs={\n \"sale_date\": {\n \"date_histogram\": {\n \"field\": \"date\",\n \"calendar_interval\": \"1d\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.asyncSearch.submit({\n index: \"sales*\",\n size: 0,\n sort: [\n {\n date: {\n order: \"asc\",\n },\n },\n ],\n aggs: {\n sale_date: {\n date_histogram: {\n field: \"date\",\n calendar_interval: \"1d\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.async_search.submit(\n index: \"sales*\",\n size: \"0\",\n body: {\n \"sort\": [\n {\n \"date\": {\n \"order\": \"asc\"\n }\n }\n ],\n \"aggs\": {\n \"sale_date\": {\n \"date_histogram\": {\n \"field\": \"date\",\n \"calendar_interval\": \"1d\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->asyncSearch()->submit([\n \"index\" => \"sales*\",\n \"size\" => \"0\",\n \"body\" => [\n \"sort\" => array(\n [\n \"date\" => [\n \"order\" => \"asc\",\n ],\n ],\n ),\n \"aggs\" => [\n \"sale_date\" => [\n \"date_histogram\" => [\n \"field\" => \"date\",\n \"calendar_interval\" => \"1d\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":[{\"date\":{\"order\":\"asc\"}}],\"aggs\":{\"sale_date\":{\"date_histogram\":{\"field\":\"date\",\"calendar_interval\":\"1d\"}}}}' \"$ELASTICSEARCH_URL/sales*/_async_search?size=0\"" - }, - { - "language": "Java", - "code": "client.asyncSearch().submit(s -> s\n .aggregations(\"sale_date\", a -> a\n .dateHistogram(d -> d\n .calendarInterval(CalendarInterval.Day)\n .field(\"date\")\n )\n )\n .index(\"sales*\")\n .size(0)\n .sort(so -> so\n .field(f -> f\n .field(\"date\")\n .order(SortOrder.Asc)\n )\n )\n,Void.class);\n" - } - ], - "specification/async_search/delete/examples/request/AsyncSearchDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.async_search.delete(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.asyncSearch.delete({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.async_search.delete(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->asyncSearch()->delete([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" - }, - { - "language": "Java", - "code": "client.asyncSearch().delete(d -> d\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" - } - ], - "specification/async_search/get/examples/request/AsyncSearchGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.async_search.get(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.asyncSearch.get({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.async_search.get(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->asyncSearch()->get([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" - }, - { - "language": "Java", - "code": "client.asyncSearch().get(g -> g\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" - } - ], - "specification/async_search/status/examples/request/AsyncSearchStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.async_search.status(\n id=\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.asyncSearch.status({\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.async_search.status(\n id: \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->asyncSearch()->status([\n \"id\" => \"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_async_search/status/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\"" - }, - { - "language": "Java", - "code": "client.asyncSearch().status(s -> s\n .id(\"FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=\")\n);\n" - } - ], - "specification/eql/get_status/examples/request/EqlGetStatusExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.eql.get_status(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.eql.getStatus({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.eql.get_status(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->eql()->getStatus([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/status/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"" - }, - { - "language": "Java", - "code": "client.eql().getStatus(g -> g\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n);\n" - } - ], - "specification/eql/delete/examples/request/EqlDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.eql.delete(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.eql.delete({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.eql.delete(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->eql()->delete([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\"" - }, - { - "language": "Java", - "code": "client.eql().delete(d -> d\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n);\n" - } - ], - "specification/eql/get/examples/request/EqlGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.eql.get(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout=\"2s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.eql.get({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"2s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.eql.get(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"2s\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->eql()->get([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n \"wait_for_completion_timeout\" => \"2s\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_eql/search/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=2s\"" - }, - { - "language": "Java", - "code": "client.eql().get(g -> g\n .id(\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\")\n .waitForCompletionTimeout(w -> w\n .offset(2)\n )\n);\n" - } - ], - "specification/eql/search/examples/request/EqlSearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.eql.search(\n index=\"my-data-stream\",\n query=\"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.eql.search({\n index: \"my-data-stream\",\n query:\n '\\n process where (process.name == \"cmd.exe\" and process.pid != 2013)\\n ',\n});" - }, - { - "language": "Ruby", - "code": "response = client.eql.search(\n index: \"my-data-stream\",\n body: {\n \"query\": \"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->eql()->search([\n \"index\" => \"my-data-stream\",\n \"body\" => [\n \"query\" => \"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" - }, - { - "language": "Java", - "code": "client.eql().search(s -> s\n .index(\"my-data-stream\")\n .query(\" process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013) \")\n);\n" - } - ], - "specification/eql/search/examples/request/EqlSearchRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.eql.search(\n index=\"my-data-stream\",\n query=\"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.eql.search({\n index: \"my-data-stream\",\n query:\n '\\n sequence by process.pid\\n [ file where file.name == \"cmd.exe\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \"regsvr32\") ]\\n ',\n});" - }, - { - "language": "Ruby", - "code": "response = client.eql.search(\n index: \"my-data-stream\",\n body: {\n \"query\": \"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->eql()->search([\n \"index\" => \"my-data-stream\",\n \"body\" => [\n \"query\" => \"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" - }, - { - "language": "Java", - "code": "client.eql().search(s -> s\n .index(\"my-data-stream\")\n .query(\" sequence by process.pid [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ][ process where stringContains(process.executable, \\\"regsvr32\\\") ] \")\n);\n" - } - ], - "specification/esql/async_query_stop/examples/request/EsqlAsyncQueryStopExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.esql.async_query_stop(\n id=\"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.esql.asyncQueryStop({\n id: \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.esql.async_query_stop(\n id: \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->esql()->asyncQueryStop([\n \"id\" => \"FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=/stop\"" - } - ], - "specification/esql/async_query/examples/request/AsyncQueryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.esql.async_query(\n query=\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n wait_for_completion_timeout=\"2s\",\n include_ccs_metadata=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.esql.asyncQuery({\n query:\n \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n wait_for_completion_timeout: \"2s\",\n include_ccs_metadata: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.esql.async_query(\n body: {\n \"query\": \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"wait_for_completion_timeout\": \"2s\",\n \"include_ccs_metadata\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->esql()->asyncQuery([\n \"body\" => [\n \"query\" => \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"wait_for_completion_timeout\" => \"2s\",\n \"include_ccs_metadata\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\"wait_for_completion_timeout\":\"2s\",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query/async\"" - } - ], - "specification/esql/async_query_get/examples/request/EsqlAsyncQueryGetExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.esql.async_query_get(\n id=\"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout=\"30s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.esql.asyncQueryGet({\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"30s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.esql.async_query_get(\n id: \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n wait_for_completion_timeout: \"30s\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->esql()->asyncQueryGet([\n \"id\" => \"FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=\",\n \"wait_for_completion_timeout\" => \"30s\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=?wait_for_completion_timeout=30s\"" - } - ], - "specification/esql/query/examples/request/QueryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.esql.query(\n query=\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n include_ccs_metadata=True,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.esql.query({\n query:\n \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n include_ccs_metadata: true,\n});" - }, - { - "language": "Ruby", - "code": "response = client.esql.query(\n body: {\n \"query\": \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"include_ccs_metadata\": true\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->esql()->query([\n \"body\" => [\n \"query\" => \"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\n \"include_ccs_metadata\" => true,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query\"" - }, - { - "language": "Java", - "code": "client.esql().query(q -> q\n .includeCcsMetadata(true)\n .query(\" FROM library,remote-*:library | EVAL year = DATE_TRUNC(1 YEARS, release_date) | STATS MAX(page_count) BY year | SORT year | LIMIT 5 \")\n);\n" - } - ], - "specification/esql/async_query_delete/examples/request/EsqlAsyncQueryDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.esql.async_query_delete(\n id=\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.esql.asyncQueryDelete({\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.esql.async_query_delete(\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->esql()->asyncQueryDelete([\n \"id\" => \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_query/async/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"" - } - ], - "specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.autoscaling.put_autoscaling_policy(\n name=\"\",\n policy={\n \"roles\": [],\n \"deciders\": {\n \"fixed\": {}\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.autoscaling.putAutoscalingPolicy({\n name: \"\",\n policy: {\n roles: [],\n deciders: {\n fixed: {},\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.autoscaling.put_autoscaling_policy(\n name: \"\",\n body: {\n \"roles\": [],\n \"deciders\": {\n \"fixed\": {}\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->autoscaling()->putAutoscalingPolicy([\n \"name\" => \"\",\n \"body\" => [\n \"roles\" => array(\n ),\n \"deciders\" => [\n \"fixed\" => new ArrayObject([]),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[],\"deciders\":{\"fixed\":{}}}' \"$ELASTICSEARCH_URL/_autoscaling/policy/\"" - }, - { - "language": "Java", - "code": "client.autoscaling().putAutoscalingPolicy(p -> p\n .name(\"\")\n .policy(po -> po\n .deciders(\"fixed\", JsonData.fromJson(\"{}\"))\n )\n);\n" - } - ], - "specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.autoscaling.put_autoscaling_policy(\n name=\"my_autoscaling_policy\",\n policy={\n \"roles\": [\n \"data_hot\"\n ],\n \"deciders\": {\n \"fixed\": {}\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.autoscaling.putAutoscalingPolicy({\n name: \"my_autoscaling_policy\",\n policy: {\n roles: [\"data_hot\"],\n deciders: {\n fixed: {},\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.autoscaling.put_autoscaling_policy(\n name: \"my_autoscaling_policy\",\n body: {\n \"roles\": [\n \"data_hot\"\n ],\n \"deciders\": {\n \"fixed\": {}\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->autoscaling()->putAutoscalingPolicy([\n \"name\" => \"my_autoscaling_policy\",\n \"body\" => [\n \"roles\" => array(\n \"data_hot\",\n ),\n \"deciders\" => [\n \"fixed\" => new ArrayObject([]),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"data_hot\"],\"deciders\":{\"fixed\":{}}}' \"$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy\"" - }, - { - "language": "Java", - "code": "client.autoscaling().putAutoscalingPolicy(p -> p\n .name(\"my_autoscaling_policy\")\n .policy(po -> po\n .roles(\"data_hot\")\n .deciders(\"fixed\", JsonData.fromJson(\"{}\"))\n )\n);\n" - } - ], - "specification/autoscaling/delete_autoscaling_policy/examples/request/DeleteAutoscalingPolicyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.autoscaling.delete_autoscaling_policy(\n name=\"*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.autoscaling.deleteAutoscalingPolicy({\n name: \"*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.autoscaling.delete_autoscaling_policy(\n name: \"*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->autoscaling()->deleteAutoscalingPolicy([\n \"name\" => \"*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/policy/*\"" - }, - { - "language": "Java", - "code": "client.autoscaling().deleteAutoscalingPolicy(d -> d\n .name(\"*\")\n);\n" - } - ], - "specification/autoscaling/get_autoscaling_policy/examples/request/GetAutoscalingPolicyRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.autoscaling.get_autoscaling_policy(\n name=\"my_autoscaling_policy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.autoscaling.getAutoscalingPolicy({\n name: \"my_autoscaling_policy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.autoscaling.get_autoscaling_policy(\n name: \"my_autoscaling_policy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->autoscaling()->getAutoscalingPolicy([\n \"name\" => \"my_autoscaling_policy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy\"" - }, - { - "language": "Java", - "code": "client.autoscaling().getAutoscalingPolicy(g -> g\n .name(\"my_autoscaling_policy\")\n);\n" - } - ], - "specification/autoscaling/get_autoscaling_capacity/examples/request/GetAutoscalingCapacityRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.autoscaling.get_autoscaling_capacity()" - }, - { - "language": "JavaScript", - "code": "const response = await client.autoscaling.getAutoscalingCapacity();" - }, - { - "language": "Ruby", - "code": "response = client.autoscaling.get_autoscaling_capacity" - }, - { - "language": "PHP", - "code": "$resp = $client->autoscaling()->getAutoscalingCapacity();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_autoscaling/capacity\"" - }, - { - "language": "Java", - "code": "client.autoscaling().getAutoscalingCapacity(g -> g);\n" - } - ], - "specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.render_query(\n name=\"my-app\",\n params={\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.renderQuery({\n name: \"my-app\",\n params: {\n query_string: \"my first query\",\n text_fields: [\n {\n name: \"title\",\n boost: 5,\n },\n {\n name: \"description\",\n boost: 1,\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.render_query(\n name: \"my-app\",\n body: {\n \"params\": {\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->renderQuery([\n \"name\" => \"my-app\",\n \"body\" => [\n \"params\" => [\n \"query_string\" => \"my first query\",\n \"text_fields\" => array(\n [\n \"name\" => \"title\",\n \"boost\" => 5,\n ],\n [\n \"name\" => \"description\",\n \"boost\" => 1,\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"params\":{\"query_string\":\"my first query\",\"text_fields\":[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app/_render_query\"" - }, - { - "language": "Java", - "code": "client.searchApplication().renderQuery(r -> r\n .name(\"my-app\")\n .params(Map.of(\"text_fields\", JsonData.fromJson(\"[{\\\"name\\\":\\\"title\\\",\\\"boost\\\":5},{\\\"name\\\":\\\"description\\\",\\\"boost\\\":1}]\"),\"query_string\", JsonData.fromJson(\"\\\"my first query\\\"\")))\n);\n" - } - ], - "specification/search_application/delete/examples/request/SearchApplicationDeleteExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.delete(\n name=\"my-app\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.delete({\n name: \"my-app\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.delete(\n name: \"my-app\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->delete([\n \"name\" => \"my-app\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application/my-app/\"" - }, - { - "language": "Java", - "code": "client.searchApplication().delete(d -> d\n .name(\"my-app\")\n);\n" - } - ], - "specification/search_application/put/examples/request/SearchApplicationPutRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.put(\n name=\"my-app\",\n search_application={\n \"indices\": [\n \"index1\",\n \"index2\"\n ],\n \"template\": {\n \"script\": {\n \"source\": {\n \"query\": {\n \"query_string\": {\n \"query\": \"{{query_string}}\",\n \"default_field\": \"{{default_field}}\"\n }\n }\n },\n \"params\": {\n \"query_string\": \"*\",\n \"default_field\": \"*\"\n }\n },\n \"dictionary\": {\n \"properties\": {\n \"query_string\": {\n \"type\": \"string\"\n },\n \"default_field\": {\n \"type\": \"string\",\n \"enum\": [\n \"title\",\n \"description\"\n ]\n },\n \"additionalProperties\": False\n },\n \"required\": [\n \"query_string\"\n ]\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.put({\n name: \"my-app\",\n search_application: {\n indices: [\"index1\", \"index2\"],\n template: {\n script: {\n source: {\n query: {\n query_string: {\n query: \"{{query_string}}\",\n default_field: \"{{default_field}}\",\n },\n },\n },\n params: {\n query_string: \"*\",\n default_field: \"*\",\n },\n },\n dictionary: {\n properties: {\n query_string: {\n type: \"string\",\n },\n default_field: {\n type: \"string\",\n enum: [\"title\", \"description\"],\n },\n additionalProperties: false,\n },\n required: [\"query_string\"],\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.put(\n name: \"my-app\",\n body: {\n \"indices\": [\n \"index1\",\n \"index2\"\n ],\n \"template\": {\n \"script\": {\n \"source\": {\n \"query\": {\n \"query_string\": {\n \"query\": \"{{query_string}}\",\n \"default_field\": \"{{default_field}}\"\n }\n }\n },\n \"params\": {\n \"query_string\": \"*\",\n \"default_field\": \"*\"\n }\n },\n \"dictionary\": {\n \"properties\": {\n \"query_string\": {\n \"type\": \"string\"\n },\n \"default_field\": {\n \"type\": \"string\",\n \"enum\": [\n \"title\",\n \"description\"\n ]\n },\n \"additionalProperties\": false\n },\n \"required\": [\n \"query_string\"\n ]\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->put([\n \"name\" => \"my-app\",\n \"body\" => [\n \"indices\" => array(\n \"index1\",\n \"index2\",\n ),\n \"template\" => [\n \"script\" => [\n \"source\" => [\n \"query\" => [\n \"query_string\" => [\n \"query\" => \"{{query_string}}\",\n \"default_field\" => \"{{default_field}}\",\n ],\n ],\n ],\n \"params\" => [\n \"query_string\" => \"*\",\n \"default_field\" => \"*\",\n ],\n ],\n \"dictionary\" => [\n \"properties\" => [\n \"query_string\" => [\n \"type\" => \"string\",\n ],\n \"default_field\" => [\n \"type\" => \"string\",\n \"enum\" => array(\n \"title\",\n \"description\",\n ),\n ],\n \"additionalProperties\" => false,\n ],\n \"required\" => array(\n \"query_string\",\n ),\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"indices\":[\"index1\",\"index2\"],\"template\":{\"script\":{\"source\":{\"query\":{\"query_string\":{\"query\":\"{{query_string}}\",\"default_field\":\"{{default_field}}\"}}},\"params\":{\"query_string\":\"*\",\"default_field\":\"*\"}},\"dictionary\":{\"properties\":{\"query_string\":{\"type\":\"string\"},\"default_field\":{\"type\":\"string\",\"enum\":[\"title\",\"description\"]},\"additionalProperties\":false},\"required\":[\"query_string\"]}}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app\"" - }, - { - "language": "Java", - "code": "client.searchApplication().put(p -> p\n .name(\"my-app\")\n .searchApplication(s -> s\n .indices(List.of(\"index1\",\"index2\"))\n .template(t -> t\n .script(sc -> sc\n .source(so -> so\n .scriptTemplate(scr -> scr\n .query(q -> q\n .queryString(qu -> qu\n .defaultField(\"{{default_field}}\")\n .query(\"{{query_string}}\")\n )\n )\n )\n )\n .params(Map.of(\"default_field\", JsonData.fromJson(\"\\\"*\\\"\"),\"query_string\", JsonData.fromJson(\"\\\"*\\\"\")))\n )\n )\n )\n);\n" - } - ], - "specification/search_application/get/examples/request/SearchApplicationGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.get(\n name=\"my-app\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.get({\n name: \"my-app\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.get(\n name: \"my-app\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->get([\n \"name\" => \"my-app\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application/my-app/\"" - }, - { - "language": "Java", - "code": "client.searchApplication().get(g -> g\n .name(\"my-app\")\n);\n" - } - ], - "specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.post_behavioral_analytics_event(\n collection_name=\"my_analytics_collection\",\n event_type=\"search_click\",\n payload={\n \"session\": {\n \"id\": \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"\n },\n \"user\": {\n \"id\": \"5f26f01a-bbee-4202-9298-81261067abbd\"\n },\n \"search\": {\n \"query\": \"search term\",\n \"results\": {\n \"items\": [\n {\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n ],\n \"total_results\": 10\n },\n \"sort\": {\n \"name\": \"relevance\"\n },\n \"search_application\": \"website\"\n },\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.postBehavioralAnalyticsEvent({\n collection_name: \"my_analytics_collection\",\n event_type: \"search_click\",\n payload: {\n session: {\n id: \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\",\n },\n user: {\n id: \"5f26f01a-bbee-4202-9298-81261067abbd\",\n },\n search: {\n query: \"search term\",\n results: {\n items: [\n {\n document: {\n id: \"123\",\n index: \"products\",\n },\n },\n ],\n total_results: 10,\n },\n sort: {\n name: \"relevance\",\n },\n search_application: \"website\",\n },\n document: {\n id: \"123\",\n index: \"products\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.post_behavioral_analytics_event(\n collection_name: \"my_analytics_collection\",\n event_type: \"search_click\",\n body: {\n \"session\": {\n \"id\": \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"\n },\n \"user\": {\n \"id\": \"5f26f01a-bbee-4202-9298-81261067abbd\"\n },\n \"search\": {\n \"query\": \"search term\",\n \"results\": {\n \"items\": [\n {\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n ],\n \"total_results\": 10\n },\n \"sort\": {\n \"name\": \"relevance\"\n },\n \"search_application\": \"website\"\n },\n \"document\": {\n \"id\": \"123\",\n \"index\": \"products\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->postBehavioralAnalyticsEvent([\n \"collection_name\" => \"my_analytics_collection\",\n \"event_type\" => \"search_click\",\n \"body\" => [\n \"session\" => [\n \"id\" => \"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\",\n ],\n \"user\" => [\n \"id\" => \"5f26f01a-bbee-4202-9298-81261067abbd\",\n ],\n \"search\" => [\n \"query\" => \"search term\",\n \"results\" => [\n \"items\" => array(\n [\n \"document\" => [\n \"id\" => \"123\",\n \"index\" => \"products\",\n ],\n ],\n ),\n \"total_results\" => 10,\n ],\n \"sort\" => [\n \"name\" => \"relevance\",\n ],\n \"search_application\" => \"website\",\n ],\n \"document\" => [\n \"id\" => \"123\",\n \"index\" => \"products\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"session\":{\"id\":\"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"},\"user\":{\"id\":\"5f26f01a-bbee-4202-9298-81261067abbd\"},\"search\":{\"query\":\"search term\",\"results\":{\"items\":[{\"document\":{\"id\":\"123\",\"index\":\"products\"}}],\"total_results\":10},\"sort\":{\"name\":\"relevance\"},\"search_application\":\"website\"},\"document\":{\"id\":\"123\",\"index\":\"products\"}}' \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection/event/search_click\"" - }, - { - "language": "Java", - "code": "client.searchApplication().postBehavioralAnalyticsEvent(p -> p\n .collectionName(\"my_analytics_collection\")\n .eventType(EventType.SearchClick)\n .payload(JsonData.fromJson(\"{\\\"session\\\":{\\\"id\\\":\\\"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\\\"},\\\"user\\\":{\\\"id\\\":\\\"5f26f01a-bbee-4202-9298-81261067abbd\\\"},\\\"search\\\":{\\\"query\\\":\\\"search term\\\",\\\"results\\\":{\\\"items\\\":[{\\\"document\\\":{\\\"id\\\":\\\"123\\\",\\\"index\\\":\\\"products\\\"}}],\\\"total_results\\\":10},\\\"sort\\\":{\\\"name\\\":\\\"relevance\\\"},\\\"search_application\\\":\\\"website\\\"},\\\"document\\\":{\\\"id\\\":\\\"123\\\",\\\"index\\\":\\\"products\\\"}}\"))\n);\n" - } - ], - "specification/search_application/get_behavioral_analytics/examples/request/BehavioralAnalyticsGetRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.get_behavioral_analytics(\n name=\"my*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.getBehavioralAnalytics({\n name: \"my*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.get_behavioral_analytics(\n name: \"my*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->getBehavioralAnalytics([\n \"name\" => \"my*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my*\"" - }, - { - "language": "Java", - "code": "client.searchApplication().getBehavioralAnalytics(g -> g\n .name(\"my*\")\n);\n" - } - ], - "specification/search_application/delete_behavioral_analytics/examples/request/SearchApplicationDeleteBehavioralAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.delete_behavioral_analytics(\n name=\"my_analytics_collection\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.deleteBehavioralAnalytics({\n name: \"my_analytics_collection\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.delete_behavioral_analytics(\n name: \"my_analytics_collection\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->deleteBehavioralAnalytics([\n \"name\" => \"my_analytics_collection\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection/\"" - }, - { - "language": "Java", - "code": "client.searchApplication().deleteBehavioralAnalytics(d -> d\n .name(\"my_analytics_collection\")\n);\n" - } - ], - "specification/search_application/put_behavioral_analytics/examples/request/SearchApplicationPutBehavioralAnalyticsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.put_behavioral_analytics(\n name=\"my_analytics_collection\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.putBehavioralAnalytics({\n name: \"my_analytics_collection\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.put_behavioral_analytics(\n name: \"my_analytics_collection\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->putBehavioralAnalytics([\n \"name\" => \"my_analytics_collection\",\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection\"" - }, - { - "language": "Java", - "code": "client.searchApplication().putBehavioralAnalytics(p -> p\n .name(\"my_analytics_collection\")\n);\n" - } - ], - "specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.search(\n name=\"my-app\",\n params={\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.search({\n name: \"my-app\",\n params: {\n query_string: \"my first query\",\n text_fields: [\n {\n name: \"title\",\n boost: 5,\n },\n {\n name: \"description\",\n boost: 1,\n },\n ],\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.search(\n name: \"my-app\",\n body: {\n \"params\": {\n \"query_string\": \"my first query\",\n \"text_fields\": [\n {\n \"name\": \"title\",\n \"boost\": 5\n },\n {\n \"name\": \"description\",\n \"boost\": 1\n }\n ]\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->search([\n \"name\" => \"my-app\",\n \"body\" => [\n \"params\" => [\n \"query_string\" => \"my first query\",\n \"text_fields\" => array(\n [\n \"name\" => \"title\",\n \"boost\" => 5,\n ],\n [\n \"name\" => \"description\",\n \"boost\" => 1,\n ],\n ),\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"params\":{\"query_string\":\"my first query\",\"text_fields\":[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]}}' \"$ELASTICSEARCH_URL/_application/search_application/my-app/_search\"" - }, - { - "language": "Java", - "code": "client.searchApplication().search(s -> s\n .name(\"my-app\")\n .params(Map.of(\"text_fields\", JsonData.fromJson(\"[{\\\"name\\\":\\\"title\\\",\\\"boost\\\":5},{\\\"name\\\":\\\"description\\\",\\\"boost\\\":1}]\"),\"query_string\", JsonData.fromJson(\"\\\"my first query\\\"\")))\n);\n" - } - ], - "specification/search_application/list/examples/request/SearchApplicationsListRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.search_application.list(\n from=\"0\",\n size=\"3\",\n q=\"app*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.searchApplication.list({\n from: 0,\n size: 3,\n q: \"app*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.search_application.list(\n from: \"0\",\n size: \"3\",\n q: \"app*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->searchApplication()->list([\n \"from\" => \"0\",\n \"size\" => \"3\",\n \"q\" => \"app*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_application/search_application?from=0&size=3&q=app*\"" - }, - { - "language": "Java", - "code": "client.searchApplication().list(l -> l\n .from(0)\n .q(\"app*\")\n .size(3)\n);\n" - } - ], - "specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.migration.get_feature_upgrade_status()" - }, - { - "language": "JavaScript", - "code": "const response = await client.migration.getFeatureUpgradeStatus();" - }, - { - "language": "Ruby", - "code": "response = client.migration.get_feature_upgrade_status" - }, - { - "language": "PHP", - "code": "$resp = $client->migration()->getFeatureUpgradeStatus();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/system_features\"" - }, - { - "language": "Java", - "code": "client.migration().getFeatureUpgradeStatus();\n" - } - ], - "specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.migration.post_feature_upgrade()" - }, - { - "language": "JavaScript", - "code": "const response = await client.migration.postFeatureUpgrade();" - }, - { - "language": "Ruby", - "code": "response = client.migration.post_feature_upgrade" - }, - { - "language": "PHP", - "code": "$resp = $client->migration()->postFeatureUpgrade();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/system_features\"" - }, - { - "language": "Java", - "code": "client.migration().postFeatureUpgrade();\n" - } - ], - "specification/migration/deprecations/examples/request/DeprecationInfoRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.migration.deprecations()" - }, - { - "language": "JavaScript", - "code": "const response = await client.migration.deprecations();" - }, - { - "language": "Ruby", - "code": "response = client.migration.deprecations" - }, - { - "language": "PHP", - "code": "$resp = $client->migration()->deprecations();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_migration/deprecations\"" - }, - { - "language": "Java", - "code": "client.migration().deprecations(d -> d);\n" - } - ], - "specification/transform/start_transform/examples/request/TransformStartTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.start_transform(\n transform_id=\"ecommerce-customer-transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.startTransform({\n transform_id: \"ecommerce-customer-transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.start_transform(\n transform_id: \"ecommerce-customer-transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->startTransform([\n \"transform_id\" => \"ecommerce-customer-transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce-customer-transform/_start\"" - }, - { - "language": "Java", - "code": "client.transform().startTransform(s -> s\n .transformId(\"ecommerce-customer-transform\")\n);\n" - } - ], - "specification/transform/schedule_now_transform/examples/request/TransformScheduleNowTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.schedule_now_transform(\n transform_id=\"ecommerce_transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.scheduleNowTransform({\n transform_id: \"ecommerce_transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.schedule_now_transform(\n transform_id: \"ecommerce_transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->scheduleNowTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_schedule_now\"" - }, - { - "language": "Java", - "code": "client.transform().scheduleNowTransform(s -> s\n .transformId(\"ecommerce_transform\")\n);\n" - } - ], - "specification/transform/get_transform/examples/request/TransformGetTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.get_transform(\n size=\"10\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.getTransform({\n size: 10,\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.get_transform(\n size: \"10\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->getTransform([\n \"size\" => \"10\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform?size=10\"" - }, - { - "language": "Java", - "code": "client.transform().getTransform(g -> g\n .size(10)\n);\n" - } - ], - "specification/transform/upgrade_transforms/examples/request/TransformUpgradeTransformsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.upgrade_transforms()" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.upgradeTransforms();" - }, - { - "language": "Ruby", - "code": "response = client.transform.upgrade_transforms" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->upgradeTransforms();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/_upgrade\"" - }, - { - "language": "Java", - "code": "client.transform().upgradeTransforms(u -> u);\n" - } - ], - "specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.preview_transform(\n source={\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n pivot={\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": True\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.previewTransform({\n source: {\n index: \"kibana_sample_data_ecommerce\",\n },\n pivot: {\n group_by: {\n customer_id: {\n terms: {\n field: \"customer_id\",\n missing_bucket: true,\n },\n },\n },\n aggregations: {\n max_price: {\n max: {\n field: \"taxful_total_price\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.preview_transform(\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n \"pivot\": {\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": true\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->previewTransform([\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n ],\n \"pivot\" => [\n \"group_by\" => [\n \"customer_id\" => [\n \"terms\" => [\n \"field\" => \"customer_id\",\n \"missing_bucket\" => true,\n ],\n ],\n ],\n \"aggregations\" => [\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"taxful_total_price\",\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\"},\"pivot\":{\"group_by\":{\"customer_id\":{\"terms\":{\"field\":\"customer_id\",\"missing_bucket\":true}}},\"aggregations\":{\"max_price\":{\"max\":{\"field\":\"taxful_total_price\"}}}}}' \"$ELASTICSEARCH_URL/_transform/_preview\"" - }, - { - "language": "Java", - "code": "client.transform().previewTransform(p -> p\n .pivot(pi -> pi\n .aggregations(\"max_price\", a -> a\n .max(m -> m\n .field(\"taxful_total_price\")\n )\n )\n .groupBy(\"customer_id\", g -> g\n .terms(t -> t\n .field(\"customer_id\")\n .missingBucket(true)\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n )\n);\n" - } - ], - "specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.put_transform(\n transform_id=\"ecommerce_transform2\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n latest={\n \"unique_key\": [\n \"customer_id\"\n ],\n \"sort\": \"order_date\"\n },\n description=\"Latest order for each customer\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform2\"\n },\n frequency=\"5m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.putTransform({\n transform_id: \"ecommerce_transform2\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n },\n latest: {\n unique_key: [\"customer_id\"],\n sort: \"order_date\",\n },\n description: \"Latest order for each customer\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform2\",\n },\n frequency: \"5m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"60s\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.put_transform(\n transform_id: \"ecommerce_transform2\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\"\n },\n \"latest\": {\n \"unique_key\": [\n \"customer_id\"\n ],\n \"sort\": \"order_date\"\n },\n \"description\": \"Latest order for each customer\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform2\"\n },\n \"frequency\": \"5m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->putTransform([\n \"transform_id\" => \"ecommerce_transform2\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n ],\n \"latest\" => [\n \"unique_key\" => array(\n \"customer_id\",\n ),\n \"sort\" => \"order_date\",\n ],\n \"description\" => \"Latest order for each customer\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform2\",\n ],\n \"frequency\" => \"5m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"60s\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\"},\"latest\":{\"unique_key\":[\"customer_id\"],\"sort\":\"order_date\"},\"description\":\"Latest order for each customer\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform2\"},\"frequency\":\"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform2\"" - }, - { - "language": "Java", - "code": "client.transform().putTransform(p -> p\n .description(\"Latest order for each customer\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform2\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .latest(l -> l\n .sort(\"order_date\")\n .uniqueKey(\"customer_id\")\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n )\n .sync(s -> s\n .time(t -> t\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"ecommerce_transform2\")\n);\n" - } - ], - "specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.put_transform(\n transform_id=\"ecommerce_transform1\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n pivot={\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": True\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n description=\"Maximum priced ecommerce data by customer_id in Asia\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n frequency=\"5m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n retention_policy={\n \"time\": {\n \"field\": \"order_date\",\n \"max_age\": \"30d\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.putTransform({\n transform_id: \"ecommerce_transform1\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n query: {\n term: {\n \"geoip.continent_name\": {\n value: \"Asia\",\n },\n },\n },\n },\n pivot: {\n group_by: {\n customer_id: {\n terms: {\n field: \"customer_id\",\n missing_bucket: true,\n },\n },\n },\n aggregations: {\n max_price: {\n max: {\n field: \"taxful_total_price\",\n },\n },\n },\n },\n description: \"Maximum priced ecommerce data by customer_id in Asia\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform1\",\n pipeline: \"add_timestamp_pipeline\",\n },\n frequency: \"5m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"60s\",\n },\n },\n retention_policy: {\n time: {\n field: \"order_date\",\n max_age: \"30d\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.put_transform(\n transform_id: \"ecommerce_transform1\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n \"pivot\": {\n \"group_by\": {\n \"customer_id\": {\n \"terms\": {\n \"field\": \"customer_id\",\n \"missing_bucket\": true\n }\n }\n },\n \"aggregations\": {\n \"max_price\": {\n \"max\": {\n \"field\": \"taxful_total_price\"\n }\n }\n }\n },\n \"description\": \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n \"frequency\": \"5m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"60s\"\n }\n },\n \"retention_policy\": {\n \"time\": {\n \"field\": \"order_date\",\n \"max_age\": \"30d\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->putTransform([\n \"transform_id\" => \"ecommerce_transform1\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n \"query\" => [\n \"term\" => [\n \"geoip.continent_name\" => [\n \"value\" => \"Asia\",\n ],\n ],\n ],\n ],\n \"pivot\" => [\n \"group_by\" => [\n \"customer_id\" => [\n \"terms\" => [\n \"field\" => \"customer_id\",\n \"missing_bucket\" => true,\n ],\n ],\n ],\n \"aggregations\" => [\n \"max_price\" => [\n \"max\" => [\n \"field\" => \"taxful_total_price\",\n ],\n ],\n ],\n ],\n \"description\" => \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform1\",\n \"pipeline\" => \"add_timestamp_pipeline\",\n ],\n \"frequency\" => \"5m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"60s\",\n ],\n ],\n \"retention_policy\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"max_age\" => \"30d\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\",\"query\":{\"term\":{\"geoip.continent_name\":{\"value\":\"Asia\"}}}},\"pivot\":{\"group_by\":{\"customer_id\":{\"terms\":{\"field\":\"customer_id\",\"missing_bucket\":true}}},\"aggregations\":{\"max_price\":{\"max\":{\"field\":\"taxful_total_price\"}}}},\"description\":\"Maximum priced ecommerce data by customer_id in Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform1\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}},\"retention_policy\":{\"time\":{\"field\":\"order_date\",\"max_age\":\"30d\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform1\"" - }, - { - "language": "Java", - "code": "client.transform().putTransform(p -> p\n .description(\"Maximum priced ecommerce data by customer_id in Asia\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform1\")\n .pipeline(\"add_timestamp_pipeline\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .pivot(pi -> pi\n .aggregations(\"max_price\", a -> a\n .max(m -> m\n .field(\"taxful_total_price\")\n )\n )\n .groupBy(\"customer_id\", g -> g\n .terms(t -> t\n .field(\"customer_id\")\n .missingBucket(true)\n )\n )\n )\n .retentionPolicy(r -> r\n .time(t -> t\n .field(\"order_date\")\n .maxAge(m -> m\n .time(\"30d\")\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n .query(q -> q\n .term(te -> te\n .field(\"geoip.continent_name\")\n .value(FieldValue.of(\"Asia\"))\n )\n )\n )\n .sync(sy -> sy\n .time(ti -> ti\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"ecommerce_transform1\")\n);\n" - } - ], - "specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.update_transform(\n transform_id=\"simple-kibana-ecomm-pivot\",\n source={\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n description=\"Maximum priced ecommerce data by customer_id in Asia\",\n dest={\n \"index\": \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n frequency=\"15m\",\n sync={\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"120s\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.updateTransform({\n transform_id: \"simple-kibana-ecomm-pivot\",\n source: {\n index: \"kibana_sample_data_ecommerce\",\n query: {\n term: {\n \"geoip.continent_name\": {\n value: \"Asia\",\n },\n },\n },\n },\n description: \"Maximum priced ecommerce data by customer_id in Asia\",\n dest: {\n index: \"kibana_sample_data_ecommerce_transform_v2\",\n pipeline: \"add_timestamp_pipeline\",\n },\n frequency: \"15m\",\n sync: {\n time: {\n field: \"order_date\",\n delay: \"120s\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.update_transform(\n transform_id: \"simple-kibana-ecomm-pivot\",\n body: {\n \"source\": {\n \"index\": \"kibana_sample_data_ecommerce\",\n \"query\": {\n \"term\": {\n \"geoip.continent_name\": {\n \"value\": \"Asia\"\n }\n }\n }\n },\n \"description\": \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\": {\n \"index\": \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\": \"add_timestamp_pipeline\"\n },\n \"frequency\": \"15m\",\n \"sync\": {\n \"time\": {\n \"field\": \"order_date\",\n \"delay\": \"120s\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->updateTransform([\n \"transform_id\" => \"simple-kibana-ecomm-pivot\",\n \"body\" => [\n \"source\" => [\n \"index\" => \"kibana_sample_data_ecommerce\",\n \"query\" => [\n \"term\" => [\n \"geoip.continent_name\" => [\n \"value\" => \"Asia\",\n ],\n ],\n ],\n ],\n \"description\" => \"Maximum priced ecommerce data by customer_id in Asia\",\n \"dest\" => [\n \"index\" => \"kibana_sample_data_ecommerce_transform_v2\",\n \"pipeline\" => \"add_timestamp_pipeline\",\n ],\n \"frequency\" => \"15m\",\n \"sync\" => [\n \"time\" => [\n \"field\" => \"order_date\",\n \"delay\" => \"120s\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\",\"query\":{\"term\":{\"geoip.continent_name\":{\"value\":\"Asia\"}}}},\"description\":\"Maximum priced ecommerce data by customer_id in Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform_v2\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\"15m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"120s\"}}}' \"$ELASTICSEARCH_URL/_transform/simple-kibana-ecomm-pivot/_update\"" - }, - { - "language": "Java", - "code": "client.transform().updateTransform(u -> u\n .description(\"Maximum priced ecommerce data by customer_id in Asia\")\n .dest(d -> d\n .index(\"kibana_sample_data_ecommerce_transform1\")\n .pipeline(\"add_timestamp_pipeline\")\n )\n .frequency(f -> f\n .time(\"5m\")\n )\n .retentionPolicy(r -> r\n .time(t -> t\n .field(\"order_date\")\n .maxAge(m -> m\n .time(\"30d\")\n )\n )\n )\n .source(s -> s\n .index(\"kibana_sample_data_ecommerce\")\n .query(q -> q\n .term(te -> te\n .field(\"geoip.continent_name\")\n .value(FieldValue.of(\"Asia\"))\n )\n )\n )\n .sync(sy -> sy\n .time(ti -> ti\n .delay(d -> d\n .time(\"60s\")\n )\n .field(\"order_date\")\n )\n )\n .transformId(\"simple-kibana-ecomm-pivot\")\n);\n" - } - ], - "specification/transform/reset_transform/examples/request/TransformResetTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.reset_transform(\n transform_id=\"ecommerce_transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.resetTransform({\n transform_id: \"ecommerce_transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.reset_transform(\n transform_id: \"ecommerce_transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->resetTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_reset\"" - }, - { - "language": "Java", - "code": "client.transform().resetTransform(r -> r\n .transformId(\"ecommerce_transform\")\n);\n" - } - ], - "specification/transform/stop_transform/examples/request/TransformStopTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.stop_transform(\n transform_id=\"ecommerce_transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.stopTransform({\n transform_id: \"ecommerce_transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.stop_transform(\n transform_id: \"ecommerce_transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->stopTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform/_stop\"" - }, - { - "language": "Java", - "code": "client.transform().stopTransform(s -> s\n .transformId(\"ecommerce_transform\")\n);\n" - } - ], - "specification/transform/get_transform_stats/examples/request/TransformGetTransformStatsExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.get_transform_stats(\n transform_id=\"ecommerce-customer-transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.getTransformStats({\n transform_id: \"ecommerce-customer-transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.get_transform_stats(\n transform_id: \"ecommerce-customer-transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->getTransformStats([\n \"transform_id\" => \"ecommerce-customer-transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce-customer-transform/_stats\"" - }, - { - "language": "Java", - "code": "client.transform().getTransformStats(g -> g\n .transformId(\"ecommerce-customer-transform\")\n);\n" - } - ], - "specification/transform/delete_transform/examples/request/TransformDeleteTransformExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.transform.delete_transform(\n transform_id=\"ecommerce_transform\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.transform.deleteTransform({\n transform_id: \"ecommerce_transform\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.transform.delete_transform(\n transform_id: \"ecommerce_transform\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->transform()->deleteTransform([\n \"transform_id\" => \"ecommerce_transform\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_transform/ecommerce_transform\"" - }, - { - "language": "Java", - "code": "client.transform().deleteTransform(d -> d\n .transformId(\"ecommerce_transform\")\n);\n" - } - ], - "specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.forget_follower(\n index=\"\",\n follower_cluster=\"\",\n follower_index=\"\",\n follower_index_uuid=\"\",\n leader_remote_cluster=\"\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.forgetFollower({\n index: \"\",\n follower_cluster: \"\",\n follower_index: \"\",\n follower_index_uuid: \"\",\n leader_remote_cluster: \"\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.forget_follower(\n index: \"\",\n body: {\n \"follower_cluster\": \"\",\n \"follower_index\": \"\",\n \"follower_index_uuid\": \"\",\n \"leader_remote_cluster\": \"\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->forgetFollower([\n \"index\" => \"\",\n \"body\" => [\n \"follower_cluster\" => \"\",\n \"follower_index\" => \"\",\n \"follower_index_uuid\" => \"\",\n \"leader_remote_cluster\" => \"\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"follower_cluster\":\"\",\"follower_index\":\"\",\"follower_index_uuid\":\"\",\"leader_remote_cluster\":\"\"}' \"$ELASTICSEARCH_URL//_ccr/forget_follower\"" - }, - { - "language": "Java", - "code": "client.ccr().forgetFollower(f -> f\n .followerCluster(\"\")\n .followerIndex(\"\")\n .followerIndexUuid(\"\")\n .index(\"\")\n .leaderRemoteCluster(\"\")\n);\n" - } - ], - "specification/ccr/delete_auto_follow_pattern/examples/request/DeleteAutoFollowPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.delete_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.deleteAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.delete_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->deleteAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" - }, - { - "language": "Java", - "code": "client.ccr().deleteAutoFollowPattern(d -> d\n .name(\"my_auto_follow_pattern\")\n);\n" - } - ], - "specification/ccr/resume_auto_follow_pattern/examples/request/ResumeAutoFollowPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.resume_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.resumeAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.resume_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->resumeAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern/resume\"" - }, - { - "language": "Java", - "code": "client.ccr().resumeAutoFollowPattern(r -> r\n .name(\"my_auto_follow_pattern\")\n);\n" - } - ], - "specification/ccr/pause_follow/examples/request/PauseFollowIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.pause_follow(\n index=\"follower_index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.pauseFollow({\n index: \"follower_index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.pause_follow(\n index: \"follower_index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->pauseFollow([\n \"index\" => \"follower_index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/pause_follow\"" - }, - { - "language": "Java", - "code": "client.ccr().pauseFollow(p -> p\n .index(\"follower_index\")\n);\n" - } - ], - "specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.follow(\n index=\"follower_index\",\n wait_for_active_shards=\"1\",\n remote_cluster=\"remote_cluster\",\n leader_index=\"leader_index\",\n settings={\n \"index.number_of_replicas\": 0\n },\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.follow({\n index: \"follower_index\",\n wait_for_active_shards: 1,\n remote_cluster: \"remote_cluster\",\n leader_index: \"leader_index\",\n settings: {\n \"index.number_of_replicas\": 0,\n },\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.follow(\n index: \"follower_index\",\n wait_for_active_shards: \"1\",\n body: {\n \"remote_cluster\": \"remote_cluster\",\n \"leader_index\": \"leader_index\",\n \"settings\": {\n \"index.number_of_replicas\": 0\n },\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->follow([\n \"index\" => \"follower_index\",\n \"wait_for_active_shards\" => \"1\",\n \"body\" => [\n \"remote_cluster\" => \"remote_cluster\",\n \"leader_index\" => \"leader_index\",\n \"settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_cluster\":\"remote_cluster\",\"leader_index\":\"leader_index\",\"settings\":{\"index.number_of_replicas\":0},\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/follow?wait_for_active_shards=1\"" - }, - { - "language": "Java", - "code": "client.ccr().follow(f -> f\n .index(\"follower_index\")\n .leaderIndex(\"leader_index\")\n .maxOutstandingReadRequests(16L)\n .maxOutstandingWriteRequests(8)\n .maxReadRequestOperationCount(1024)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768)\n .maxWriteRequestSize(\"16k\")\n .readPollTimeout(r -> r\n .time(\"30s\")\n )\n .remoteCluster(\"remote_cluster\")\n .settings(s -> s\n .otherSettings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n )\n .waitForActiveShards(w -> w\n .count(1)\n )\n);\n" - } - ], - "specification/ccr/get_auto_follow_pattern/examples/request/GetAutoFollowPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.get_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.getAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.get_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->getAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" - }, - { - "language": "Java", - "code": "client.ccr().getAutoFollowPattern(g -> g\n .name(\"my_auto_follow_pattern\")\n);\n" - } - ], - "specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.put_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n remote_cluster=\"remote_cluster\",\n leader_index_patterns=[\n \"leader_index*\"\n ],\n follow_index_pattern=\"{{leader_index}}-follower\",\n settings={\n \"index.number_of_replicas\": 0\n },\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.putAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n remote_cluster: \"remote_cluster\",\n leader_index_patterns: [\"leader_index*\"],\n follow_index_pattern: \"{{leader_index}}-follower\",\n settings: {\n \"index.number_of_replicas\": 0,\n },\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.put_auto_follow_pattern(\n name: \"my_auto_follow_pattern\",\n body: {\n \"remote_cluster\": \"remote_cluster\",\n \"leader_index_patterns\": [\n \"leader_index*\"\n ],\n \"follow_index_pattern\": \"{{leader_index}}-follower\",\n \"settings\": {\n \"index.number_of_replicas\": 0\n },\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->putAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n \"body\" => [\n \"remote_cluster\" => \"remote_cluster\",\n \"leader_index_patterns\" => array(\n \"leader_index*\",\n ),\n \"follow_index_pattern\" => \"{{leader_index}}-follower\",\n \"settings\" => [\n \"index.number_of_replicas\" => 0,\n ],\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"remote_cluster\":\"remote_cluster\",\"leader_index_patterns\":[\"leader_index*\"],\"follow_index_pattern\":\"{{leader_index}}-follower\",\"settings\":{\"index.number_of_replicas\":0},\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" - }, - { - "language": "Java", - "code": "client.ccr().putAutoFollowPattern(p -> p\n .followIndexPattern(\"{{leader_index}}-follower\")\n .leaderIndexPatterns(\"leader_index*\")\n .maxOutstandingReadRequests(16)\n .maxOutstandingWriteRequests(8)\n .maxReadRequestOperationCount(1024)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768)\n .maxWriteRequestSize(\"16k\")\n .name(\"my_auto_follow_pattern\")\n .readPollTimeout(r -> r\n .time(\"30s\")\n )\n .remoteCluster(\"remote_cluster\")\n .settings(\"index.number_of_replicas\", JsonData.fromJson(\"0\"))\n);\n" - } - ], - "specification/ccr/follow_info/examples/request/FollowInfoRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.follow_info(\n index=\"follower_index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.followInfo({\n index: \"follower_index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.follow_info(\n index: \"follower_index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->followInfo([\n \"index\" => \"follower_index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/info\"" - }, - { - "language": "Java", - "code": "client.ccr().followInfo(f -> f\n .index(\"follower_index\")\n);\n" - } - ], - "specification/ccr/unfollow/examples/request/UnfollowIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.unfollow(\n index=\"follower_index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.unfollow({\n index: \"follower_index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.unfollow(\n index: \"follower_index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->unfollow([\n \"index\" => \"follower_index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/unfollow\"" - }, - { - "language": "Java", - "code": "client.ccr().unfollow(u -> u\n .index(\"follower_index\")\n);\n" - } - ], - "specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.resume_follow(\n index=\"follower_index\",\n max_read_request_operation_count=1024,\n max_outstanding_read_requests=16,\n max_read_request_size=\"1024k\",\n max_write_request_operation_count=32768,\n max_write_request_size=\"16k\",\n max_outstanding_write_requests=8,\n max_write_buffer_count=512,\n max_write_buffer_size=\"512k\",\n max_retry_delay=\"10s\",\n read_poll_timeout=\"30s\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.resumeFollow({\n index: \"follower_index\",\n max_read_request_operation_count: 1024,\n max_outstanding_read_requests: 16,\n max_read_request_size: \"1024k\",\n max_write_request_operation_count: 32768,\n max_write_request_size: \"16k\",\n max_outstanding_write_requests: 8,\n max_write_buffer_count: 512,\n max_write_buffer_size: \"512k\",\n max_retry_delay: \"10s\",\n read_poll_timeout: \"30s\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.resume_follow(\n index: \"follower_index\",\n body: {\n \"max_read_request_operation_count\": 1024,\n \"max_outstanding_read_requests\": 16,\n \"max_read_request_size\": \"1024k\",\n \"max_write_request_operation_count\": 32768,\n \"max_write_request_size\": \"16k\",\n \"max_outstanding_write_requests\": 8,\n \"max_write_buffer_count\": 512,\n \"max_write_buffer_size\": \"512k\",\n \"max_retry_delay\": \"10s\",\n \"read_poll_timeout\": \"30s\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->resumeFollow([\n \"index\" => \"follower_index\",\n \"body\" => [\n \"max_read_request_operation_count\" => 1024,\n \"max_outstanding_read_requests\" => 16,\n \"max_read_request_size\" => \"1024k\",\n \"max_write_request_operation_count\" => 32768,\n \"max_write_request_size\" => \"16k\",\n \"max_outstanding_write_requests\" => 8,\n \"max_write_buffer_count\" => 512,\n \"max_write_buffer_size\" => \"512k\",\n \"max_retry_delay\" => \"10s\",\n \"read_poll_timeout\" => \"30s\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_read_request_operation_count\":1024,\"max_outstanding_read_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/resume_follow\"" - }, - { - "language": "Java", - "code": "client.ccr().resumeFollow(r -> r\n .index(\"follower_index\")\n .maxOutstandingReadRequests(16L)\n .maxOutstandingWriteRequests(8L)\n .maxReadRequestOperationCount(1024L)\n .maxReadRequestSize(\"1024k\")\n .maxRetryDelay(m -> m\n .time(\"10s\")\n )\n .maxWriteBufferCount(512L)\n .maxWriteBufferSize(\"512k\")\n .maxWriteRequestOperationCount(32768L)\n .maxWriteRequestSize(\"16k\")\n .readPollTimeout(re -> re\n .time(\"30s\")\n )\n);\n" - } - ], - "specification/ccr/follow_stats/examples/request/FollowIndexStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.follow_stats(\n index=\"follower_index\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.followStats({\n index: \"follower_index\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.follow_stats(\n index: \"follower_index\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->followStats([\n \"index\" => \"follower_index\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/follower_index/_ccr/stats\"" - }, - { - "language": "Java", - "code": "client.ccr().followStats(f -> f\n .index(\"follower_index\")\n);\n" - } - ], - "specification/ccr/stats/examples/request/CcrStatsRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.stats()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.stats();" - }, - { - "language": "Ruby", - "code": "response = client.ccr.stats" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->stats();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/stats\"" - }, - { - "language": "Java", - "code": "client.ccr().stats(s -> s);\n" - } - ], - "specification/ccr/pause_auto_follow_pattern/examples/request/PauseAutoFollowPatternRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ccr.pause_auto_follow_pattern(\n name=\"my_auto_follow_pattern\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ccr.pauseAutoFollowPattern({\n name: \"my_auto_follow_pattern\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ccr.pause_auto_follow_pattern(\n name: \"my_auto_follow_pattern\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ccr()->pauseAutoFollowPattern([\n \"name\" => \"my_auto_follow_pattern\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern/pause\"" - }, - { - "language": "Java", - "code": "client.ccr().pauseAutoFollowPattern(p -> p\n .name(\"my_auto_follow_pattern\")\n);\n" - } - ], - "specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.get_status()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.getStatus();" - }, - { - "language": "Ruby", - "code": "response = client.ilm.get_status" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->getStatus();" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/status\"" - }, - { - "language": "Java", - "code": "client.ilm().getStatus();\n" - } - ], - "specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.move_to_step(\n index=\"my-index-000001\",\n current_step={\n \"phase\": \"new\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n next_step={\n \"phase\": \"warm\",\n \"action\": \"forcemerge\",\n \"name\": \"forcemerge\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.moveToStep({\n index: \"my-index-000001\",\n current_step: {\n phase: \"new\",\n action: \"complete\",\n name: \"complete\",\n },\n next_step: {\n phase: \"warm\",\n action: \"forcemerge\",\n name: \"forcemerge\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.move_to_step(\n index: \"my-index-000001\",\n body: {\n \"current_step\": {\n \"phase\": \"new\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n \"next_step\": {\n \"phase\": \"warm\",\n \"action\": \"forcemerge\",\n \"name\": \"forcemerge\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->moveToStep([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"current_step\" => [\n \"phase\" => \"new\",\n \"action\" => \"complete\",\n \"name\" => \"complete\",\n ],\n \"next_step\" => [\n \"phase\" => \"warm\",\n \"action\" => \"forcemerge\",\n \"name\" => \"forcemerge\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"current_step\":{\"phase\":\"new\",\"action\":\"complete\",\"name\":\"complete\"},\"next_step\":{\"phase\":\"warm\",\"action\":\"forcemerge\",\"name\":\"forcemerge\"}}' \"$ELASTICSEARCH_URL/_ilm/move/my-index-000001\"" - }, - { - "language": "Java", - "code": "client.ilm().moveToStep(m -> m\n .currentStep(c -> c\n .action(\"complete\")\n .name(\"complete\")\n .phase(\"new\")\n )\n .index(\"my-index-000001\")\n .nextStep(n -> n\n .action(\"forcemerge\")\n .name(\"forcemerge\")\n .phase(\"warm\")\n )\n);\n" - } - ], - "specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.move_to_step(\n index=\"my-index-000001\",\n current_step={\n \"phase\": \"hot\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n next_step={\n \"phase\": \"warm\"\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.moveToStep({\n index: \"my-index-000001\",\n current_step: {\n phase: \"hot\",\n action: \"complete\",\n name: \"complete\",\n },\n next_step: {\n phase: \"warm\",\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.move_to_step(\n index: \"my-index-000001\",\n body: {\n \"current_step\": {\n \"phase\": \"hot\",\n \"action\": \"complete\",\n \"name\": \"complete\"\n },\n \"next_step\": {\n \"phase\": \"warm\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->moveToStep([\n \"index\" => \"my-index-000001\",\n \"body\" => [\n \"current_step\" => [\n \"phase\" => \"hot\",\n \"action\" => \"complete\",\n \"name\" => \"complete\",\n ],\n \"next_step\" => [\n \"phase\" => \"warm\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"current_step\":{\"phase\":\"hot\",\"action\":\"complete\",\"name\":\"complete\"},\"next_step\":{\"phase\":\"warm\"}}' \"$ELASTICSEARCH_URL/_ilm/move/my-index-000001\"" - }, - { - "language": "Java", - "code": "client.ilm().moveToStep(m -> m\n .currentStep(c -> c\n .action(\"complete\")\n .name(\"complete\")\n .phase(\"hot\")\n )\n .index(\"my-index-000001\")\n .nextStep(n -> n\n .phase(\"warm\")\n )\n);\n" - } - ], - "specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.migrate_to_data_tiers(\n legacy_template_to_delete=\"global-template\",\n node_attribute=\"custom_attribute_name\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.migrateToDataTiers({\n legacy_template_to_delete: \"global-template\",\n node_attribute: \"custom_attribute_name\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.migrate_to_data_tiers(\n body: {\n \"legacy_template_to_delete\": \"global-template\",\n \"node_attribute\": \"custom_attribute_name\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->migrateToDataTiers([\n \"body\" => [\n \"legacy_template_to_delete\" => \"global-template\",\n \"node_attribute\" => \"custom_attribute_name\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"legacy_template_to_delete\":\"global-template\",\"node_attribute\":\"custom_attribute_name\"}' \"$ELASTICSEARCH_URL/_ilm/migrate_to_data_tiers\"" - }, - { - "language": "Java", - "code": "client.ilm().migrateToDataTiers(m -> m\n .legacyTemplateToDelete(\"global-template\")\n .nodeAttribute(\"custom_attribute_name\")\n);\n" - } - ], - "specification/ilm/retry/examples/request/IlmRetryExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.retry(\n index=\"my-index-000001\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.retry({\n index: \"my-index-000001\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.retry(\n index: \"my-index-000001\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->retry([\n \"index\" => \"my-index-000001\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/my-index-000001/_ilm/retry\"" - }, - { - "language": "Java", - "code": "client.ilm().retry(r -> r\n .index(\"my-index-000001\")\n);\n" - } - ], - "specification/ilm/delete_lifecycle/examples/request/IlmDeleteLifecycleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.delete_lifecycle(\n name=\"my_policy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.deleteLifecycle({\n name: \"my_policy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.delete_lifecycle(\n policy: \"my_policy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->deleteLifecycle([\n \"policy\" => \"my_policy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" - }, - { - "language": "Java", - "code": "client.ilm().deleteLifecycle(d -> d\n .name(\"my_policy\")\n);\n" - } - ], - "specification/ilm/start/examples/request/IlmStartExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.start()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.start();" - }, - { - "language": "Ruby", - "code": "response = client.ilm.start" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->start();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/start\"" - }, - { - "language": "Java", - "code": "client.ilm().start(s -> s);\n" - } - ], - "specification/ilm/explain_lifecycle/examples/request/IlmExplainLifecycleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.explain_lifecycle(\n index=\".ds-timeseries-*\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.explainLifecycle({\n index: \".ds-timeseries-*\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.explain_lifecycle(\n index: \".ds-timeseries-*\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->explainLifecycle([\n \"index\" => \".ds-timeseries-*\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/.ds-timeseries-*/_ilm/explain\"" - }, - { - "language": "Java", - "code": "client.ilm().explainLifecycle(e -> e\n .index(\".ds-timeseries-*\")\n);\n" - } - ], - "specification/ilm/stop/examples/request/IlmStopExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.stop()" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.stop();" - }, - { - "language": "Ruby", - "code": "response = client.ilm.stop" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->stop();" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/stop\"" - }, - { - "language": "Java", - "code": "client.ilm().stop(s -> s);\n" - } - ], - "specification/ilm/remove_policy/examples/request/IlmRemovePolicyExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.remove_policy(\n index=\"logs-my_app-default\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.removePolicy({\n index: \"logs-my_app-default\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.remove_policy(\n index: \"logs-my_app-default\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->removePolicy([\n \"index\" => \"logs-my_app-default\",\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/logs-my_app-default/_ilm/remove\"" - }, - { - "language": "Java", - "code": "client.ilm().removePolicy(r -> r\n .index(\"logs-my_app-default\")\n);\n" - } - ], - "specification/ilm/get_lifecycle/examples/request/IlmGetLifecycleExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.get_lifecycle(\n name=\"my_policy\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.getLifecycle({\n name: \"my_policy\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.get_lifecycle(\n policy: \"my_policy\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->getLifecycle([\n \"policy\" => \"my_policy\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" - }, - { - "language": "Java", - "code": "client.ilm().getLifecycle(g -> g\n .name(\"my_policy\")\n);\n" - } - ], - "specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.ilm.put_lifecycle(\n name=\"my_policy\",\n policy={\n \"_meta\": {\n \"description\": \"used for nginx log\",\n \"project\": {\n \"name\": \"myProject\",\n \"department\": \"myDepartment\"\n }\n },\n \"phases\": {\n \"warm\": {\n \"min_age\": \"10d\",\n \"actions\": {\n \"forcemerge\": {\n \"max_num_segments\": 1\n }\n }\n },\n \"delete\": {\n \"min_age\": \"30d\",\n \"actions\": {\n \"delete\": {}\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.ilm.putLifecycle({\n name: \"my_policy\",\n policy: {\n _meta: {\n description: \"used for nginx log\",\n project: {\n name: \"myProject\",\n department: \"myDepartment\",\n },\n },\n phases: {\n warm: {\n min_age: \"10d\",\n actions: {\n forcemerge: {\n max_num_segments: 1,\n },\n },\n },\n delete: {\n min_age: \"30d\",\n actions: {\n delete: {},\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.ilm.put_lifecycle(\n policy: \"my_policy\",\n body: {\n \"policy\": {\n \"_meta\": {\n \"description\": \"used for nginx log\",\n \"project\": {\n \"name\": \"myProject\",\n \"department\": \"myDepartment\"\n }\n },\n \"phases\": {\n \"warm\": {\n \"min_age\": \"10d\",\n \"actions\": {\n \"forcemerge\": {\n \"max_num_segments\": 1\n }\n }\n },\n \"delete\": {\n \"min_age\": \"30d\",\n \"actions\": {\n \"delete\": {}\n }\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->ilm()->putLifecycle([\n \"policy\" => \"my_policy\",\n \"body\" => [\n \"policy\" => [\n \"_meta\" => [\n \"description\" => \"used for nginx log\",\n \"project\" => [\n \"name\" => \"myProject\",\n \"department\" => \"myDepartment\",\n ],\n ],\n \"phases\" => [\n \"warm\" => [\n \"min_age\" => \"10d\",\n \"actions\" => [\n \"forcemerge\" => [\n \"max_num_segments\" => 1,\n ],\n ],\n ],\n \"delete\" => [\n \"min_age\" => \"30d\",\n \"actions\" => [\n \"delete\" => new ArrayObject([]),\n ],\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"policy\":{\"_meta\":{\"description\":\"used for nginx log\",\"project\":{\"name\":\"myProject\",\"department\":\"myDepartment\"}},\"phases\":{\"warm\":{\"min_age\":\"10d\",\"actions\":{\"forcemerge\":{\"max_num_segments\":1}}},\"delete\":{\"min_age\":\"30d\",\"actions\":{\"delete\":{}}}}}}' \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" - }, - { - "language": "Java", - "code": "client.ilm().putLifecycle(p -> p\n .name(\"my_policy\")\n .policy(po -> po\n .phases(ph -> ph\n .delete(d -> d\n .actions(a -> a\n .delete(de -> de)\n )\n .minAge(m -> m\n .time(\"30d\")\n )\n )\n .warm(w -> w\n .actions(a -> a\n .forcemerge(f -> f\n .maxNumSegments(1)\n )\n )\n .minAge(m -> m\n .time(\"10d\")\n )\n )\n )\n .meta(Map.of(\"description\", JsonData.fromJson(\"\\\"used for nginx log\\\"\"),\"project\", JsonData.fromJson(\"{\\\"name\\\":\\\"myProject\\\",\\\"department\\\":\\\"myDepartment\\\"}\")))\n )\n);\n" - } - ], - "specification/sql/delete_async/examples/request/SqlDeleteAsyncExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.delete_async(\n id=\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.deleteAsync({\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.delete_async(\n id: \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->deleteAsync([\n \"id\" => \"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/delete/FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\"" - }, - { - "language": "Java", - "code": "client.sql().deleteAsync(d -> d\n .id(\"FmdMX2pIang3UWhLRU5QS0lqdlppYncaMUpYQ05oSkpTc3kwZ21EdC1tbFJXQToxOTI=\")\n);\n" - } - ], - "specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.translate(\n query=\"SELECT * FROM library ORDER BY page_count DESC\",\n fetch_size=10,\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.translate({\n query: \"SELECT * FROM library ORDER BY page_count DESC\",\n fetch_size: 10,\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.translate(\n body: {\n \"query\": \"SELECT * FROM library ORDER BY page_count DESC\",\n \"fetch_size\": 10\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->translate([\n \"body\" => [\n \"query\" => \"SELECT * FROM library ORDER BY page_count DESC\",\n \"fetch_size\" => 10,\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"SELECT * FROM library ORDER BY page_count DESC\",\"fetch_size\":10}' \"$ELASTICSEARCH_URL/_sql/translate\"" - }, - { - "language": "Java", - "code": "client.sql().translate(t -> t\n .fetchSize(10)\n .query(\"SELECT * FROM library ORDER BY page_count DESC\")\n);\n" - } - ], - "specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.clear_cursor(\n cursor=\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.clearCursor({\n cursor:\n \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.clear_cursor(\n body: {\n \"cursor\": \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->clearCursor([\n \"body\" => [\n \"cursor\" => \"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cursor\":\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\"}' \"$ELASTICSEARCH_URL/_sql/close\"" - }, - { - "language": "Java", - "code": "client.sql().clearCursor(c -> c\n .cursor(\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=\")\n);\n" - } - ], - "specification/sql/get_async/examples/request/SqlGetAsyncExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.get_async(\n id=\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout=\"2s\",\n format=\"json\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.getAsync({\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout: \"2s\",\n format: \"json\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.get_async(\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n wait_for_completion_timeout: \"2s\",\n format: \"json\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->getAsync([\n \"id\" => \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n \"wait_for_completion_timeout\" => \"2s\",\n \"format\" => \"json\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=?wait_for_completion_timeout=2s&format=json\"" - }, - { - "language": "Java", - "code": "client.sql().getAsync(g -> g\n .format(\"json\")\n .id(\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\")\n .waitForCompletionTimeout(w -> w\n .offset(2)\n )\n);\n" - } - ], - "specification/sql/get_async_status/examples/request/SqlGetAsyncStatusExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.get_async_status(\n id=\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.getAsyncStatus({\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.get_async_status(\n id: \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\"\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->getAsyncStatus([\n \"id\" => \"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\",\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" \"$ELASTICSEARCH_URL/_sql/async/status/FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\"" - }, - { - "language": "Java", - "code": "client.sql().getAsyncStatus(g -> g\n .id(\"FnR0TDhyWUVmUmVtWXRWZER4MXZiNFEad2F5UDk2ZVdTVHV1S0xDUy00SklUdzozMTU=\")\n);\n" - } - ], - "specification/sql/query/examples/request/QuerySqlRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.sql.query(\n format=\"txt\",\n query=\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.sql.query({\n format: \"txt\",\n query: \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.sql.query(\n format: \"txt\",\n body: {\n \"query\": \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\"\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->sql()->query([\n \"format\" => \"txt\",\n \"body\" => [\n \"query\" => \"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\",\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\"}' \"$ELASTICSEARCH_URL/_sql?format=txt\"" - }, - { - "language": "Java", - "code": "client.sql().query(q -> q\n .format(SqlFormat.Txt)\n .query(\"SELECT * FROM library ORDER BY page_count DESC LIMIT 5\")\n);\n" - } - ], - "specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.cluster.allocation_explain(\n index=\"my-index-000001\",\n shard=\"0\",\n primary=False,\n current_node=\"my-node\",\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.cluster.allocationExplain({\n index: \"my-index-000001\",\n shard: 0,\n primary: \"false\",\n current_node: \"my-node\",\n});" - }, - { - "language": "Ruby", - "code": "response = client.cluster.allocation_explain(\n index: \"my-index-000001\",\n shard: \"0\",\n primary: \"false\",\n current_node: \"my-node\",\n body: {}\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->cluster()->allocationExplain([\n \"index\" => \"my-index-000001\",\n \"shard\" => \"0\",\n \"primary\" => \"false\",\n \"current_node\" => \"my-node\",\n \"body\" => new ArrayObject([]),\n]);" - }, - { - "language": "curl", - "code": "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{}' \"$ELASTICSEARCH_URL/_cluster/allocation/explain?index=my-index-000001&shard=0&primary=false¤t_node=my-node\"" - }, - { - "language": "Java", - "code": "client.cluster().allocationExplain(a -> a\n .currentNode(\"my-node\")\n .index(\"my-index-000001\")\n .primary(false)\n .shard(0)\n);\n" - } - ], - "specification/inference/put_cohere/examples/request/PutCohereRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"cohere-completion\",\n inference_config={\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"command-a-03-2025\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"cohere-completion\",\n inference_config: {\n service: \"cohere\",\n service_settings: {\n api_key: \"Cohere-API-key\",\n model_id: \"command-a-03-2025\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"cohere-completion\",\n body: {\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"command-a-03-2025\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"cohere-completion\",\n \"body\" => [\n \"service\" => \"cohere\",\n \"service_settings\" => [\n \"api_key\" => \"Cohere-API-key\",\n \"model_id\" => \"command-a-03-2025\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-API-key\",\"model_id\":\"command-a-03-2025\"}}' \"$ELASTICSEARCH_URL/_inference/completion/cohere-completion\"" - } - ], - "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"amazon_sagemaker_embeddings\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\",\n \"dimensions\": 384,\n \"element_type\": \"float\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"amazon_sagemaker_embeddings\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n dimensions: 384,\n element_type: \"float\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"amazon_sagemaker_embeddings\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\",\n \"dimensions\": 384,\n \"element_type\": \"float\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"amazon_sagemaker_embeddings\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n \"dimensions\" => 384,\n \"element_type\" => \"float\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\",\"dimensions\":384,\"element_type\":\"float\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/amazon_sagemaker_embeddings\"" - } - ], - "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"amazon_sagemaker_completion\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"amazon_sagemaker_completion\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"amazon_sagemaker_completion\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"amazon_sagemaker_completion\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/completion/amazon_sagemaker_completion\"" - } - ], - "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"chat_completion\",\n inference_id=\"amazon_sagemaker_chat_completion\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"chat_completion\",\n inference_id: \"amazon_sagemaker_chat_completion\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"chat_completion\",\n inference_id: \"amazon_sagemaker_chat_completion\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"chat_completion\",\n \"inference_id\" => \"amazon_sagemaker_chat_completion\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/chat_completion/amazon_sagemaker_chat_completion\"" - } - ], - "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"sparse_embedding\",\n inference_id=\"amazon_sagemaker_sparse_embedding\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"sparse_embedding\",\n inference_id: \"amazon_sagemaker_sparse_embedding\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"sparse_embedding\",\n inference_id: \"amazon_sagemaker_sparse_embedding\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"sparse_embedding\",\n \"inference_id\" => \"amazon_sagemaker_sparse_embedding\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/amazon_sagemaker_sparse_embedding\"" - } - ], - "specification/inference/put_amazonsagemaker/examples/request/PutAmazonSageMakerRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"amazon_sagemaker_rerank\",\n inference_config={\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"amazon_sagemaker_rerank\",\n inference_config: {\n service: \"amazon_sagemaker\",\n service_settings: {\n access_key: \"AWS-access-key\",\n secret_key: \"AWS-secret-key\",\n region: \"us-east-1\",\n api: \"elastic\",\n endpoint_name: \"my-endpoint\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"amazon_sagemaker_rerank\",\n body: {\n \"service\": \"amazon_sagemaker\",\n \"service_settings\": {\n \"access_key\": \"AWS-access-key\",\n \"secret_key\": \"AWS-secret-key\",\n \"region\": \"us-east-1\",\n \"api\": \"elastic\",\n \"endpoint_name\": \"my-endpoint\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"amazon_sagemaker_rerank\",\n \"body\" => [\n \"service\" => \"amazon_sagemaker\",\n \"service_settings\" => [\n \"access_key\" => \"AWS-access-key\",\n \"secret_key\" => \"AWS-secret-key\",\n \"region\" => \"us-east-1\",\n \"api\" => \"elastic\",\n \"endpoint_name\" => \"my-endpoint\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"amazon_sagemaker\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"api\":\"elastic\",\"endpoint_name\":\"my-endpoint\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/amazon_sagemaker_rerank\"" - } - ], - "specification/inference/put_ai21/examples/request/PutAi21RequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"completion\",\n inference_id=\"ai21-completion\",\n inference_config={\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-large\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"completion\",\n inference_id: \"ai21-completion\",\n inference_config: {\n service: \"ai21\",\n service_settings: {\n api_key: \"ai21-api-key\",\n model_id: \"jamba-large\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"completion\",\n inference_id: \"ai21-completion\",\n body: {\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-large\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"completion\",\n \"inference_id\" => \"ai21-completion\",\n \"body\" => [\n \"service\" => \"ai21\",\n \"service_settings\" => [\n \"api_key\" => \"ai21-api-key\",\n \"model_id\" => \"jamba-large\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"ai21\",\"service_settings\":{\"api_key\":\"ai21-api-key\",\"model_id\":\"jamba-large\"}}' \"$ELASTICSEARCH_URL/_inference/completion/ai21-completion\"" - } - ], - "specification/inference/put_ai21/examples/request/PutAi21RequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"chat-completion\",\n inference_id=\"ai21-chat-completion\",\n inference_config={\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-mini\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"chat-completion\",\n inference_id: \"ai21-chat-completion\",\n inference_config: {\n service: \"ai21\",\n service_settings: {\n api_key: \"ai21-api-key\",\n model_id: \"jamba-mini\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"chat-completion\",\n inference_id: \"ai21-chat-completion\",\n body: {\n \"service\": \"ai21\",\n \"service_settings\": {\n \"api_key\": \"ai21-api-key\",\n \"model_id\": \"jamba-mini\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"chat-completion\",\n \"inference_id\" => \"ai21-chat-completion\",\n \"body\" => [\n \"service\" => \"ai21\",\n \"service_settings\" => [\n \"api_key\" => \"ai21-api-key\",\n \"model_id\" => \"jamba-mini\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"ai21\",\"service_settings\":{\"api_key\":\"ai21-api-key\",\"model_id\":\"jamba-mini\"}}' \"$ELASTICSEARCH_URL/_inference/chat-completion/ai21-chat-completion\"" - } - ], - "specification/inference/put_custom/examples/request/PutCustomRequestExample1.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-embeddings\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.openai.com/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\"\n },\n \"request\": \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-embeddings\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.openai.com/v1/embeddings\",\n headers: {\n Authorization: \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\",\n },\n request: '{\"input\": ${input}, \"model\": \"text-embedding-3-small\"}',\n response: {\n json_parser: {\n text_embeddings: \"$.data[*].embedding[*]\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-embeddings\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.openai.com/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json;charset=utf-8\"\n },\n \"request\": \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-embeddings\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.openai.com/v1/embeddings\",\n \"headers\" => [\n \"Authorization\" => \"Bearer ${api_key}\",\n \"Content-Type\" => \"application/json;charset=utf-8\",\n ],\n \"request\" => \"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.data[*].embedding[*]\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.openai.com/v1/embeddings\",\"headers\":{\"Authorization\":\"Bearer ${api_key}\",\"Content-Type\":\"application/json;charset=utf-8\"},\"request\":\"{\\\"input\\\": ${input}, \\\"model\\\": \\\"text-embedding-3-small\\\"}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.data[*].embedding[*]\"}}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-embeddings\"" - } - ], - "specification/inference/put_custom/examples/request/PutCustomRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-text-embedding\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/embed\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.embeddings.float[*]\"\n }\n },\n \"input_type\": {\n \"translation\": {\n \"ingest\": \"search_document\",\n \"search\": \"search_query\"\n },\n \"default\": \"search_document\"\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.cohere.com/v2/embed\",\n headers: {\n Authorization: \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request:\n '{\"texts\": ${input}, \"model\": \"embed-v4.0\", \"input_type\": ${input_type}}',\n response: {\n json_parser: {\n text_embeddings: \"$.embeddings.float[*]\",\n },\n },\n input_type: {\n translation: {\n ingest: \"search_document\",\n search: \"search_query\",\n },\n default: \"search_document\",\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/embed\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.embeddings.float[*]\"\n }\n },\n \"input_type\": {\n \"translation\": {\n \"ingest\": \"search_document\",\n \"search\": \"search_query\"\n },\n \"default\": \"search_document\"\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-text-embedding\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.cohere.com/v2/embed\",\n \"headers\" => [\n \"Authorization\" => \"bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.embeddings.float[*]\",\n ],\n ],\n \"input_type\" => [\n \"translation\" => [\n \"ingest\" => \"search_document\",\n \"search\" => \"search_query\",\n ],\n \"default\" => \"search_document\",\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.cohere.com/v2/embed\",\"headers\":{\"Authorization\":\"bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"texts\\\": ${input}, \\\"model\\\": \\\"embed-v4.0\\\", \\\"input_type\\\": ${input_type}}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.embeddings.float[*]\"}},\"input_type\":{\"translation\":{\"ingest\":\"search_document\",\"search\":\"search_query\"},\"default\":\"search_document\"}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-text-embedding\"" - } - ], - "specification/inference/put_custom/examples/request/PutCustomRequestExample2.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"custom-rerank\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/rerank\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"reranked_index\": \"$.results[*].index\",\n \"relevance_score\": \"$.results[*].relevance_score\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"custom-rerank\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.cohere.com/v2/rerank\",\n headers: {\n Authorization: \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request:\n '{\"documents\": ${input}, \"query\": ${query}, \"model\": \"rerank-v3.5\"}',\n response: {\n json_parser: {\n reranked_index: \"$.results[*].index\",\n relevance_score: \"$.results[*].relevance_score\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"custom-rerank\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.cohere.com/v2/rerank\",\n \"headers\": {\n \"Authorization\": \"bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\": {\n \"json_parser\": {\n \"reranked_index\": \"$.results[*].index\",\n \"relevance_score\": \"$.results[*].relevance_score\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"custom-rerank\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.cohere.com/v2/rerank\",\n \"headers\" => [\n \"Authorization\" => \"bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\n \"response\" => [\n \"json_parser\" => [\n \"reranked_index\" => \"$.results[*].index\",\n \"relevance_score\" => \"$.results[*].relevance_score\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.cohere.com/v2/rerank\",\"headers\":{\"Authorization\":\"bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"documents\\\": ${input}, \\\"query\\\": ${query}, \\\"model\\\": \\\"rerank-v3.5\\\"}\",\"response\":{\"json_parser\":{\"reranked_index\":\"$.results[*].index\",\"relevance_score\":\"$.results[*].relevance_score\"}}}}' \"$ELASTICSEARCH_URL/_inference/rerank/custom-rerank\"" - } - ], - "specification/inference/put_custom/examples/request/PutCustomRequestExample5.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"text_embedding\",\n inference_id=\"custom-text-embedding-hf\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"input\\\": ${input}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding-hf\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"/v1/embeddings\",\n headers: {\n Authorization: \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\",\n },\n request: '{\"input\": ${input}}',\n response: {\n json_parser: {\n text_embeddings: \"$.data[*].embedding[*]\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"text_embedding\",\n inference_id: \"custom-text-embedding-hf\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"/v1/embeddings\",\n \"headers\": {\n \"Authorization\": \"Bearer ${api_key}\",\n \"Content-Type\": \"application/json\"\n },\n \"request\": \"{\\\"input\\\": ${input}}\",\n \"response\": {\n \"json_parser\": {\n \"text_embeddings\": \"$.data[*].embedding[*]\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"text_embedding\",\n \"inference_id\" => \"custom-text-embedding-hf\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"/v1/embeddings\",\n \"headers\" => [\n \"Authorization\" => \"Bearer ${api_key}\",\n \"Content-Type\" => \"application/json\",\n ],\n \"request\" => \"{\\\"input\\\": ${input}}\",\n \"response\" => [\n \"json_parser\" => [\n \"text_embeddings\" => \"$.data[*].embedding[*]\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"/v1/embeddings\",\"headers\":{\"Authorization\":\"Bearer ${api_key}\",\"Content-Type\":\"application/json\"},\"request\":\"{\\\"input\\\": ${input}}\",\"response\":{\"json_parser\":{\"text_embeddings\":\"$.data[*].embedding[*]\"}}}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/custom-text-embedding-hf\"" - } - ], - "specification/inference/put_custom/examples/request/PutCustomRequestExample4.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"custom-rerank-jina\",\n inference_config={\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.jina.ai/v1/rerank\",\n \"headers\": {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${api_key}\"\n },\n \"request\": \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\": {\n \"json_parser\": {\n \"relevance_score\": \"$.results[*].relevance_score\",\n \"reranked_index\": \"$.results[*].index\"\n }\n }\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"custom-rerank-jina\",\n inference_config: {\n service: \"custom\",\n service_settings: {\n secret_parameters: {\n api_key: \"\",\n },\n url: \"https://api.jina.ai/v1/rerank\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: \"Bearer ${api_key}\",\n },\n request:\n '{\"model\": \"jina-reranker-v2-base-multilingual\",\"query\": ${query},\"documents\":${input}}',\n response: {\n json_parser: {\n relevance_score: \"$.results[*].relevance_score\",\n reranked_index: \"$.results[*].index\",\n },\n },\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"custom-rerank-jina\",\n body: {\n \"service\": \"custom\",\n \"service_settings\": {\n \"secret_parameters\": {\n \"api_key\": \"\"\n },\n \"url\": \"https://api.jina.ai/v1/rerank\",\n \"headers\": {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${api_key}\"\n },\n \"request\": \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\": {\n \"json_parser\": {\n \"relevance_score\": \"$.results[*].relevance_score\",\n \"reranked_index\": \"$.results[*].index\"\n }\n }\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"custom-rerank-jina\",\n \"body\" => [\n \"service\" => \"custom\",\n \"service_settings\" => [\n \"secret_parameters\" => [\n \"api_key\" => \"\",\n ],\n \"url\" => \"https://api.jina.ai/v1/rerank\",\n \"headers\" => [\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer ${api_key}\",\n ],\n \"request\" => \"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\n \"response\" => [\n \"json_parser\" => [\n \"relevance_score\" => \"$.results[*].relevance_score\",\n \"reranked_index\" => \"$.results[*].index\",\n ],\n ],\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"custom\",\"service_settings\":{\"secret_parameters\":{\"api_key\":\"\"},\"url\":\"https://api.jina.ai/v1/rerank\",\"headers\":{\"Content-Type\":\"application/json\",\"Authorization\":\"Bearer ${api_key}\"},\"request\":\"{\\\"model\\\": \\\"jina-reranker-v2-base-multilingual\\\",\\\"query\\\": ${query},\\\"documents\\\":${input}}\",\"response\":{\"json_parser\":{\"relevance_score\":\"$.results[*].relevance_score\",\"reranked_index\":\"$.results[*].index\"}}}}' \"$ELASTICSEARCH_URL/_inference/rerank/custom-rerank-jina\"" - } - ], - "specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample3.yaml": [ - { - "language": "Python", - "code": "resp = client.inference.put(\n task_type=\"rerank\",\n inference_id=\"azure_ai_studio_rerank\",\n inference_config={\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"cohere\",\n \"endpoint_type\": \"token\"\n }\n },\n)" - }, - { - "language": "JavaScript", - "code": "const response = await client.inference.put({\n task_type: \"rerank\",\n inference_id: \"azure_ai_studio_rerank\",\n inference_config: {\n service: \"azureaistudio\",\n service_settings: {\n api_key: \"Azure-AI-Studio-API-key\",\n target: \"Target-URI\",\n provider: \"cohere\",\n endpoint_type: \"token\",\n },\n },\n});" - }, - { - "language": "Ruby", - "code": "response = client.inference.put(\n task_type: \"rerank\",\n inference_id: \"azure_ai_studio_rerank\",\n body: {\n \"service\": \"azureaistudio\",\n \"service_settings\": {\n \"api_key\": \"Azure-AI-Studio-API-key\",\n \"target\": \"Target-URI\",\n \"provider\": \"cohere\",\n \"endpoint_type\": \"token\"\n }\n }\n)" - }, - { - "language": "PHP", - "code": "$resp = $client->inference()->put([\n \"task_type\" => \"rerank\",\n \"inference_id\" => \"azure_ai_studio_rerank\",\n \"body\" => [\n \"service\" => \"azureaistudio\",\n \"service_settings\" => [\n \"api_key\" => \"Azure-AI-Studio-API-key\",\n \"target\" => \"Target-URI\",\n \"provider\" => \"cohere\",\n \"endpoint_type\" => \"token\",\n ],\n ],\n]);" - }, - { - "language": "curl", - "code": "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"provider\":\"cohere\",\"endpoint_type\":\"token\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/azure_ai_studio_rerank\"" - } - ] -} \ No newline at end of file