This message was deleted.
# community-help
s
This message was deleted.
j
Switching to an array of objects with a
key
and
value
field instead, meaning we don't end up with a bunch of extra fields. i.e. from:
Copy code
{
  "key1": "value1",
  "key2": "value2"
}
To:
Copy code
[
  { "key": "key1", "value": "value1" },
  { "key": "key2", "value": "value2" }
]
j
It's actually not an extra field... If there the document like this:
Copy code
{
  "field": {
    "nestedA": "valueA",
    "nestedB": "valueB"
  }
}
And say the user searches for
valueA
, then the highlight object, will just replace the leaf matched field from a string value to the highlight object like this:
Copy code
{
  "field": {
    "nestedA": {
      "matched_tokens": [
        "valueA"
      ],
      "snippet": "<mark>valueA</mark>",
      "value": "valueA"
    },
    "nestedB": "valueB"
  }
}
While preserving the rest of the object's structure as is
So
valueA
in the original document became the following object in the highlight:
Copy code
{
  "matched_tokens": [
    "valueA"
  ],
  "snippet": "<mark>valueA</mark>",
  "value": "valueA"
}
So whatever types you've defined for the original document would carry over to the highlight object as well, except for the nested value that matches, which will be transformed to the object structure above
n
I believe this issue is related - https://github.com/typesense/typesense/issues/1081? Is there a way to disable this “auto-schema” generation?
j
It ends up creating additional fields in the schema (at least it appears to have additional fields when I request the collection), that's my concern.
So if I have an object with 1k keys (extreme example I know), I can see 1k extra fields in the schema for the collection.
k
Yes we should not be creating schema for non-indexed object fields. We will address this soon.
But when an object does exist in the schema, the sub-fields have to be recorded for schema validation. This is not a problem even if it runs into 1K fields. I've seen customers with such large discovered fields.
j
Ah sweet - I do have these indexed, but knowing it's not an issue is great - thanks!