Unishox can be used to store more data than the 1GB free limit in Firestore database by compressing text content and storing as a Blob.
Since the size of compressed content will be smaller than the input text, more than 1GB data can be compressed and stored into Firestore. The compression ratio could be between 30 to 60 %, depending on the type of text that is being compressed.
Unishox was developed to individually compress and decompress small strings. In general compression utilities such as zip
, gzip
do not compress short strings well and often expand them. For more details see here:
Unishox - Guaranteed compression for short strings
Unishox can co-exist on the blob with conventional compressed data like gzip
, zip
, bzip2
etc., since the first byte of Unishox is always greater than 127, and so can be distinguished from the other formats. So by using two methods, it is possible to achieve best of both worlds.
See here for Unishox specification.
This method is ideal when you have a lot of text in your document such as comments or remarks.
If you wish to search inside text, Firestore does not support full-text search even for uncompressed text. We will have to depend on third party tools or implement full-text search inside firestore ourselves. See Firestore documentation here.