Class MatchingEngineIndex (1.54.1)

MatchingEngineIndex(
    index_name: str,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
)

Matching Engine index resource for Vertex AI.

Properties

create_time

Time this resource was created.

deployed_indexes

Returns a list of deployed index references that originate from this index.

description

Description of the index.

display_name

Display name of this resource.

encryption_spec

Customer-managed encryption key options for this Vertex AI resource.

If this is set, then all resources created by this Vertex AI resource will be encrypted with the provided encryption key.

gca_resource

The underlying resource proto representation.

labels

User-defined labels containing metadata about this resource.

Read more about labels at https://goo.gl/xmQnxf

name

Name of this resource.

resource_name

Full qualified resource name.

update_time

Time this resource was last updated.

Methods

MatchingEngineIndex

MatchingEngineIndex(
    index_name: str,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
)

Retrieves an existing index given an index name or ID.

Example Usage:

my_index = aiplatform.MatchingEngineIndex(
    index_name='projects/123/locations/us-central1/indexes/my_index_id'
)
or
my_index = aiplatform.MatchingEngineIndex(
    index_name='my_index_id'
)
Parameters
Name Description
index_name str

Required. A fully-qualified index resource name or a index ID. Example: "projects/123/locations/us-central1/indexes/my_index_id" or "my_index_id" when project and location are initialized or passed.

project str

Optional. Project to retrieve index from. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to retrieve index from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to retrieve this Index. Overrides credentials set in aiplatform.init.

create_brute_force_index

create_brute_force_index(
    display_name: str,
    contents_delta_uri: typing.Optional[str] = None,
    dimensions: typing.Optional[int] = None,
    distance_measure_type: typing.Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.DistanceMeasureType
    ] = None,
    feature_norm_type: typing.Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.FeatureNormType
    ] = None,
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    index_update_method: typing.Optional[str] = None,
    encryption_spec_key_name: typing.Optional[str] = None,
    create_request_timeout: typing.Optional[float] = None,
    shard_size: typing.Optional[str] = None,
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Creates a MatchingEngineIndex resource that uses the brute force algorithm.

Example Usage:

my_index = aiplatform.Index.create_brute_force_index(
    display_name="my_display_name",
    contents_delta_uri="gs://my_bucket/embeddings",
    dimensions=1,
    approximate_neighbors_count=150,
    distance_measure_type="SQUARED_L2_DISTANCE",
    description="my description",
    labels={ "label_name": "label_value" },
)
Parameters
Name Description
display_name str

Required. The display name of the Index. The name can be up to 128 characters long and can be consist of any UTF-8 characters.

contents_delta_uri str

Optional. Allows inserting, updating or deleting the contents of the Matching Engine Index. The string must be a valid Google Cloud Storage directory path. If this field is set when calling IndexService.UpdateIndex, then no other Index field can be also updated as part of the same call. The expected structure and format of the files this URI points to is described at https://cloud.google.com/vertex-ai/docs/vector-search/setup/format-structure

dimensions int

Required. The number of dimensions of the input vectors.

distance_measure_type matching_engine_index_config.DistanceMeasureType

Optional. The distance measure used in nearest neighbor search.

feature_norm_type matching_engine_index_config.FeatureNormType

Optional. The feature norm type used in nearest neighbor search.

description str

Optional. The description of the Index.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your Index. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one Index(System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

project str

Optional. Project to create EntityType in. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to create EntityType in. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to create EntityTypes. Overrides credentials set in aiplatform.init.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this creation synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

index_update_method str

Optional. The update method to use with this index. Choose stream_update or batch_update. If not set, batch update will be used by default.

encryption_spec_key_name str

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the index. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this index and all sub-resources of this index will be secured by this key. The key needs to be in the same region as where the index is created.

create_request_timeout float

Optional. The timeout for the request in seconds.

shard_size str

Optional. The size of each shard. Index will get resharded based on specified shard size. During serving, each shard will be served on a separate node and will scale independently. If not set, shard size is default to SHARD_SIZE_MEDIUM. Choose one of the following: SHARD_SIZE_SMALL SHARD_SIZE_MEDIUM SHARD_SIZE_LARGE

create_tree_ah_index

create_tree_ah_index(
    display_name: str,
    contents_delta_uri: typing.Optional[str] = None,
    dimensions: typing.Optional[int] = None,
    approximate_neighbors_count: typing.Optional[int] = None,
    leaf_node_embedding_count: typing.Optional[int] = None,
    leaf_nodes_to_search_percent: typing.Optional[float] = None,
    distance_measure_type: typing.Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.DistanceMeasureType
    ] = None,
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    index_update_method: typing.Optional[str] = None,
    encryption_spec_key_name: typing.Optional[str] = None,
    create_request_timeout: typing.Optional[float] = None,
    shard_size: typing.Optional[str] = None,
    feature_norm_type: typing.Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.FeatureNormType
    ] = None,
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Creates a MatchingEngineIndex resource that uses the tree-AH algorithm.

Example Usage:

my_index = aiplatform.Index.create_tree_ah_index(
    display_name="my_display_name",
    contents_delta_uri="gs://my_bucket/embeddings",
    dimensions=1,
    approximate_neighbors_count=150,
    distance_measure_type="SQUARED_L2_DISTANCE",
    leaf_node_embedding_count=100,
    leaf_nodes_to_search_percent=50,
    description="my description",
    labels={ "label_name": "label_value" },
)
Parameters
Name Description
display_name str

Required. The display name of the Index. The name can be up to 128 characters long and can be consist of any UTF-8 characters.

