Class MatchingEngineIndex (1.15.0)

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

Matching Engine index resource for Vertex AI.

Inheritance

builtins.object > google.cloud.aiplatform.base.VertexAiResourceNoun > builtins.object > google.cloud.aiplatform.base.FutureManager > google.cloud.aiplatform.base.VertexAiResourceNounWithFutureManager > MatchingEngineIndex

Properties

deployed_indexes

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

description

Description of the index.

Methods

MatchingEngineIndex

MatchingEngineIndex(
    index_name: str,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: 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
NameDescription
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: str,
    dimensions: int,
    distance_measure_type: Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.DistanceMeasureType
    ] = None,
    description: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
)

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
NameDescription
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

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://docs.google.com/document/d/12DLVB6Nq6rdv8grxfBsPhUA283KWrQ9ZenPBp0zUC30

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.

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.

encryption_spec str

Optional. Customer-managed encryption key spec for data storage. If set, both of the online and offline data storage will be secured by this key.

create_tree_ah_index

create_tree_ah_index(
    display_name: str,
    contents_delta_uri: str,
    dimensions: int,
    approximate_neighbors_count: int,
    leaf_node_embedding_count: Optional[int] = None,
    leaf_nodes_to_search_percent: Optional[float] = None,
    distance_measure_type: Optional[
        google.cloud.aiplatform.matching_engine.matching_engine_index_config.DistanceMeasureType
    ] = None,
    description: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
)

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
NameDescription
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

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://docs.google.com/document/d/12DLVB6Nq6rdv8grxfBsPhUA283KWrQ9ZenPBp0zUC30

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.

encryption_spec str

Optional. Customer-managed encryption key spec for data storage. If set, both of the online and offline data storage will be secured by this key.

update_embeddings

update_embeddings(
    contents_delta_uri: str,
    is_complete_overwrite: Optional[bool] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
)

Updates the embeddings for this index.

Parameters
NameDescription
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://docs.google.com/document/d/12DLVB6Nq6rdv8grxfBsPhUA283KWrQ9ZenPBp0zUC30

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_metadata

update_metadata(
    display_name: Optional[str] = None,
    description: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
)

Updates the metadata for this index.

Parameters
NameDescription
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.