---
title: "Building Composite Indexes for Firestore on Windows"
description: "Troubleshoot creating composite indexes with vector embeddings in Firestore on Windows.  This solution uses a JSON file to define the index, bypassing Powershell JSON escaping issues, and provides the corrected `gcloud` command for successful index creation.  Learn how to create a functional composite index with vector embeddings.\n"
slug: "create-composite-index-on-firestore-on-windows"
created: 2025-01-10T18:46:00Z
updated: 2025-01-10T18:46:00Z
tags:
  - "firestore"
  - "composite-index"
  - "vector-search"
ai_assisted: false
---

The command on the [Firestore docs][1] to create a composite index that includes a vector embedding doesn't work out of the box on Windows. This seems to be related on how escaping JSON works on Powershell. The solution I found to run the command was to create a JSON file with the index definition, like so:

```json
[
    {
        "field-path": "user_id",
        "order": "ASCENDING"
    },
    {
        "field-path": "embedding",
        "vector-config": {
            "dimension": 768,
            "flat": "{}"
        }
    }
]
```

Then, create the index with a command that reads the index details from the file, like this:

```sh
gcloud beta firestore indexes composite create `
    --collection-group=MyCollection `
    --query-scope=COLLECTION `
    --field-config=field-config.json `
    --database=mydatabase
```


[1]: https://firebase.google.com/docs/firestore/vector-search?_gl=1*1bnvvnt*_up*MQ..*_ga*NjY3OTU3OTMuMTczNDk1NzM5OQ..*_ga_CW55HF8NVT*MTczNDk1NzM5OS4xLjAuMTczNDk1NzM5OS4wLjAuMA..#create_a_vector_index