Only non-analyzed fields are stored in doc values. For aggregations, sorting, and scripting on an analyzed field, an in-memory structure called field data is used. Unlike doc values, which live on disk, field data lives in the JVM heap memory due to which it is not very scalable and can cause out-of-memory exceptions. Field data is lazily loaded the first time you try to run an aggregation or sort on an analyzed field. Field data is built from the inverted index of the field, which is an expensive operation and can use significant memory.
Non-analyzed fields are, by default, stored in the doc values, and you can use multi-fields to index the same field as analyzed and non-analyzed fields. You can use the analyzed field for searching and the non-analyzed field for aggregations and so on. Field data is disabled by default, and if you need to run aggregations on an analyzed...