// 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: "test*",
  filter_path: "aggregations",
  aggs: {
    ip: {
      terms: {
        field: "ip",
      },
      aggs: {
        tm: {
          top_metrics: {
            metrics: {
              field: "m",
            },
            sort: {
              s: "desc",
            },
            size: 1,
          },
        },
        having_tm: {
          bucket_selector: {
            buckets_path: {
              top_m: "tm[m]",
            },
            script: "params.top_m < 1000",
          },
        },
      },
    },
  },
});
console.log(response);
----
