I have a question about automatic schema update (I...
# community-help
c
I have a question about automatic schema update (I use firebase backfill). When indexing documents with a map-type field (in my case, "ingredients") that contains dynamic keys (like ingredients.id123), Typesense automatically adds these dynamic keys to the schema, here's an example of what I see on the collection settings after adding a new document:
Copy code
...
   {
      "facet": false,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "ingredients.food_bsemte8amo4tc3a5t84zobk0ms09.quantity",
      "optional": true,
      "sort": true,
      "stem": false,
      "store": true,
      "type": "int64"
    },
   ...
I want to prevent this behavior because the keys will constantly change and I only want to index the predefined structure. Is it even possible to prevent this from happening?
j
Instead of using
object
as the data type, you can specify certain subfields to be indexed by using dot notation, and specifying a native data type like
string
or
int32
for them. Eg:
{"name": "address.zip", "type": "string"}
c
Thanks @Jason Bosco, the challenge is that the subfields are always different because they are ids, and I have more than 500 possible ids I'll use 😅
j
You might have to restructure the data a bit into a new collection before you sync that over to Typesense for search purposes. Field names with dynamic IDs will make them hard to search through