(cherry picked from commit f737290d10)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
79 lines
1.3 KiB
Plaintext
79 lines
1.3 KiB
Plaintext
// This file is autogenerated, DO NOT EDIT
|
|
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
|
|
|
[source, js]
|
|
----
|
|
const response = await client.indices.create({
|
|
index: "clientips",
|
|
mappings: {
|
|
properties: {
|
|
client_ip: {
|
|
type: "keyword",
|
|
},
|
|
env: {
|
|
type: "keyword",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.bulk({
|
|
index: "clientips",
|
|
operations: [
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
client_ip: "172.21.0.5",
|
|
env: "Development",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
client_ip: "172.21.2.113",
|
|
env: "QA",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
client_ip: "172.21.2.162",
|
|
env: "QA",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
client_ip: "172.21.3.15",
|
|
env: "Production",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
client_ip: "172.21.3.16",
|
|
env: "Production",
|
|
},
|
|
],
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.enrich.putPolicy({
|
|
name: "clientip_policy",
|
|
match: {
|
|
indices: "clientips",
|
|
match_field: "client_ip",
|
|
enrich_fields: ["env"],
|
|
},
|
|
});
|
|
console.log(response2);
|
|
|
|
const response3 = await client.enrich.executePolicy({
|
|
name: "clientip_policy",
|
|
wait_for_completion: "false",
|
|
});
|
|
console.log(response3);
|
|
----
|