Registry /
gcp / google-cloud-vectorsearch
Install & Compatibility
Where this runs
tested against v0.11.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.904s · 73.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 5.6s · import 1.348s · 71MB
72MB installed
● package 72MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
VectorSearchServiceClient
✓ from google.cloud.vectorsearch import VectorSearchServiceClient
✗ from google.cloud import vectorsearch
This quickstart demonstrates how to instantiate the `VectorSearchServiceClient` and perform a basic vector similarity search (`match`). It assumes you have an existing Vector Search index endpoint with a deployed index. Remember to set the environment variables or replace the placeholder strings for `project_id`, `location`, `index_endpoint_id`, and `deployed_index_id`.
import os
from google.cloud import vectorsearch
# Set your GCP Project ID and Location
project_id = os.environ.get("GCP_PROJECT_ID", "your-gcp-project-id")
location = os.environ.get("GCP_REGION", "us-central1") # e.g., 'us-central1'
# Set your Vector Search Index Endpoint ID and Deployed Index ID
# These must point to an existing, deployed index endpoint in your project.
index_endpoint_id = os.environ.get("VECTORSEARCH_INDEX_ENDPOINT_ID", "your-index-endpoint-id")
deployed_index_id = os.environ.get("VECTORSEARCH_DEPLOYED_INDEX_ID", "your-deployed-index-id")
# Initialize the client
try:
client = vectorsearch.VectorSearchServiceClient()
index_endpoint_name = client.index_endpoint_path(
project=project_id, location=location, index_endpoint=index_endpoint_id
)
# Define a query vector (replace with your actual embedding)
# The dimension must match the index's dimension. Example for 1536 dimensions:
query_vector = [0.1] * 1536 # Placeholder: adjust dimensions as needed
num_neighbors = 5
# Perform a vector search (match)
print(f"Searching for {num_neighbors} neighbors in index endpoint: {index_endpoint_name}...")
response = client.match(
index_endpoint=index_endpoint_name,
deployed_index_id=deployed_index_id,
queries=[
vectorsearch.MatchQuery(
vector=query_vector,
# Optional: Add filters if your index supports them
# restrict_filters=[vectorsearch.RestrictFilter(namespace="color", allow_tokens=["red"])],
# numeric_filters=[vectorsearch.NumericFilter(value_int=vectorsearch.IntFilter(value=10), field_name="price")],
)
],
# Optional: Set to True to retrieve full datapoint metadata
# return_full_datapoint=True
)
if response.results:
print(f"Found {len(response.results[0].matches)} matches for the first query:")
for match in response.results[0].matches:
print(f" ID: {match.id}, Distance: {match.distance:.4f}")
if match.datapoint:
print(f" Datapoint ID: {match.datapoint.datapoint_id}")
# Access other datapoint fields like match.datapoint.metadata, match.datapoint.restricts, etc.
else:
print("No results found. Check your query, index, and endpoint configuration.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure you have authenticated to GCP (e.g., `gcloud auth application-default login`),")
print("your project, location, index endpoint, and deployed index IDs are correct, and the index is deployed.")
Upgrade
Version history
0.11.2latest on PyPI · released Aug 25, 2026
Audit
Dependencies
No dependency data recorded yet.