What kind of data does Spotlight index and store on OS X? With Spotlight it's possible to find almost anything on a Mac computer, but to know everything, Spotlight must keep this information somewhere.

Regarding text (txt, doc, pages, etc,) files, Spotlight indexes not only the file name and metadata, but also the content.

What kind of data does Spotlight store and how does it index text files? Does it keep metadata when the file is being deleted?

When you edit work files from flash drive, does it keep index and content of that files after flash drive was removed?
Spotlight indexes are kept in an invisible folder at the root of the indexed drive: .Spotlight-V100. When you eject a drive, its index is no longer available for searching.

Spotlight relies on importer plug-ins to extract metadata and content from files. The system ships with importers for many common file formats. Third party applications often include importers for their proprietary file types.

What information is extracted from files and given to Spotlight for indexing is left up to the developer of the importer plug-in. This often includes text content, but can really be any information about the file: author, date received, bit rate, image dimensions, ….

Files are re-indexed automatically when modified. Delete files disappear from the index. I would not bet on every trace of a file disappearing as soon as you delete it.