// 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: "my-index-000001",
  query: {
    match: {
      message: "GET /search",
    },
  },
  collapse: {
    field: "user.id",
    inner_hits: [
      {
        name: "largest_responses",
        size: 3,
        sort: [
          {
            "http.response.bytes": {
              order: "desc",
            },
          },
        ],
      },
      {
        name: "most_recent",
        size: 3,
        sort: [
          {
            "@timestamp": {
              order: "desc",
            },
          },
        ],
      },
    ],
  },
  sort: ["http.response.bytes"],
});
console.log(response);
----
