They are generated at index time (doc values are also generated at index time), and they are also stored on disk.

Elasticsearch uses Apache Lucene for storing and search, and you might want to check out their documentation for more information.

See https://lucene.apache.org/core/7_2_1/index.html

---