Ai Index
A representation of a collection of database items organized in a way that allows for approximate nearest neighbor (a.k.a ANN) algorithms search. To get more information about Index, see:
Example Usage
Vertex Ai Index
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.vertex.AiIndex;
import com.pulumi.gcp.vertex.AiIndexArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucket = new Bucket("bucket", BucketArgs.builder()
.location("us-central1")
.uniformBucketLevelAccess(true)
.build());
var data = new BucketObject("data", BucketObjectArgs.builder()
.bucket(bucket.name())
.content("""
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
""")
.build());
var index = new AiIndex("index", AiIndexArgs.builder()
.labels(Map.of("foo", "bar"))
.region("us-central1")
.displayName("test-index")
.description("index for test")
.metadata(AiIndexMetadataArgs.builder()
.contentsDeltaUri(bucket.name().applyValue(name -> String.format("gs://%s/contents", name)))
.config(AiIndexMetadataConfigArgs.builder()
.dimensions(2)
.approximateNeighborsCount(150)
.shardSize("SHARD_SIZE_SMALL")
.distanceMeasureType("DOT_PRODUCT_DISTANCE")
.algorithmConfig(AiIndexMetadataConfigAlgorithmConfigArgs.builder()
.treeAhConfig(AiIndexMetadataConfigAlgorithmConfigTreeAhConfigArgs.builder()
.leafNodeEmbeddingCount(500)
.leafNodesToSearchPercent(7)
.build())
.build())
.build())
.build())
.indexUpdateMethod("BATCH_UPDATE")
.build());
}
}
Vertex Ai Index Streaming
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.vertex.AiIndex;
import com.pulumi.gcp.vertex.AiIndexArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigArgs;
import com.pulumi.gcp.vertex.inputs.AiIndexMetadataConfigAlgorithmConfigBruteForceConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucket = new Bucket("bucket", BucketArgs.builder()
.location("us-central1")
.uniformBucketLevelAccess(true)
.build());
var data = new BucketObject("data", BucketObjectArgs.builder()
.bucket(bucket.name())
.content("""
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
""")
.build());
var index = new AiIndex("index", AiIndexArgs.builder()
.labels(Map.of("foo", "bar"))
.region("us-central1")
.displayName("test-index")
.description("index for test")
.metadata(AiIndexMetadataArgs.builder()
.contentsDeltaUri(bucket.name().applyValue(name -> String.format("gs://%s/contents", name)))
.config(AiIndexMetadataConfigArgs.builder()
.dimensions(2)
.shardSize("SHARD_SIZE_LARGE")
.distanceMeasureType("COSINE_DISTANCE")
.featureNormType("UNIT_L2_NORM")
.algorithmConfig(AiIndexMetadataConfigAlgorithmConfigArgs.builder()
.bruteForceConfig()
.build())
.build())
.build())
.indexUpdateMethod("STREAM_UPDATE")
.build());
}
}
Import
Index can be imported using any of these accepted formats
$ pulumi import gcp:vertex/aiIndex:AiIndex default projects/{{project}}/locations/{{region}}/indexes/{{name}}
$ pulumi import gcp:vertex/aiIndex:AiIndex default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:vertex/aiIndex:AiIndex default {{region}}/{{name}}
$ pulumi import gcp:vertex/aiIndex:AiIndex default {{name}}
Properties
The timestamp of when the Index was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
The pointers to DeployedIndexes created from this Index. An Index can be only deleted if all its DeployedIndexes had been undeployed first. Structure is documented below.
The description of the Index.
The display name of the Index. The name can be up to 128 characters long and can consist of any UTF-8 characters.
Stats of the index resource. Structure is documented below.
The update method to use with this Index. The value must be the followings. If not set, BATCH_UPDATE will be used by default.
An additional information about the Index Structure is documented below.
Points to a YAML file stored on Google Cloud Storage describing additional information about the Index, that is specific to it. Unset if the Index does not have any additional information.
The timestamp of when the Index was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.