There is no way to update a collection schema?
# community-help
s
There is no way to update a collection schema?
k
@Stefan Hesse We don't have a way to do that at the moment, but in 0.20 (for which we already have a release candidate available), we support automatic schema detection which might help in some cases (for e.g. if new fields get added, they will get indexed automatically). However, schema update is on our roadmap.
r
is there any workaround for this ? also query_by doesn't work for fields which are not mentioned while creating collection
j
Hi @Rishabh Agrawal For now the work-around is to create a new collection with the new schema and re-index the data. To make this zero-downtime, you want to setup a collection alias and use that alias in your application. So for eg: if you have a set of books, you'd create a collection called
books_<current_timetsamp>_1
. Then create an alias called
books
pointing to this collection. You can then use
books
to perform all indexing and searches. Then when you want to change the schema, you'd create a new collection called
books_<current_timetsamp>_2
, re-index all the data and then update the
books
alias to point to
books_<current_timetsamp>_2
also query_by doesn't work for fields which are not mentioned while creating collection
This is by design. Only fields mentioned in the schema when creating the collection are indexed & searchable fields. All others are just stored on disk and returned with the results. So to be able to use a field in queryBy, it has to be specified in the collection schema
r
okay, thanks for the response, let me try
while creating a new collection is there a way i can define my own field as an id ? for eg. defining studentRollNumber as an id. otherwise typesense will create the id of it's own
j
Unfortunately no, the ID field needs to be called
id
, otherwise Typesense will auto-create it
r
ok