#community-help

Resolving Doubts on File Import and Collection Update in Typesense

TLDR Ariosvaldo asked about import behavior and collection updates in Typesense. Dima clarified import strategies and explained adding optional and non-optional fields to collections.

Powered by Struct AI

1

Aug 22, 2023 (3 months ago)
Ariosvaldo
Photo of md5-70a65c96b293c1aafa37eaaefeaefa64
Ariosvaldo
01:02 PM
Hello my friends, I have two questions, if you could help me with them. What happens if I import the same files again? Does it give any kind of error, duplicate the documents, or replace the old documents if the ID is the same, acting like an update? Lastly, if I update a collection by adding a new field with existing documents, does it update all the documents as well, with the new field?
Dima
Photo of md5-1b62114a658b760944aa7d2b4c274460
Dima
01:09 PM
Hi Ariosvaldo! Typesense supports multiple import strategies:
Image 1 for Hi Ariosvaldo! Typesense supports multiple <https://typesense.org/docs/0.25.0/api/documents.html#index-multiple-documents|import strategies>:

1

Ariosvaldo
Photo of md5-70a65c96b293c1aafa37eaaefeaefa64
Ariosvaldo
03:19 PM
hi Dima, thanks for helping, but what about updating the collection? Will you change all documents by adding the new field?
Dima
Photo of md5-1b62114a658b760944aa7d2b4c274460
Dima
03:22 PM
You can add optional field to the collection, so documents won’t require to have it. Or you can add new field to all documents and then add non-optional field to the collection.

Typesense allows documents to have fields even if they are not in the collection schema, they will be stored on disk and returned when requested, but not indexed until you add them to the collection.