// 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: "sales",
  size: 0,
  aggs: {
    by_date: {
      date_histogram: {
        field: "date",
        calendar_interval: "month",
      },
      aggs: {
        avg_number_of_sales_per_year: {
          rate: {
            field: "price",
            unit: "year",
            mode: "value_count",
          },
        },
      },
    },
  },
});
console.log(response);
----
