Call get_vector_index to retrieve the configuration and status of a named vector index in an OSS bucket. Use this call to inspect index settings before running queries, or to verify that an index was created with the expected configuration.
Permissions
An Alibaba Cloud account has all permissions by default. RAM users and RAM roles have no permissions by default. Grant permissions using a RAM policy or a bucket policy.
| API | Action | Description |
|---|---|---|
| GetVectorIndex | oss:GetVectorIndex | Gets information about a vector index. |
Method signature
get_vector_index(request: GetVectorIndexRequest, **kwargs) → GetVectorIndexResultRequest parameters
| Parameter | Type | Description |
|---|---|---|
request | GetVectorIndexRequest | The bucket name and index name to query. See GetVectorIndexRequest for all fields. |
Return value
Returns a GetVectorIndexResult object containing the detailed information about the vector index. For the full field reference, see GetVectorIndexResult.
For the complete method definition, see get_vector_index.
Sample code
The sample loads credentials from environment variables and calls get_vector_index with the bucket name and index name.
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector get vector index sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')
parser.add_argument('--index_name', help='The name of the vector index.', required=True)
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Use the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.get_vector_index(oss_vectors.models.GetVectorIndexRequest(
bucket=args.bucket,
index_name=args.index_name,
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if result.index:
print(f'index name: {result.index}')
if __name__ == "__main__":
main()For the complete sample, see get_vector_index.py.