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