Description
Refreshing is one of the trickier fundamental concepts in Elasticsearch: most other storage systems implicitly refresh on the regular write-then-read path so users don't even think about the concept. "Why are my searches not returning recent docs?" comes up repeatedly in conversations with new users.
Something I think that'd help would be to expose the last-refreshed wallclock time of a shard in the shard-level stats, and then expose the minimum of the shard-level last-refreshed times in the index-level stats. That way we can give users a more concrete sense of how stale the data at which they're looking is, and more easily resolve questions about whether they're getting unexpected results because of missing refreshes or some other reason.
The stat in question would be a guarantee that all writes that were acked before the specified time are now exposed to searches. Therefore we would want to capture the wallclock time at the very start of the refresh process, and somehow associate it with the reader that we're opening. I guess we'd want to see this separately for both internal and external refreshes. It might also be useful to try and indicate whether there are any known-unrefreshed writes, since the last-refresh time won't advance on shards that see no writes.
Relates #110688