#community-help

Guide on Updating Collections in Application Development

TLDR Ajeet requested guidance on updating collections for an application, citing issues like lack of schema validation. Jason suggested using regex for field restriction and confirmed collection alias functionality. CaptainCodeman shared a plan to use version numbers for collections avoiding delays.

Powered by Struct AI
3
20mo
Solved
Join the chat
Jan 31, 2022 (20 months ago)
Ajeet
Photo of md5-5c6d56f557408cb1ba6990a945ae4ebb
Ajeet
02:20 PM
Joshua CaptainCodeman
Hi there - We are building an application where we need to update the collection later on based on requirement, so can you please guide me how does collection updating works.
1. I have tried auto schema, it does add dynamic field but it will add any fields in collection, there is no schema validation over there and also I can not filter the data with auto schema collection.
1. I need to understand how we can update collection through alias if we have existing record in collection.
https://typesense.org/docs/0.22.1/api/collections.html#update-a-collection
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:41 PM
Ajeet you can restrict which fields get added to the collection in auto schema detection by using a regex to limit field names instead of using “.*”

Collection alias will work regardless of the number of documents in the collection. It’s just like a symlink
CaptainCodeman
Photo of md5-d3a4ca49ba4aeb3b9d0cb7d846eb0989
CaptainCodeman
03:36 PM
My plan, once past the dev stage, is to have collections with a version number appended which will match one configured in the app. As long as the index is built ahead of the code deploy, it shouldn't need any delay or downtime. Using the alias might be easier, but then I think I'd need to coordinate code-deploy + repointing the alias