Hello :slightly_smiling_face: Is it possible to fa...
# community-help
g
Hello 🙂 Is it possible to facet the field of an object? I tried to define the facet of
thematics.label
, but since I provide the whole object and not the index, it does not seem to be properly indexed. I have done a similar thing on another object, where instead of being optional, the field is mandatory, and typesense did not accept the data, complaining that
<field>.label
is missing. this is the company I have:
Copy code
{
  name: "companies",
  fields: [
    {
      name: "id",
      type: "string",
      index: false,
    },
    {
      name: "name",
      type: "string",
      infix: true,
      stem: true,
    },
    {
      name: "logo_id",
      type: "string",
      optional: true,
      index: false,
    },
    {
      name: "thematics.label",
      type: "string[]",
      facet: true,
      optional: true,
    },
    {
      name: "segments.label",
      type: "string[]",
      facet: true,
      optional: true,
    },
    {
      name: "location",
      type: "string",
      facet: true,
      optional: true,
    },
    {
      name: "ownership",
      type: "string",
      facet: true,
      optional: true,
    },
    {
      name: "restricted_users",
      type: "string[]",
      optional: true,
    },
  ],
  enable_nested_fields: false,
}
And a payload example:
Copy code
[
  {
    "id": "019685f4-cabb-a16e-c35d-c61f153767bf",
    "name": "Atlantica Digital",
    "logo_id": "companies/rec3SnmvjJJRERSIw",
    "thematics": [{"id": 1330, "type": "THEMATIC_V2", "label": "Professional & IT services", "order": "c0AW"}, {"id": 1333, "type": "THEMATIC_V2", "label": "Niche Verticals", "order": "c0AZ"}, {"id": 1338, "type": "THEMATIC_V2", "label": "Cybersecurity", "order": "c0Ae"}],
    "segments": [{"id": 1461, "type": "SEGMENT_V2", "label": "System Integrator", "order": "c0B0"}, {"id": 1487, "type": "SEGMENT_V2", "label": "Telecommunication", "order": "c0BQ"}],
    "location": "Italy",
    "ownership": "PE Owned",
    "restricted_users": null
  }
]
f
Hey there,
enable_nested_fields
has to be set to true in order to have a nested object structure
g
Really stupid error … Thank you Fanis ! 🙂