Skip to content

Instantly share code, notes, and snippets.

@mrwithersea
Last active September 19, 2018 15:13
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 mrwithersea/5c4976233259d40b60c4bc9f86922e90 to your computer and use it in GitHub Desktop.
Save mrwithersea/5c4976233259d40b60c4bc9f86922e90 to your computer and use it in GitHub Desktop.
Elasticsearch dedupe earliest event
{
"size": 0,
"query": {
"match": {
"event": "generate_docx"
}
},
"aggs":{
"dedupe_event_by_factfind" : {
"terms":{
"field": "factFindId.keyword",
"size": 10000
},
"aggs":{
"earliest_event_in_range":{
"filter": {
"range": {
"@timestamp": {
"from": "now-7d/d",
"to": "now/d"
}
}
},
"aggs": {
"earliest_event": {
"top_hits":{
"size":1,
"sort": [
{
"@timestamp": {
"order": "asc"
}
}
]
}
}
}
}
}
}
},
"highlight" : {
"fields" : {
"@timestamp" : {}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment