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

75 lines
1.1 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: "my-index",
mappings: {
properties: {
nr: {
type: "integer",
},
state: {
type: "keyword",
},
},
},
});
console.log(response);
const response1 = await client.bulk({
index: "my-index",
refresh: "true",
operations: [
{
index: {},
},
{
nr: 1,
state: "started",
},
{
index: {},
},
{
nr: 2,
state: "stopped",
},
{
index: {},
},
{
nr: 3,
state: "N/A",
},
{
index: {},
},
{
nr: 4,
},
],
});
console.log(response1);
const response2 = await client.search({
index: "my-index",
filter_path: "aggregations",
aggs: {
my_top_metrics: {
top_metrics: {
metrics: {
field: "state",
missing: "N/A",
},
sort: {
nr: "desc",
},
},
},
},
});
console.log(response2);
----