> ## Documentation Index
> Fetch the complete documentation index at: https://docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> FalkorDB is a graph database that speaks the Redis protocol. Queries are issued as OpenCypher through the GRAPH.QUERY and GRAPH.RO_QUERY commands, not over Bolt or a SQL connection.
> FalkorDB implements a subset of OpenCypher with proprietary extensions. Do not assume Neo4j-only syntax or procedures are available — check /cypher/cypher-support and /cypher/known-limitations before using a clause.
> FalkorDB is the successor to RedisGraph, but they are separate products. Do not present RedisGraph commands, versions, or limitations as current FalkorDB behavior.
> Use the official clients listed in /getting-started/clients rather than generic Redis or Neo4j drivers, and prefer the language the user is already working in.
> Configuration parameters are set with GRAPH.CONFIG SET or at startup; cite the exact parameter name from /getting-started/configuration rather than inventing one.
> This site covers four products: FalkorDB (core), FalkorDB Cloud, FalkorDB Enterprise, and the GraphRAG SDK. Name which one an answer applies to, since setup and operations differ.

# map.merge

> Performs a shallow merge of multiple maps, with later map values overriding earlier ones on key conflicts.

## Description

Performs a shallow merge of multiple maps into a new map. When keys conflict, values from later maps override earlier ones. Non-object inputs are ignored.

## Syntax

```cypher theme={null}
flex.map.merge(map1, map2, ...)
```

## Parameters

| Parameter | Type | Required | Description              |
| --------- | ---- | -------- | ------------------------ |
| `map1`    | map  | No       | First map to merge       |
| `map2`    | map  | No       | Second map to merge      |
| `...`     | map  | No       | Additional maps to merge |

## Returns

**Type:** map (object)

A new map containing all keys and values from the input maps. Later maps override earlier ones for duplicate keys.

## Examples

### Example 1: Basic Merge

```cypher theme={null}
WITH {a: 1, b: 2} AS map1, {b: 3, c: 4} AS map2
RETURN flex.map.merge(map1, map2) AS result
```

**Output:**

```text theme={null}
result
------------------
{a: 1, b: 3, c: 4}
```

(Note: `b` from map2 overrides `b` from map1)

### Example 2: Merging Node Properties

```cypher theme={null}
MATCH (u:User {id: 123})
WITH {role: 'admin', status: 'active'} AS defaults
RETURN flex.map.merge(defaults, properties(u)) AS userWithDefaults
```

### Example 3: Combining Configuration

```cypher theme={null}
WITH {host: 'localhost', port: 6379} AS defaults,
     {port: 7000, password: 'secret'} AS config
RETURN flex.map.merge(defaults, config) AS finalConfig
```

**Output:**

```text theme={null}
finalConfig
--------------------------------------------------
{host: 'localhost', port: 7000, password: 'secret'}
```

### Example 4: Merging Multiple Maps

```cypher theme={null}
WITH {a: 1} AS base, {b: 2} AS extra1, {c: 3} AS extra2
RETURN flex.map.merge(base, extra1, extra2) AS combined
```

## Notes

* Non-object inputs are silently ignored
* Performs shallow merge (nested objects are not deeply merged)
* Later maps take precedence for duplicate keys
* Returns a new map; does not modify input maps
* Useful for applying defaults, combining configuration, or merging properties

## See Also

* [map.submap](/udfs/flex/map/submap) - Extract specific keys from a map
* [map.removeKeys](/udfs/flex/map/removeKeys) - Remove keys from a map

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Does flex.map.merge do a deep or shallow merge?">
    It performs a **shallow** merge. Nested maps are not recursively merged — values from later maps overwrite those from earlier maps.
  </Accordion>

  <Accordion title="Can I merge more than two maps?">
    Yes. You can pass multiple maps as arguments to merge them all in sequence.
  </Accordion>
</AccordionGroup>
