Invalid json syntax, expected json object but was json primitive

82 Views Asked by At

When creating an index in Google Vector Search platform the index creation failed with this error:

 embeddingId: EMBEDDING_ID_NOT_APPLICABLE
        errorMessage: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive;
          at path $
        errorType: INVALID_JSON_SYNTAX
        rawRecord: '    -0.0223593935, 0.0273346137, -0.0281442013, -0.00227753539,
          0.0143363187,'

This is how my .json file looks like:

{
  "id": "1",
  "embedding": [
    -0.0320996083, 0.0598638132, -0.000723437872, 0.0202979278, -0.00374370185,
    0.020754844, -0.028198, -0.00302006351, -0.00580240414, 0.0216173287,
    0.0225891396, 0.00469718548, 0.0182211958, 0.0842230618, -0.0173235275,
    ........................(has about 286 more lines)...................
    0.00816405565, 0.0117803486, -0.0233089756, -0.00427557155, -0.00267161848,
    -0.00266683474, 0.00760478387, 0.0102972658, -0.00593171781, 0.00593384868,
    0.0122984545
  ]
}

this is my metadata:

{
  "contentsDeltaUri": "gs://match-it-fast-us-central1/gdelt_gsg/index-1",
  "config": {
    "dimensions": 512,
    "approximateNeighborsCount": 150,
    "distanceMeasureType": "COSINE_DISTANCE",
    "algorithm_config": {
      "treeAhConfig": {
        "leafNodeEmbeddingCount": 1000,
        "leafNodesToSearchPercent": 5
      }
    }
  }
}

i successfully uploaded the json file into my google cloud bucket using this code block:

gsutil cp ./embeddings/testembedding.json gs://match-it-fast-us-central1/gdelt_gsg/index-1/ 

and created index with this block of code successfully:

gcloud --project=myproject ai indexes create --display-name=demo-image-index --description="Image Demo" --metadata-file=metadata/gdelt_gsg_index_metadata.json --region=us-central1

The index can be seen on vector search index list and the status shows creating and returns with a failed response: here is the error image of failed creation

0

There are 0 best solutions below