// 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: "test",
  mappings: {
    properties: {
      d: {
        type: "date",
      },
    },
  },
});
console.log(response);

const response1 = await client.bulk({
  index: "test",
  refresh: "true",
  operations: [
    {
      index: {},
    },
    {
      s: 1,
      m: 3.1415,
      i: 1,
      d: "2020-01-01T00:12:12Z",
      t: "cat",
    },
    {
      index: {},
    },
    {
      s: 2,
      m: 1,
      i: 6,
      d: "2020-01-02T00:12:12Z",
      t: "dog",
    },
    {
      index: {},
    },
    {
      s: 3,
      m: 2.71828,
      i: -12,
      d: "2019-12-31T00:12:12Z",
      t: "chicken",
    },
  ],
});
console.log(response1);

const response2 = await client.search({
  index: "test",
  filter_path: "aggregations",
  aggs: {
    tm: {
      top_metrics: {
        metrics: [
          {
            field: "m",
          },
          {
            field: "i",
          },
          {
            field: "d",
          },
          {
            field: "t.keyword",
          },
        ],
        sort: {
          s: "desc",
        },
      },
    },
  },
});
console.log(response2);
----
