# Cloud Firestore Admin V1 API - Module Google::Cloud::Firestore::Admin::V1::Index::Density (v1.13.0)

1.13.0 (latest) 1.12.1 1.11.0 1.10.0 1.9.1 1.8.0 1.7.0 1.6.0 1.5.0 1.4.1 1.3.0 1.2.0 1.1.0 1.0.1 0.18.0 0.17.1 0.16.0 0.15.0 0.14.3 0.13.0 0.12.0 0.11.0 0.10.0 0.9.0 0.8.0 0.7.1 0.6.0 0.5.0 0.4.0 0.3.5 Reference documentation and code samples for the Cloud Firestore Admin V1 API module Google::Cloud::Firestore::Admin::V1::Index::Density.

The density configuration for the index.

## Constants

### DENSITY_UNSPECIFIED

**value:** 0  
Unspecified. It will use database default setting. This value is input
only.

### SPARSE_ALL

**value:** 1  
An index entry will only exist if ALL fields are present in the document.


This is both the default and only allowed value for Standard Edition
databases (for both Cloud Firestore `ANY_API` and Cloud Datastore
`DATASTORE_MODE_API`).

Take for example the following document:

`
{
"name": "...",
"a": 1,
"b": 2,
"c": 3
}
`

an index on `(a ASC, b ASC, c ASC, name ASC)` will generate an index
entry for this document since `a`, 'b', `c`, and `name` are all
present but an index of `(a ASC, d ASC, name ASC)` will not generate
an index entry for this document since `d` is missing.

<br />

This means that such indexes can only be used to serve a query when the
query has either implicit or explicit requirements that all fields from
the index are present.

### SPARSE_ANY

**value:** 2  
An index entry will exist if ANY field are present in the document.


This is used as the definition of a sparse index for Enterprise Edition
databases.

Take for example the following document:

`
{
"name": "...",
"a": 1,
"b": 2,
"c": 3
}
`

an index on `(a ASC, d ASC)` will generate an index entry for this
document since `a` is present, and will fill in an `unset` value for `d`.
An index on `(d ASC, e ASC)` will not generate any index entry as neither
`d` nor `e` are present.

<br />

An index that contains `name` will generate an index entry for all
documents since Firestore guarantees that all documents have a `name`
field.

### DENSE

**value:** 3  
An index entry will exist regardless of if the fields are present or not.


This is the default density for an Enterprise Edition database.

<br />

The index will store `unset` values for fields that are not present in
the document.