:thread: I'm working on building a collection whic...
# community-help
h
🧵 I'm working on building a collection which has an object type field. Is it possible to define the types in the object as well? I've noticed that whether I flatten or use this syntax, the nested fields defined in schema do not show up until I've added documents to the collection which are objects meeting the schema I've defined. I am trying to understand a couple of things: what is the proper way to give type definition to the object in typesense. I am also trying to understand how to add sorting to the nested objects string fields
"nested" fields declaration seems to work?
Copy code
[
  {
    "operation": "CREATE",
    "resource": "collection",
    "data": {
      "enable_nested_fields": true,
      "name": "admin_deals_initial",
      "fields": [
        {
          "name": "accountManager",
          "type": "object",
          "fields": [
            {
              "name": "id",
              "type": "int32"
            },
            {
              "name": "fullName",
              "type": "string",
              "facet": true,
              "index": true,
              "sort": true
            }
          ]
        },
But the docs indicate this should be the way
Copy code
[
  {
    "operation": "CREATE",
    "resource": "collection",
    "data": {
      "enable_nested_fields": true,
      "name": "admin_deals_initial",
      "fields": [
        {
          "name": "accountManager",
          "type": "object",
        },
        {
           "name": "accountManager.id",
           "type": "int32"
        },
        {
          "name": "accountManager.fullName",
          "type": "string",
          "facet": true,
          "index": true,
          "sort": true
        }
...
I was wrong that nested definition does not work. I was conflating it with document data being of that shape/definition. the "flattened" dot notation is what works in the schema.
j
Dot notation would be the way to define the type for nested fields