// 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.search({
  index: "sales",
  size: 0,
  query: {
    match: {
      type: "t-shirt",
    },
  },
  aggs: {
    all_products: {
      global: {},
      aggs: {
        avg_price: {
          avg: {
            field: "price",
          },
        },
      },
    },
    t_shirts: {
      avg: {
        field: "price",
      },
    },
  },
});
console.log(response);
----