contents_delta_uri str

Optional. Allows inserting, updating or deleting the contents of the Matching Engine Index. The string must be a valid Google Cloud Storage directory path. If this field is set when calling IndexService.UpdateIndex, then no other Index field can be also updated as part of the same call. The expected structure and format of the files this URI points to is described at https://cloud.google.com/vertex-ai/docs/vector-search/setup/format-structure

dimensions int

Required. The number of dimensions of the input vectors.

approximate_neighbors_count int

Required. The default number of neighbors to find via approximate search before exact reordering is performed. Exact reordering is a procedure where results returned by an approximate search algorithm are reordered via a more expensive distance computation.

leaf_node_embedding_count int

Optional. Number of embeddings on each leaf node. The default value is 1000 if not set.

leaf_nodes_to_search_percent float

Optional. The default percentage of leaf nodes that any query may be searched. Must be in range 1-100, inclusive. The default value is 10 (means 10%) if not set.

distance_measure_type matching_engine_index_config.DistanceMeasureType

Optional. The distance measure used in nearest neighbor search.

description str

Optional. The description of the Index.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your Index. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one Index(System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

project str

Optional. Project to create EntityType in. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to create EntityType in. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to create EntityTypes. Overrides credentials set in aiplatform.init.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this creation synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

index_update_method str

Optional. The update method to use with this index. Choose STREAM_UPDATE or BATCH_UPDATE. If not set, batch update will be used by default.

encryption_spec_key_name str

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the index. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this index and all sub-resources of this index will be secured by this key. The key needs to be in the same region as where the index is created.

create_request_timeout float

Optional. The timeout for the request in seconds.

shard_size str

Optional. The size of each shard. Index will get resharded based on specified shard size. During serving, each shard will be served on a separate node and will scale independently. Choose one of the following: SHARD_SIZE_SMALL SHARD_SIZE_MEDIUM SHARD_SIZE_LARGE

feature_norm_type matching_engine_index_config.FeatureNormType

Optional. The feature norm type used in nearest neighbor search.

delete

delete(sync: bool = True) -> None

Deletes this Vertex AI resource. WARNING: This deletion is permanent.

Parameter
Name Description
sync bool

Whether to execute this deletion synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

list

list(
    filter: typing.Optional[str] = None,
    order_by: typing.Optional[str] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    parent: typing.Optional[str] = None,
) -> typing.List[google.cloud.aiplatform.base.VertexAiResourceNoun]

List all instances of this Vertex AI Resource.

Example Usage:

aiplatform.BatchPredictionJobs.list( filter='state="JOB_STATE_SUCCEEDED" AND display_name="my_job"', )

aiplatform.Model.list(order_by="create_time desc, display_name")

Parameters
Name Description
filter str

Optional. An expression for filtering the results of the request. For field names both snake_case and camelCase are supported.

order_by str

Optional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: display_name, create_time, update_time

project str

Optional. Project to retrieve list from. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to retrieve list from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to retrieve list. Overrides credentials set in aiplatform.init.

parent str

Optional. The parent resource name if any to retrieve list from.

remove_datapoints

remove_datapoints(
    datapoint_ids: typing.Sequence[str],
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Remove datapoints for this index.

Parameter
Name Description
datapoints_ids Sequence[str]

Required. The list of datapoints ids to be deleted.

to_dict

to_dict() -> typing.Dict[str, typing.Any]

Returns the resource proto as a dictionary.

update_embeddings

update_embeddings(
    contents_delta_uri: str,
    is_complete_overwrite: typing.Optional[bool] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    update_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Updates the embeddings for this index.

Parameters
Name Description
contents_delta_uri str

Required. Allows inserting, updating or deleting the contents of the Matching Engine Index. The string must be a valid Google Cloud Storage directory path. If this field is set when calling IndexService.UpdateIndex, then no other Index field can be also updated as part of the same call. The expected structure and format of the files this URI points to is described at https://cloud.google.com/vertex-ai/docs/vector-search/setup/format-structure

is_complete_overwrite bool

Optional. If this field is set together with contentsDeltaUri when calling IndexService.UpdateIndex, then existing content of the Index will be replaced by the data from the contentsDeltaUri.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

update_request_timeout float

Optional. The timeout for the request in seconds.

update_metadata

update_metadata(
    display_name: typing.Optional[str] = None,
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    update_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Updates the metadata for this index.

Parameters
Name Description
display_name str

Optional. The display name of the Index. The name can be up to 128 characters long and can be consist of any UTF-8 characters.

description str

Optional. The description of the Index.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your Indexs. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one Index (System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

update_request_timeout float

Optional. The timeout for the request in seconds.

upsert_datapoints

upsert_datapoints(
    datapoints: typing.Sequence[google.cloud.aiplatform_v1.types.index.IndexDatapoint],
    update_mask: typing.Optional[typing.Sequence[str]] = None,
) -> google.cloud.aiplatform.matching_engine.matching_engine_index.MatchingEngineIndex

Upsert datapoints to this index.

Parameters
Name Description
datapoints Sequence[gca_matching_engine_index.IndexDatapoint]

Required. Datapoints to be upserted to this index.

update_mask Sequence[str]

Optional. Update mask is used to specify the fields to be overwritten in the datapoints by the update. The fields specified in the update_mask are relative to each IndexDatapoint inside datapoints, not the full request. Updatable fields: Use all_restricts to update both restricts and numeric_restricts.

wait

wait()

Helper method that blocks until all futures are complete.