In Vector Search 2.0, Collections are used to store related Data Objects. They provide a source of truth that you can query to determine the exact state of the Data Objects they contain.
Collection Schema
When you create a Collection, you must provide the following JSON schemas :
-
A data schema, which provides the user-defined structure of your data.
-
A vector schema that defines and configures the vector fields for your Data Objects.
Together, these are referred to as the Collection Schema .
Creating a Collection
The following example demonstrates how to create a Collection with the ID COLLECTION_ID
, specifying both a data schema and a vector schema.
curl -X POST \
'https://vectorsearch.googleapis.com/v1beta/projects/ PROJECT_ID
/locations/ LOCATION
/collections?collection_id= COLLECTION_ID
' \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H 'Content-Type: application/json' \
-d '{
"data_schema": {
"type": "object",
"properties": {
"year": {
"type": "number"
},
"genre": {
"type": "string"
},
"director": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"vector_schema": {
"plot_embedding": {
"dense_vector": {
"dimensions": 3
}
},
"soundtrack_embedding": {
"dense_vector": {
"dimensions": 5
}
},
"genre_embedding": {
"dense_vector": {
"dimensions": 4
}
},
"sparse_embedding": {
"sparse_vector": {}
}
}
}'
In the example, a request is made with collection_id
set to COLLECTION_ID
and
the following as part of the JSON request body:
-
data_schema- Specifies the Data Object structure. -
vector_schema- Configures and defines the vector fields.
Getting a Collection
The following example demonstrates how to get a reference to an existing
Collection with the ID COLLECTION_ID
.
curl -X GET \
'https://vectorsearch.googleapis.com/v1beta/projects/ PROJECT_ID
/locations/ LOCATION
/collections/ COLLECTION_ID
' \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H 'Content-Type: application/json'
Listing Collections
The following example demonstrates how to retrieve a list of existing Collections.
curl -X GET \
'https://vectorsearch.googleapis.com/v1beta/projects/ PROJECT_ID
/locations/ LOCATION
/collections' \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H 'Content-Type: application/json'
Deleting a Collection
The following example demonstrates how to delete an existing Collection
with the ID COLLECTION_ID
.
curl -X DELETE \
'https://vectorsearch.googleapis.com/v1beta/projects/ PROJECT_ID
/locations/ LOCATION
/collections/ COLLECTION_ID
' \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H 'Content-Type: application/json'
What's next?
-
Learn how to create Data Objects to add to a Collection, or import the data from Cloud Storage .

