{
  "id": "flatmap",
  "title": "FlatMap",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsbuilder/flatmap/",
  "summary": "Maps a single input record to one or more output records.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "660cc5c50794fff73b0678926fddb6913a423bd32b1141ddd6cc3574d6eac98a",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "[code example]\n\nMaps a single input record to one or more output records.\n\nThe FlatMap operation must return an [`Iterable`](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html). RedisGears \nsplits the elements from the `Iterable` object and processes them as individual records."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "Type parameters:\n\n| Name | Description |\n|------|-------------|\n| I | The template type of the returned builder object |\n\nFunction parameters:\n\n| Name | Type | Description |\n|------|------|-------------|\n| flatmapper | <nobr>FlatMapOperation<T,​I></nobr> | For each input record, returns one or more output records |"
    },
    {
      "id": "returns",
      "title": "Returns",
      "role": "returns",
      "text": "Returns a GearsBuilder object with a new template type."
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "java",
      "code": "public <I extends java.io.Serializable> GearsBuilder<I> flatMap​(\n\tgears.operations.FlatMapOperation<T,​I> flatmapper)",
      "section_id": "overview"
    },
    {
      "id": "example-ex0",
      "language": "java",
      "code": "GearsBuilder.CreateGearsBuilder(reader).flatMap(r->{\n   \treturn r.getListVal();\n});",
      "section_id": "example"
    }
  ]
}
