// 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,
  filter_path: "aggregations",
  aggs: {
    the_filter: {
      filters: {
        keyed: false,
        filters: {
          "t-shirt": {
            term: {
              type: "t-shirt",
            },
          },
          hat: {
            term: {
              type: "hat",
            },
          },
        },
      },
      aggs: {
        avg_price: {
          avg: {
            field: "price",
          },
        },
        sort_by_avg_price: {
          bucket_sort: {
            sort: {
              avg_price: "asc",
            },
          },
        },
      },
    },
  },
});
console.log(response);
----
