#community-help

Creating a Collection in Typesense Cloud with Firebase Extension

TLDR Lukas asked about creating collections in Typesense with objects, which Kishore Nallan informed is not supported. Kishore Nallan suggested flattening the fields and reassured that an array of strings can be used for tagging purposes.

Powered by Struct AI
7
28mo
Solved
Join the chat
Jul 28, 2021 (28 months ago)
Lukas
Photo of md5-d9deaf8d1683beb47108307453fe58bc
Lukas
10:59 AM
Hey all,

I'm trying to create a collection in typesense cloud with firebase extension. Just wanted to know are objects not supported?

calories = {
  calories: 200,
  protein: 30,
  carbs: 10
}
Request failed with HTTP code 400 | Server said: Type of field `calories` is invalid.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:59 AM
Yes, Typesense does not support indexing nested objects yet.
11:00
Kishore Nallan
11:00 AM
The fields need to be "flattened" out.
Lukas
Photo of md5-d9deaf8d1683beb47108307453fe58bc
Lukas
11:01 AM
Yeah, I've seen once it's flattened it works.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:06 AM
We've a feature request open for it here (https://github.com/typesense/typesense/issues/227). It's a bit of an involved change, but we certainly think it is a good feature to support in future.
Lukas
Photo of md5-d9deaf8d1683beb47108307453fe58bc
Lukas
11:31 AM
Thanks for that! Just a quick one, so let's say I want to implement tags for searching.
Would I have to do it like this: isVegan: true instead of obviously storing in array.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:39 AM
Array of strings is fine. What we don't support is a dictionary. So you can't index a dictionary like person: {name: "foo", age: 20} -- instead you need to have 2 fields "person.name" and "person.age" separately.