terraform-provider-google/website/docs/r/firestore_index.html.markdown

143 lines
4.3 KiB
Markdown
Raw Normal View History

---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
layout: "google"
page_title: "Google: google_firestore_index"
sidebar_current: "docs-google-firestore-index"
description: |-
Cloud Firestore indexes enable simple and complex queries against documents in a database.
---
# google\_firestore\_index
Cloud Firestore indexes enable simple and complex queries against documents in a database.
This resource manages composite indexes and not single
field indexes.
To get more information about Index, see:
* [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.indexes)
* How-to Guides
* [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=firestore_index_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Firestore Index Basic
```hcl
resource "google_firestore_index" "my-index" {
project = "my-project-name"
collection = "chatrooms"
fields {
field_path = "name"
order = "ASCENDING"
}
fields {
field_path = "description"
order = "DESCENDING"
}
fields {
field_path = "__name__"
order = "DESCENDING"
}
}
```
## Argument Reference
The following arguments are supported:
* `collection` -
(Required)
The collection being indexed.
* `fields` -
(Required)
The fields supported by this index. The last field entry is always for
the field path `__name__`. If, on creation, `__name__` was not
specified as the last field, it will be added automatically with the
same direction as that of the last field defined. If the final field
in a composite index is not directional, the `__name__` will be
ordered `"ASCENDING"` (unless explicitly specified otherwise). Structure is documented below.
The `fields` block supports:
* `field_path` -
(Optional)
Name of the field.
* `order` -
(Optional)
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=.
Only one of `order` and `arrayConfig` can be specified.
* `array_config` -
(Optional)
Indicates that this field supports operations on arrayValues. Only one of `order` and `arrayConfig` can
be specified.
- - -
* `database` -
(Optional)
The Firestore database id. Defaults to `"(default)"`.
* `query_scope` -
(Optional)
The scope at which a query is run. Defaults to `"COLLECTION"`.
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `name` -
A server defined name for this index. Format:
`projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}`
## Timeouts
This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
- `create` - Default is 10 minutes.
- `delete` - Default is 10 minutes.
## Import
Index can be imported using any of these accepted formats:
```
$ terraform import google_firestore_index.default {{name}}
```
-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
as an argument so that Terraform uses the correct provider to import your resource.