1// Copyright 2023 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
15syntax = "proto3";
16
17package google.cloud.aiplatform.v1beta1;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/aiplatform/v1beta1/deployed_index_ref.proto";
22import "google/protobuf/struct.proto";
23import "google/protobuf/timestamp.proto";
24
25option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1";
26option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb";
27option java_multiple_files = true;
28option java_outer_classname = "IndexProto";
29option java_package = "com.google.cloud.aiplatform.v1beta1";
30option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1";
31option ruby_package = "Google::Cloud::AIPlatform::V1beta1";
32
33// A representation of a collection of database items organized in a way that
34// allows for approximate nearest neighbor (a.k.a ANN) algorithms search.
35message Index {
36  option (google.api.resource) = {
37    type: "aiplatform.googleapis.com/Index"
38    pattern: "projects/{project}/locations/{location}/indexes/{index}"
39  };
40
41  // The update method of an Index.
42  enum IndexUpdateMethod {
43    // Should not be used.
44    INDEX_UPDATE_METHOD_UNSPECIFIED = 0;
45
46    // BatchUpdate: user can call UpdateIndex with files on Cloud Storage of
47    // datapoints to update.
48    BATCH_UPDATE = 1;
49
50    // StreamUpdate: user can call UpsertDatapoints/DeleteDatapoints to update
51    // the Index and the updates will be applied in corresponding
52    // DeployedIndexes in nearly real-time.
53    STREAM_UPDATE = 2;
54  }
55
56  // Output only. The resource name of the Index.
57  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
58
59  // Required. The display name of the Index.
60  // The name can be up to 128 characters long and can consist of any UTF-8
61  // characters.
62  string display_name = 2 [(google.api.field_behavior) = REQUIRED];
63
64  // The description of the Index.
65  string description = 3;
66
67  // Immutable. Points to a YAML file stored on Google Cloud Storage describing
68  // additional information about the Index, that is specific to it. Unset if
69  // the Index does not have any additional information. The schema is defined
70  // as an OpenAPI 3.0.2 [Schema
71  // Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#schemaObject).
72  // Note: The URI given on output will be immutable and probably different,
73  // including the URI scheme, than the one given on input. The output URI will
74  // point to a location where the user only has a read access.
75  string metadata_schema_uri = 4 [(google.api.field_behavior) = IMMUTABLE];
76
77  // An additional information about the Index; the schema of the metadata can
78  // be found in
79  // [metadata_schema][google.cloud.aiplatform.v1beta1.Index.metadata_schema_uri].
80  google.protobuf.Value metadata = 6;
81
82  // Output only. The pointers to DeployedIndexes created from this Index.
83  // An Index can be only deleted if all its DeployedIndexes had been undeployed
84  // first.
85  repeated DeployedIndexRef deployed_indexes = 7
86      [(google.api.field_behavior) = OUTPUT_ONLY];
87
88  // Used to perform consistent read-modify-write updates. If not set, a blind
89  // "overwrite" update happens.
90  string etag = 8;
91
92  // The labels with user-defined metadata to organize your Indexes.
93  //
94  // Label keys and values can be no longer than 64 characters
95  // (Unicode codepoints), can only contain lowercase letters, numeric
96  // characters, underscores and dashes. International characters are allowed.
97  //
98  // See https://goo.gl/xmQnxf for more information and examples of labels.
99  map<string, string> labels = 9;
100
101  // Output only. Timestamp when this Index was created.
102  google.protobuf.Timestamp create_time = 10
103      [(google.api.field_behavior) = OUTPUT_ONLY];
104
105  // Output only. Timestamp when this Index was most recently updated.
106  // This also includes any update to the contents of the Index.
107  // Note that Operations working on this Index may have their
108  // [Operations.metadata.generic_metadata.update_time]
109  // [google.cloud.aiplatform.v1beta1.GenericOperationMetadata.update_time] a
110  // little after the value of this timestamp, yet that does not mean their
111  // results are not already reflected in the Index. Result of any successfully
112  // completed Operation on the Index is reflected in it.
113  google.protobuf.Timestamp update_time = 11
114      [(google.api.field_behavior) = OUTPUT_ONLY];
115
116  // Output only. Stats of the index resource.
117  IndexStats index_stats = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
118
119  // Immutable. The update method to use with this Index. If not set,
120  // BATCH_UPDATE will be used by default.
121  IndexUpdateMethod index_update_method = 16
122      [(google.api.field_behavior) = IMMUTABLE];
123}
124
125// A datapoint of Index.
126message IndexDatapoint {
127  // Restriction of a datapoint which describe its attributes(tokens) from each
128  // of several attribute categories(namespaces).
129  message Restriction {
130    // The namespace of this restriction. eg: color.
131    string namespace = 1;
132
133    // The attributes to allow in this namespace. eg: 'red'
134    repeated string allow_list = 2;
135
136    // The attributes to deny in this namespace. eg: 'blue'
137    repeated string deny_list = 3;
138  }
139
140  // Crowding tag is a constraint on a neighbor list produced by nearest
141  // neighbor search requiring that no more than some value k' of the k
142  // neighbors returned have the same value of crowding_attribute.
143  message CrowdingTag {
144    // The attribute value used for crowding.  The maximum number of neighbors
145    // to return per crowding attribute value
146    // (per_crowding_attribute_num_neighbors) is configured per-query. This
147    // field is ignored if per_crowding_attribute_num_neighbors is larger than
148    // the total number of neighbors to return for a given query.
149    string crowding_attribute = 1;
150  }
151
152  // Required. Unique identifier of the datapoint.
153  string datapoint_id = 1 [(google.api.field_behavior) = REQUIRED];
154
155  // Required. Feature embedding vector. An array of numbers with the length of
156  // [NearestNeighborSearchConfig.dimensions].
157  repeated float feature_vector = 2 [(google.api.field_behavior) = REQUIRED];
158
159  // Optional. List of Restrict of the datapoint, used to perform "restricted
160  // searches" where boolean rule are used to filter the subset of the database
161  // eligible for matching. See:
162  // https://cloud.google.com/vertex-ai/docs/matching-engine/filtering
163  repeated Restriction restricts = 4 [(google.api.field_behavior) = OPTIONAL];
164
165  // Optional. CrowdingTag of the datapoint, the number of neighbors to return
166  // in each crowding can be configured during query.
167  CrowdingTag crowding_tag = 5 [(google.api.field_behavior) = OPTIONAL];
168}
169
170// Stats of the Index.
171message IndexStats {
172  // Output only. The number of vectors in the Index.
173  int64 vectors_count = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
174
175  // Output only. The number of shards in the Index.
176  int32 shards_count = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
177}
178