TLDR Ivy wanted to define a list of strings in a list of objects, and Jason suggested omitting the explicit field type for "products.ingredients". The schema generated the desired field type.
Interesting! Could you try this and see what happens: ```{ "name": "products.ingredients", "type": "string[]" }```
Hang on
Let’s try something else
Could you use this schema: ```{ "enable_nested_fields": true, "name": "store", "fields": [ { "name": "products", "type": "object[]" }, ] }``` then index one of your documents and then look at the updated collection schema which Typesense generates and check the field type for `products.ingredients`?
Ok it looks like it's string[]! Interesting. Thank you! ``` { "facet": false, "index": true, "infix": false, "locale": "", "name": "products.ingredients", "optional": true, "sort": false, "type": "string[]" },``` ```[ { "id": "123", "ingredients": [ "Tomatoes", "Garlic" ], "name": "pizza" } ]```
Btw, on a side note, the most generic field definition takes precedence in the collection schema. So if you have both `products` and `products.ingredients` explicitly listed, then products will take precedence and index all nested fields
Ah ok that makes sense and clarifies things, thank you!
Ivy
Tue, 09 May 2023 21:20:55 UTCHi all, I have a question about nested objects! I'd like to have a schema like this: ```{ storeName: "Best Slice Shop" products: [{ id: 123, name: pizza, ingredients: ["Tomatoes", "Garlic", ... ] } ]``` But it looks like I can only define types on one layer deep (ref), e.g.
```{
"enable_nested_fields": true,
"name": "store",
"fields": [
{
"name": "products",
"type": "object[]"
},
{
"name": "products.id",
"type": "int[]"
},
{
"name": "products.name",
"type": "string[]"
},
{
"name": "products.ingredients",
"type": "string[][]" <-- doesn't work
}
]
}```
Is there a way to define a field to be list of strings on an list of objects field?
Thank you!!