Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Created December 4, 2015 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrobstory/595e2d2eeb39caa9dcad to your computer and use it in GitHub Desktop.
Save wrobstory/595e2d2eeb39caa9dcad to your computer and use it in GitHub Desktop.
ES Window fn
{:correlation_id 12345 :_id "abcde" :when_recorded "2015-01-01"}
{:correlation_id 12345 :_id "fjhij" :when_recorded "2015-01-02"}
{:correlation_id 12345 :_id "klmno" :when_recorded "2015-01-03"}
{:correlation_id 12345 :_id "pqrst" :when_recorded "2015-01-04"}
{:correlation_id 12345 :_id "uvwxy" :when_recorded "2015-01-05"}
{:ordered_docs {:terms {:field "correlation_id"
:order {:max_date "desc"}
:size 500}
:aggs {:most_recent_doc {:top_hits {:sort [{"when_recorded" {"order" "desc"}}]
:track_scores true
:size 1}}
:max_date {:max {:field "when_recorded"}}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment