// 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: "my-data-stream",
  runtime_mappings: {
    "source.ip": {
      type: "ip",
      script:
        "\n        String sourceip=grok('%{IPORHOST:sourceip} .*').extract(doc[ \"message\" ].value)?.sourceip;\n        if (sourceip != null) emit(sourceip);\n      ",
    },
  },
  query: {
    bool: {
      filter: [
        {
          range: {
            "@timestamp": {
              gte: "now-1d/d",
              lt: "now/d",
            },
          },
        },
        {
          range: {
            "source.ip": {
              gte: "192.0.2.0",
              lte: "192.0.2.255",
            },
          },
        },
      ],
    },
  },
  fields: ["*"],
  _source: false,
  sort: [
    {
      "@timestamp": "desc",
    },
    {
      "source.ip": "desc",
    },
  ],
});
console.log(response);
----
