xref: /aosp_15_r20/external/googleapis/google/firestore/admin/v1beta2/index.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2019 Google LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16syntax = "proto3";
17
18package google.firestore.admin.v1beta2;
19
20import "google/api/annotations.proto";
21
22option csharp_namespace = "Google.Cloud.Firestore.Admin.V1Beta2";
23option go_package = "cloud.google.com/go/firestore/admin/apiv1beta2/adminpb;adminpb";
24option java_multiple_files = true;
25option java_outer_classname = "IndexProto";
26option java_package = "com.google.firestore.admin.v1beta2";
27option objc_class_prefix = "GCFS";
28
29// Cloud Firestore indexes enable simple and complex queries against
30// documents in a database.
31message Index {
32  // A field in an index.
33  // The field_path describes which field is indexed, the value_mode describes
34  // how the field value is indexed.
35  message IndexField {
36    // The supported orderings.
37    enum Order {
38      // The ordering is unspecified. Not a valid option.
39      ORDER_UNSPECIFIED = 0;
40
41      // The field is ordered by ascending field value.
42      ASCENDING = 1;
43
44      // The field is ordered by descending field value.
45      DESCENDING = 2;
46    }
47
48    // The supported array value configurations.
49    enum ArrayConfig {
50      // The index does not support additional array queries.
51      ARRAY_CONFIG_UNSPECIFIED = 0;
52
53      // The index supports array containment queries.
54      CONTAINS = 1;
55    }
56
57    // Can be __name__.
58    // For single field indexes, this must match the name of the field or may
59    // be omitted.
60    string field_path = 1;
61
62    // How the field value is indexed.
63    oneof value_mode {
64      // Indicates that this field supports ordering by the specified order or
65      // comparing using =, <, <=, >, >=.
66      Order order = 2;
67
68      // Indicates that this field supports operations on `array_value`s.
69      ArrayConfig array_config = 3;
70    }
71  }
72
73  // Query Scope defines the scope at which a query is run. This is specified on
74  // a StructuredQuery's `from` field.
75  enum QueryScope {
76    // The query scope is unspecified. Not a valid option.
77    QUERY_SCOPE_UNSPECIFIED = 0;
78
79    // Indexes with a collection query scope specified allow queries
80    // against a collection that is the child of a specific document, specified
81    // at query time, and that has the collection id specified by the index.
82    COLLECTION = 1;
83
84    // Indexes with a collection group query scope specified allow queries
85    // against all collections that has the collection id specified by the
86    // index.
87    COLLECTION_GROUP = 2;
88  }
89
90  // The state of an index. During index creation, an index will be in the
91  // `CREATING` state. If the index is created successfully, it will transition
92  // to the `READY` state. If the index creation encounters a problem, the index
93  // will transition to the `NEEDS_REPAIR` state.
94  enum State {
95    // The state is unspecified.
96    STATE_UNSPECIFIED = 0;
97
98    // The index is being created.
99    // There is an active long-running operation for the index.
100    // The index is updated when writing a document.
101    // Some index data may exist.
102    CREATING = 1;
103
104    // The index is ready to be used.
105    // The index is updated when writing a document.
106    // The index is fully populated from all stored documents it applies to.
107    READY = 2;
108
109    // The index was being created, but something went wrong.
110    // There is no active long-running operation for the index,
111    // and the most recently finished long-running operation failed.
112    // The index is not updated when writing a document.
113    // Some index data may exist.
114    // Use the google.longrunning.Operations API to determine why the operation
115    // that last attempted to create this index failed, then re-create the
116    // index.
117    NEEDS_REPAIR = 3;
118  }
119
120  // Output only. A server defined name for this index.
121  // The form of this name for composite indexes will be:
122  // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
123  // For single field indexes, this field will be empty.
124  string name = 1;
125
126  // Indexes with a collection query scope specified allow queries
127  // against a collection that is the child of a specific document, specified at
128  // query time, and that has the same collection id.
129  //
130  // Indexes with a collection group query scope specified allow queries against
131  // all collections descended from a specific document, specified at query
132  // time, and that have the same collection id as this index.
133  QueryScope query_scope = 2;
134
135  // The fields supported by this index.
136  //
137  // For composite indexes, this is always 2 or more fields.
138  // The last field entry is always for the field path `__name__`. If, on
139  // creation, `__name__` was not specified as the last field, it will be added
140  // automatically with the same direction as that of the last field defined. If
141  // the final field in a composite index is not directional, the `__name__`
142  // will be ordered ASCENDING (unless explicitly specified).
143  //
144  // For single field indexes, this will always be exactly one entry with a
145  // field path equal to the field path of the associated field.
146  repeated IndexField fields = 3;
147
148  // Output only. The serving state of the index.
149  State state = 4;
150}
151