# Supported data types

This page describes the data types that Cloud Firestore supports.

## Data types

The following table lists the data types supported by Cloud Firestore. It also describes the sort order used when comparing values of the same type:

| Data type            | Sort order                            | Notes                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|----------------------|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Array                | By element values                     | In Standard edition databases, an array cannot contain another array value as one of its elements. In Enterprise edition databases, an array can contain an array value as one of its elements. Within an array, elements maintain the position assigned to them. When sorting two or more arrays, arrays are ordered based on their element values. When comparing two arrays, the first elements of each array are compared. If the first elements are equal, then the second elements are compared and so on until a difference is found. If an array runs out of elements to compare but is equal up to that point, then the shorter array is ordered before the longer array. For example, `[1, 2, 3] < [1, 2, 3, 1] < [2]`. The array `[2]` has the greatest first element value. The array `[1, 2, 3]` has elements equal to the first three elements of `[1, 2, 3, 1]` but is shorter in length. |
| Boolean              | `false` < `true`                     | —                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Bytes                | Byte order                           | In Standard edition databases, the value must not exceed 1,048,487 bytes (1 MiB - 89 bytes) and only the first 1,500 bytes are considered by queries. In Enterprise edition databases, there is no limit on the size of the value (other than document and index entry size limits) and the full value is considered by queries.                                                                     |
| Date and time        | Chronological                        | When stored in Cloud Firestore, precise only to microseconds; any additional precision is rounded down.                                                                                                                                                                                                                                                                                                                                                  |
| Floating-point number | Numeric                              | 64-bit double precision according to [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754), including (normalized) `NaN` & `+/-Infinity`.                                                                                                                                                                                                                                                                                                                |
| Geographical point    | By latitude, then longitude         | To search based on distance, see [Geospatial search](/content/docs/firestore/enterprise/geospatial-search/index.html).                                                                                                                                                                                                                                                                                                                         |
| Integer              | Numeric                              | 64-bit, signed                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Map                  | By keys, then by value              | Represents an object embedded within a document. When indexed, you can query on subfields. If you exclude this value from indexing, then all subfields are also excluded from indexing. Key ordering is always sorted. For example, if you write `{c: "foo", a: "bar", b: "qux"}` the map is sorted by key and saved as `{a: "bar", b: "qux", c: "foo"}`. Map fields are sorted by key and compared by key-value pairs, first comparing the keys and then the values. If the first key-value pairs are equal, the next key-value pairs are compared, and so on. If two maps have all of the same key-value pairs, then map length is considered. For example, the following maps are in ascending order: `{a: "aaa", b: "baz"}` `{a: "foo", b: "bar"}` `{a: "foo", b: "bar", c: "qux"}` `{a: "foo", b: "baz"}` `{b: "aaa", c: "baz"}` `{c: "aaa"}` |  
| Null                 | None                                | —                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Reference            | By path elements (collection, document ID, collection, document ID...) | For example, `projects/[PROJECT_ID]/databases/[DATABASE_ID]/documents/[DOCUMENT_PATH]`.                                                                                                                                                                                                                                                                                                                                                                    |
| Text string          | UTF-8 encoded byte order            | In Standard edition databases, the value must not exceed 1,048,487 bytes (1 MiB - 89 bytes) and only the first 1,500 bytes are considered by queries. In Enterprise edition databases, there is no limit on the size of the value (other than document and index entry size limits) and the full value is considered by queries.                                                                     |
| Vector               | By dimension and then by individual element values | The max supported embedding dimension is 2048. To store vectors with larger dimensions, use [dimensionality reduction](https://en.wikipedia.org/wiki/Dimensionality_reduction).                                                                                                                                                                                                                                                                                |

## Value type ordering

When a query involves a field with values of mixed types, Cloud Firestore uses a deterministic ordering based on the internal representations. The following list shows the order:

01. Null values
02. Boolean values
03. Integer and floating-point values, sorted in numerical order
04. Date values
05. Text string values
06. Byte values
07. Cloud Firestore references
08. Geographical point values
09. Array values
10. Vector embeddings
11. Map values

## Numeric ordering

Cloud Firestore sorts all numeric values (`Integer` & `Floating point`) interleaved with each other. Floating point comparison follows the total ordering of [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754) with the notable exception being that Cloud Firestore normalizes all `NaN` values, and considers it less than `-Infinity`.
