Skip to content

Commit 078dc12

Browse files
committed
java examples update
1 parent 4926284 commit 078dc12

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/examples/languageExamples.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,10 @@
24012401
{
24022402
"language": "curl",
24032403
"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\""
2404+
},
2405+
{
2406+
"language": "Java",
2407+
"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"
24042408
}
24052409
],
24062410
"specification/indices/put_settings/examples/request/indicesPutSettingsRequestExample2.yaml": [
@@ -5431,6 +5435,10 @@
54315435
{
54325436
"language": "curl",
54335437
"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\""
5438+
},
5439+
{
5440+
"language": "Java",
5441+
"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"
54345442
}
54355443
],
54365444
"specification/_global/reindex/examples/request/ReindexRequestExample5.yaml": [
@@ -5453,6 +5461,10 @@
54535461
{
54545462
"language": "curl",
54555463
"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\""
5464+
},
5465+
{
5466+
"language": "Java",
5467+
"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"
54565468
}
54575469
],
54585470
"specification/_global/reindex/examples/request/ReindexRequestExample11.yaml": [
@@ -5475,6 +5487,10 @@
54755487
{
54765488
"language": "curl",
54775489
"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\""
5490+
},
5491+
{
5492+
"language": "Java",
5493+
"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"
54785494
}
54795495
],
54805496
"specification/_global/reindex/examples/request/ReindexRequestExample10.yaml": [
@@ -5497,6 +5513,10 @@
54975513
{
54985514
"language": "curl",
54995515
"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\""
5516+
},
5517+
{
5518+
"language": "Java",
5519+
"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"
55005520
}
55015521
],
55025522
"specification/_global/reindex/examples/request/ReindexRequestExample4.yaml": [
@@ -5519,6 +5539,10 @@
55195539
{
55205540
"language": "curl",
55215541
"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\""
5542+
},
5543+
{
5544+
"language": "Java",
5545+
"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"
55225546
}
55235547
],
55245548
"specification/_global/reindex/examples/request/ReindexRequestExample8.yaml": [
@@ -5541,6 +5565,10 @@
55415565
{
55425566
"language": "curl",
55435567
"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\""
5568+
},
5569+
{
5570+
"language": "Java",
5571+
"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"
55445572
}
55455573
],
55465574
"specification/_global/reindex/examples/request/ReindexRequestExample3.yaml": [
@@ -5563,6 +5591,10 @@
55635591
{
55645592
"language": "curl",
55655593
"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\""
5594+
},
5595+
{
5596+
"language": "Java",
5597+
"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"
55665598
}
55675599
],
55685600
"specification/_global/reindex/examples/request/ReindexRequestExample2.yaml": [
@@ -5585,6 +5617,10 @@
55855617
{
55865618
"language": "curl",
55875619
"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\""
5620+
},
5621+
{
5622+
"language": "Java",
5623+
"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"
55885624
}
55895625
],
55905626
"specification/_global/reindex/examples/request/ReindexRequestExample1.yaml": [
@@ -5633,6 +5669,10 @@
56335669
{
56345670
"language": "curl",
56355671
"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\""
5672+
},
5673+
{
5674+
"language": "Java",
5675+
"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"
56365676
}
56375677
],
56385678
"specification/_global/reindex/examples/request/ReindexRequestExample7.yaml": [
@@ -5655,6 +5695,10 @@
56555695
{
56565696
"language": "curl",
56575697
"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\""
5698+
},
5699+
{
5700+
"language": "Java",
5701+
"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"
56585702
}
56595703
],
56605704
"specification/_global/reindex/examples/request/ReindexRequestExample6.yaml": [
@@ -5677,6 +5721,10 @@
56775721
{
56785722
"language": "curl",
56795723
"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\""
5724+
},
5725+
{
5726+
"language": "Java",
5727+
"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"
56805728
}
56815729
],
56825730
"specification/_global/reindex/examples/request/ReindexRequestExample12.yaml": [
@@ -5699,6 +5747,10 @@
56995747
{
57005748
"language": "curl",
57015749
"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\""
5750+
},
5751+
{
5752+
"language": "Java",
5753+
"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"
57025754
}
57035755
],
57045756
"specification/_global/index/examples/request/IndexRequestExample1.yaml": [
@@ -16857,6 +16909,10 @@
1685716909
{
1685816910
"language": "curl",
1685916911
"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&current_node=my-node\""
16912+
},
16913+
{
16914+
"language": "Java",
16915+
"code": "client.cluster().allocationExplain(a -> a\n .currentNode(\"my-node\")\n .index(\"my-index-000001\")\n .primary(false)\n .shard(0)\n);\n"
1686016916
}
1686116917
]
1686216918
}

0 commit comments

Comments
 (0)