// 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);
----
