// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.mjs` to generate the docs examples

[source, js]
----
const response = await client.search({
  index: "user_hits",
  size: 0,
  aggs: {
    users_per_day: {
      date_histogram: {
        field: "timestamp",
        calendar_interval: "day",
      },
      aggs: {
        distinct_users: {
          cardinality: {
            field: "user_id",
          },
        },
        total_new_users: {
          cumulative_cardinality: {
            buckets_path: "distinct_users",
          },
        },
      },
    },
  },
});
console.log(response);
----
