Google Cloud Vector Search V1 Client - Class VectorSearchServiceClient (0.2.0)

Reference documentation and code samples for the Google Cloud Vector Search V1 Client class VectorSearchServiceClient.

Service Description: VectorSearchService provides methods for managing Collection resources, and Collection Index resources. The primary resources offered by this service are Collections which are a container for a set of related JSON data objects, and Collection Indexes which enable efficient ANN search across data objects within a Collection.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ VectorSearch \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials FetchAuthTokenInterface|CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\VectorSearch\V1\VectorSearchServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new VectorSearchServiceClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

createCollection

Creates a new Collection in a given project and location.

The async variant is VectorSearchServiceClient::createCollectionAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\CreateCollectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<Google\Cloud\VectorSearch\V1\Collection>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\Collection;
use Google\Cloud\VectorSearch\V1\CreateCollectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Value for parent. Please see
 *                                {@see VectorSearchServiceClient::locationName()} for help formatting this field.
 * @param string $collectionId    ID of the Collection to create.
 *                                The id must be 1-63 characters long, and comply with
 *                                [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
 *                                Specifically, it must be 1-63 characters long and match the regular
 *                                expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`.
 */
function create_collection_sample(string $formattedParent, string $collectionId): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $collection = new Collection();
    $request = (new CreateCollectionRequest())
        ->setParent($formattedParent)
        ->setCollectionId($collectionId)
        ->setCollection($collection);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->createCollection($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Collection $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = VectorSearchServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $collectionId = '[COLLECTION_ID]';

    create_collection_sample($formattedParent, $collectionId);
}

createIndex

Creates a new Index in a given project and location.

The async variant is VectorSearchServiceClient::createIndexAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\CreateIndexRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<Google\Cloud\VectorSearch\V1\Index>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\CreateIndexRequest;
use Google\Cloud\VectorSearch\V1\Index;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The resource name of the Collection for which to create the
 *                                Index. Format:
 *                                `projects/{project}/locations/{location}/collections/{collection}`
 *                                Please see {@see VectorSearchServiceClient::collectionName()} for help formatting this field.
 * @param string $indexId         ID of the Index to create.
 *                                The id must be 1-63 characters long, and comply with
 *                                [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
 *                                Specifically, it must be 1-63 characters long and match the regular
 *                                expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`.
 * @param string $indexIndexField The collection schema field to index.
 */
function create_index_sample(
    string $formattedParent,
    string $indexId,
    string $indexIndexField
): void {
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $index = (new Index())
        ->setIndexField($indexIndexField);
    $request = (new CreateIndexRequest())
        ->setParent($formattedParent)
        ->setIndexId($indexId)
        ->setIndex($index);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->createIndex($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Index $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = VectorSearchServiceClient::collectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]'
    );
    $indexId = '[INDEX_ID]';
    $indexIndexField = '[INDEX_FIELD]';

    create_index_sample($formattedParent, $indexId, $indexIndexField);
}

deleteCollection

Deletes a single Collection.

The async variant is VectorSearchServiceClient::deleteCollectionAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\DeleteCollectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\DeleteCollectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see VectorSearchServiceClient::collectionName()} for help formatting this field.
 */
function delete_collection_sample(string $formattedName): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new DeleteCollectionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->deleteCollection($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = VectorSearchServiceClient::collectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]'
    );

    delete_collection_sample($formattedName);
}

deleteIndex

Deletes a single Index.

