Hi guys, I want to check on what is the recommende...
# community-help
n
Hi guys, I want to check on what is the recommended strategy for updating an existing collection ? Let's say we want to start faceting a new field in the documents? Deleting and recreating the collection with downtime seems too expensive.
k
👋 As of now there is no way to modify the schema live, though that’s a very important todo item on our list. You can create another collection, index it in the background and use aliases to swap the live traffic over to that: https://typesense.org/docs/0.19.0/api/collection-alias.html#collection-alias
In the upcoming 0.20 release we are introducing automatic schema detection and support for regular expression in field names that will already help you work around this problem. For example you can define a field named
.*_facet
and define that to be facetable. So any field matching that regexp will be automatically added to facet index @Nithin Saji
We already have a RC build for 0.20 that I can share if you are interested.
n
Thanks Kishore, I am interested in trying it out.
k
Here’s the docker image:
typesense/typesense:0.20.0.rc39
Just define a field like this:
{"name": ".*_str_facet", "type": "string", "facet": true}
So any field name ending with
_str_facet
will then be treated as a facetable field automatically. This lays the foundation for us to allow schema updates in future for non-dynamic fields from older versions of Typesense.
n
Thanks, I am already using the rc, will give this a try.
Is it possible to search or facet using nested fields when using auto ?
k
We don’t support indexing and searching on nested fields. You need to flatten all nested fields to top-level fields using a
customer.name
kinda convention and then search on that. Again, this is something that’s on our roadmap to address.