Map functions

Preview:Firestore in Native mode (with Pipeline operations) for Enterpriseedition is subject to the "Pre-GA Offerings Terms" in the GeneralService Terms section of theService SpecificTerms. You can process personaldata for this feature as outlined in theCloud Data Processing Addendum, subjectto the obligations and restrictions described in the agreement under which youaccess Google Cloud. Pre-GA features are available "as is" and might havelimited support. For more information, see thelaunch stagedescriptions.

Map Functions

NameDescription
MAPConstructs a map value from a series of key-value pairs
MAP_GETReturns the value in a map given a specified key
MAP_SETReturns a copy of a map with a series of updated keys
MAP_REMOVEReturns a copy of a map with a series of keys removed
MAP_MERGEMerges a series of maps together.
CURRENT_CONTEXTReturns the current context as a map.
MAP_KEYSReturns an array of all keys in a map.
MAP_VALUESReturns an array of all values in a map.
MAP_ENTRIESReturns an array of key-value pairs of a map.

MAP

Syntax:

map(key: STRING, value: ANY, ...) -> MAP

Description:

Constructs a map from a series of key-value pairs.

MAP_GET

Syntax:

map_get(map: ANY, key: STRING) -> ANY

Description:

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, ...) -> MAP

Description:

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...) -> MAP

Description:

Returns a copy of themap value with a series of keys removed.

MAP_MERGE

Syntax:

map_merge(maps: MAP...) -> MAP

Merges the contents of 2 or more maps. If multiple maps have conflicting values, the last value is used.

CURRENT_CONTEXT

Syntax:

current_context() -> MAP

Returns 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:

mapmap_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.