// 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,
  filter_path: "aggregations",
  aggs: {
    hats: {
      filter: {
        term: {
          type: "hat",
        },
      },
      aggs: {
        avg_price: {
          avg: {
            field: "price",
          },
        },
      },
    },
    t_shirts: {
      filter: {
        term: {
          type: "t-shirt",
        },
      },
      aggs: {
        avg_price: {
          avg: {
            field: "price",
          },
        },
      },
    },
  },
});
console.log(response);
----
