Map functions Stay organized with collections Save and categorize content based on your preferences.
Map Functions
| Name | Description |
MAP | Constructs a map value from a series of key-value pairs |
MAP_GET | Returns the value in a map given a specified key |
MAP_SET | Returns a copy of a map with a series of updated keys |
MAP_REMOVE | Returns a copy of a map with a series of keys removed |
MAP_MERGE | Merges a series of maps together. |
CURRENT_CONTEXT | Returns the current context as a map. |
MAP_KEYS | Returns an array of all keys in a map. |
MAP_VALUES | Returns an array of all values in a map. |
MAP_ENTRIES | Returns an array of key-value pairs of a map. |
MAP
Syntax:
map(key: STRING, value: ANY, ...) -> MAPDescription:
Constructs a map from a series of key-value pairs.
MAP_GET
Syntax:
map_get(map: ANY, key: STRING) -> ANYDescription:
Returns the value in a map given a specified key. Returns anABSENT value if thekey does not exist in the map, or if themap argument is not aMAP.
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("awards").mapGet("pulitzer").as("hasPulitzerAward")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("awards").mapGet("pulitzer").as("hasPulitzerAward")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("awards").mapGet("pulitzer").as("hasPulitzerAward")]).execute()
Kotlin
valresult=db.pipeline().collection("books").select(field("awards").mapGet("pulitzer").alias("hasPulitzerAward")).execute()
Java
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("awards").mapGet("pulitzer").alias("hasPulitzerAward")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("awards").map_get("pulitzer").as_("hasPulitzerAward")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(mapGet(field("awards"),"pulitzer").as("hasPulitzerAward")).execute().get();
MAP_SET
Syntax:
map_set(map: MAP, key: STRING, value: ANY, ...) -> MAPDescription:
Returns a copy of themap value with its contents updated by a series of key-value pairs.
If the given resolves to an absent value, the associated key is removed from the map.
If themap argument is not aMAP, returns an absent value.
MAP_REMOVE
Syntax:
map_remove(map: MAP, key: STRING...) -> MAPDescription:
Returns a copy of themap value with a series of keys removed.
MAP_MERGE
Syntax:
map_merge(maps: MAP...) -> MAPMerges the contents of 2 or more maps. If multiple maps have conflicting values, the last value is used.
CURRENT_CONTEXT
Syntax:
current_context() -> MAPReturns a map consisting of all available fields in the current point of execution.
MAP_KEYS
Syntax:
map_keys(map: MAP) -> ARRAY<STRING>Description:
Returns an array containing all keys of themap value.
MAP_VALUES
Syntax:
map_values(map: MAP) -> ARRAY<ANY>Description:
Returns an array containing all values of themap value.
MAP_ENTRIES
Syntax:
map_entries(map: MAP) -> ARRAY<MAP>Description:
Returns an array containing all key-value pairs in themap value.
Each key-value pair will be in the form of a map with two entries,k andv.
Examples:
map | map_entries(map) |
|---|---|
| {} | [] |
| {"foo" : 2L} | [{"k": "foo", "v" : 2L}] |
| {"foo" : "bar", "bar" : "foo"} | [{"k": "foo", "v" : "bar" }, {"k" : "bar", "v": "foo"}] |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.