Storing Non-Indexed Document Fields in Typesense

TLDR Thomas asked about unindexed, stored fields. Jason explained that unindexed fields can be stored and returned if the document is a match. Andrew added a limitation about nested fields.

Photo of Thomas
Thomas
Wed, 23 Feb 2022 17:19:33 UTC

Is it possible to have document fields that aren't indexed, but still stored on typesense?

Photo of Jason
Jason
Wed, 23 Feb 2022 17:20:20 UTC

Yup, you can just leave fields out of the schema definition when creating the collection, and then send any additional fields when importing documents

Photo of Jason
Jason
Wed, 23 Feb 2022 17:21:20 UTC

Only fields mentioned in the schema are indexed in memory. Others are stored on disk and returned if the document is a match

Photo of Jason
Jason
Wed, 23 Feb 2022 17:22:05 UTC

Also, these additional non-indexed fields can be nested btw if needed

Photo of Jason
Jason
Wed, 23 Feb 2022 17:22:20 UTC

Only indexed fields have the nested limitation

Photo of Thomas
Thomas
Wed, 23 Feb 2022 17:22:36 UTC

Perfect!!

Photo of Andrew
Andrew
Wed, 23 Feb 2022 17:56:11 UTC

There's one thing I'd like to add if you're planning to have nested fields: the include/exclude feature only works on the top level, so if you have "data" : { "small": "foo", "big": "bar bar"} you can include or exclude "data" but not "data.small" or "data.big". This causes us a few problems, so I wanted to mention iz

Photo of Andrew
Andrew
Wed, 23 Feb 2022 17:59:22 UTC

(other than that, we totally love typesense!)

Photo of Thomas
Thomas
Wed, 23 Feb 2022 18:19:44 UTC

Thanks for the warning!

Photo of Thomas
Thomas
Wed, 23 Feb 2022 18:19:49 UTC

We love it too, superb!