Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error creating single-field vector index in Firestore with gcloud CLI

oerha
New Member

I'm trying to create a single-field vector index in my Firestore database using the gcloud command-line interface (alpha) to enable vector search functionality. 

However, I keep getting this error:

ERROR: (gcloud.alpha.firestore.indexes.composite.create) Invalid value for [--field-config]: Composite indexes must be configured with at least 2 fields. For single-field index management, use the commands under gcloud firestore indexes fields.

This is the command I'm running, based on the official documentation and what is returned when I try to query the collection:

gcloud alpha firestore indexes composite create --collection-group=People --query-scope=COLLECTION --field-config field-path="embedding",vector-config='{"dimension":"768", "flat": "{}"}'

I've confirmed that:

  • The embedding field exists in my Firestore documents.
  • I have the necessary permissions to create indexes.
  • I'm using the latest alpha version of the gcloud CLI.

I understand this functionality is still in alpha, but I think the documentation is broken because it uses the composite command to create a single field index.

How can I create a single-field vector index in Firestore using the gcloud C

2 2 646
2 REPLIES 2

Hey, try running the command directly into shell/terminal available at console.cloud.google.com. worked for me.

This seems to work but it is a work-around.