#community-help

JSON Error with Empty Arrays in Embedded Field

TLDR Gustavo reported an issue with Typesense returning an error for empty array fields in an embedded field. Jason acknowledged the issue but no solution was provided.

Powered by Struct AI

2

Jun 13, 2023 (3 months ago)
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
10:10 PM
Jason Confirming another issue I mentioned previously: I have a collection with an embedding field that uses 2 array fields in from. When I create a document where both arrays are empty, Typesense returns an error saying Unexpected token in JSON at position 14.
10:11
Gustavo
10:11 PM
I'm using the JS SDK and this is the logged error.
Image 1 for I'm using the JS SDK and this is the logged error.
10:12
Gustavo
10:12 PM
These are the relevant fields from the collection schema:
    {
      "facet": false,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "segments",
      "optional": false,
      "sort": false,
      "type": "string[]"
    },
    {
      "facet": false,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "topics",
      "optional": false,
      "sort": false,
      "type": "string[]"
    },
    {
      "embed": {
        "from": [
          "segments",
          "topics"
        ],
        "model_config": {
          "api_key": "sk-************************************************",
          "model_name": "openai/text-embedding-ada-002"
        }
      },
      "facet": false,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "embedding",
      "num_dim": 1536,
      "optional": false,
      "sort": false,
      "type": "float[]"
    },
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:12 PM
Got it, thank you for reporting this

1

Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
10:13 PM
To reproduce, try to create a document with { segments: [], topics: [] }.

1