Files
elasticsearch-js/docs/doc_examples/7a0eb2222fe282d3aab66e12feff2a3b.asciidoc
2024-07-29 17:10:05 -05:00

55 lines
1.0 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.index({
index: "ip_location",
refresh: "true",
document: {
ip: "192.168.1.1",
country: "Canada",
city: "Montreal",
},
});
console.log(response);
const response1 = await client.index({
index: "logs",
id: 1,
refresh: "true",
document: {
host: "192.168.1.1",
message: "the first message",
},
});
console.log(response1);
const response2 = await client.index({
index: "logs",
id: 2,
refresh: "true",
document: {
host: "192.168.1.2",
message: "the second message",
},
});
console.log(response2);
const response3 = await client.search({
index: "logs",
runtime_mappings: {
location: {
type: "lookup",
target_index: "ip_location",
input_field: "host",
target_field: "ip",
fetch_fields: ["country", "city"],
},
},
fields: ["host", "message", "location"],
_source: false,
});
console.log(response3);
----