This page describes webpatser/fledge-pulse-elasticsearch 0.3.0.
Upstream pre-aggregates entries into buckets on write. This driver keeps raw entries and aggregates at read time with upstream's window math, so results match DatabaseStorage. The price is that a 7-day card aggregates a week of raw entries on every read, which is heavier than upstream's bucket reads. On busy applications sample the high-volume recorders, for example the cache interactions recorder's sample_rate in config/pulse.php:
Recorders\CacheInteractions::class => [ 'enabled' => env('PULSE_CACHE_INTERACTIONS_ENABLED', true), 'sample_rate' => env('PULSE_CACHE_INTERACTIONS_SAMPLE_RATE', 1),],
Ordered key lists
Ordered key lists (aggregate(), aggregateTypes()) are exact, even though the entries of a 7-day window live in about eight backing indices, one shard each:
- Elasticsearch picks candidate keys with an ordered
termsaggregation whoseshard_sizeisterms_shard_size(defaultmax(10000, limit * 50)). With no more distinct keys per backing index than that, the candidates are exact. - The aggregates are recomputed for the candidates only, exactly, and the final order and limit come from those values.
Ordering by avg (and by min) cannot be expressed as one Elasticsearch metric, so those reads page through every key in the window with a composite aggregation and order in PHP. That costs more with many distinct keys; the composite page size shrinks for averages of several types so one page stays under search.max_buckets.
Nulls order as upstream does on MySQL: last on desc, first on asc, ties by key ascending. When Elasticsearch picks candidates for count or sum, a key without values ranks as 0, so with more than limit * 2 keys tied at 0 or null the cut can differ from MySQL's.