The async variant is VectorSearchServiceClient::deleteIndexAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\DeleteIndexRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\DeleteIndexRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the Index to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/collections/{collection}/indexes/{index}`
 *                              Please see {@see VectorSearchServiceClient::indexName()} for help formatting this field.
 */
function delete_index_sample(string $formattedName): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new DeleteIndexRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->deleteIndex($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = VectorSearchServiceClient::indexName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]',
        '[INDEX]'
    );

    delete_index_sample($formattedName);
}

getCollection

Gets details of a single Collection.

The async variant is VectorSearchServiceClient::getCollectionAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\GetCollectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\VectorSearch\V1\Collection
Example
use Google\ApiCore\ApiException;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\Collection;
use Google\Cloud\VectorSearch\V1\GetCollectionRequest;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see VectorSearchServiceClient::collectionName()} for help formatting this field.
 */
function get_collection_sample(string $formattedName): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new GetCollectionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Collection $response */
        $response = $vectorSearchServiceClient->getCollection($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = VectorSearchServiceClient::collectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]'
    );

    get_collection_sample($formattedName);
}

getIndex

Gets details of a single Index.

The async variant is VectorSearchServiceClient::getIndexAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\GetIndexRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\VectorSearch\V1\Index
Example
use Google\ApiCore\ApiException;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\GetIndexRequest;
use Google\Cloud\VectorSearch\V1\Index;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see VectorSearchServiceClient::indexName()} for help formatting this field.
 */
function get_index_sample(string $formattedName): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new GetIndexRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Index $response */
        $response = $vectorSearchServiceClient->getIndex($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = VectorSearchServiceClient::indexName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]',
        '[INDEX]'
    );

    get_index_sample($formattedName);
}

importDataObjects

Initiates a Long-Running Operation to import DataObjects into a Collection.

The async variant is VectorSearchServiceClient::importDataObjectsAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ImportDataObjectsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<Google\Cloud\VectorSearch\V1\ImportDataObjectsResponse>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\ImportDataObjectsRequest;
use Google\Cloud\VectorSearch\V1\ImportDataObjectsResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the Collection to import DataObjects into.
 *                              Format: `projects/{project}/locations/{location}/collections/{collection}`. Please see
 *                              {@see VectorSearchServiceClient::collectionName()} for help formatting this field.
 */
function import_data_objects_sample(string $formattedName): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new ImportDataObjectsRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->importDataObjects($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ImportDataObjectsResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = VectorSearchServiceClient::collectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]'
    );

    import_data_objects_sample($formattedName);
}

listCollections

Lists Collections in a given project and location.

The async variant is VectorSearchServiceClient::listCollectionsAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ListCollectionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\Collection;
use Google\Cloud\VectorSearch\V1\ListCollectionsRequest;

/**
 * @param string $formattedParent Parent value for ListCollectionsRequest
 *                                Please see {@see VectorSearchServiceClient::locationName()} for help formatting this field.
 */
function list_collections_sample(string $formattedParent): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new ListCollectionsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $vectorSearchServiceClient->listCollections($request);

        /** @var Collection $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = VectorSearchServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_collections_sample($formattedParent);
}

listIndexes

Lists Indexes in a given project and location.

The async variant is VectorSearchServiceClient::listIndexesAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ListIndexesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\Index;
use Google\Cloud\VectorSearch\V1\ListIndexesRequest;

/**
 * @param string $formattedParent Parent value for ListIndexesRequest
 *                                Please see {@see VectorSearchServiceClient::collectionName()} for help formatting this field.
 */
function list_indexes_sample(string $formattedParent): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = (new ListIndexesRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $vectorSearchServiceClient->listIndexes($request);

        /** @var Index $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = VectorSearchServiceClient::collectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[COLLECTION]'
    );

    list_indexes_sample($formattedParent);
}

updateCollection

Updates the parameters of a single Collection.

The async variant is VectorSearchServiceClient::updateCollectionAsync() .

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\UpdateCollectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse<Google\Cloud\VectorSearch\V1\Collection>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;
use Google\Cloud\VectorSearch\V1\Collection;
use Google\Cloud\VectorSearch\V1\UpdateCollectionRequest;
use Google\Rpc\Status;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_collection_sample(): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $collection = new Collection();
    $request = (new UpdateCollectionRequest())
        ->setCollection($collection);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $vectorSearchServiceClient->updateCollection($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Collection $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

getLocation

Gets information about a location.

The async variant is VectorSearchServiceClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function get_location_sample(): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $vectorSearchServiceClient->getLocation($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

listLocations

Lists information about the supported locations for this service.

This method can be called in two ways:

List all public locations: Use the path GET /v1/locations. List project-visible locations: Use the path GET /v1/projects/{project_id}/locations. This may include public locations as well as private or other locations specifically visible to the project.

The async variant is VectorSearchServiceClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\VectorSearch\V1\Client\VectorSearchServiceClient;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_locations_sample(): void
{
    // Create a client.
    $vectorSearchServiceClient = new VectorSearchServiceClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $vectorSearchServiceClient->listLocations($request);

        /** @var Location $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

createCollectionAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\CreateCollectionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

createIndexAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\CreateIndexRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteCollectionAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\DeleteCollectionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteIndexAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\DeleteIndexRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getCollectionAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\GetCollectionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\VectorSearch\V1\Collection>

getIndexAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\GetIndexRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\VectorSearch\V1\Index>

importDataObjectsAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ImportDataObjectsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

listCollectionsAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ListCollectionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listIndexesAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\ListIndexesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateCollectionAsync

Parameters
Name Description
request Google\Cloud\VectorSearch\V1\UpdateCollectionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::collectionName

Formats a string containing the fully-qualified path to represent a collection resource.

Parameters
Name Description
project string
location string
collection string
Returns
Type Description
string The formatted collection resource.

static::indexName

Formats a string containing the fully-qualified path to represent a index resource.

Parameters
Name Description
project string
location string
collection string
index string
Returns
Type Description
string The formatted index resource.

static::locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • collection: projects/{project}/locations/{location}/collections/{collection}
  • index: projects/{project}/locations/{location}/collections/{collection}/indexes/{index}
  • location: projects/{project}/locations/{location}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template ?string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.