Hey folks, `facet_by` returns a facet that is just...
# community-help
i
Hey folks,
facet_by
returns a facet that is just an empty string for me. E.g.
Copy code
const testSchema = {
  name: 'test',
  enable_nested_fields: true,
  fields: [
    { name: 'id', type: 'string' },
    { name: 'category', type: 'string', facet: true, optional: true },
    ...
  ]
}
Copy code
const testEntries = [
  { id: 1, category: '' },
  { id: 2, category: 'A'},
  ...
]
Now the empty string gets returned as a facet. How can I remove this? Would it just be a matter of setting it to null instead of an empty string initially?
Copy code
{
    "counts": [
        {
            "count": 667,
            "highlighted": "",
            "value": ""
        },
        {
            "count": 191,
            "highlighted": "A",
            "value": "A"
        },
       ...
    ],
    "field_name": "category",
    "stats": {
        "total_values": 9
    }
}
k
Yes, please set string to null during index. The field should also be marked as "optional: true "in the schema to support null values.
i
Cool. Thanks