Last active
September 19, 2018 15:13
-
-
Save mrwithersea/5c4976233259d40b60c4bc9f86922e90 to your computer and use it in GitHub Desktop.
Elasticsearch dedupe earliest event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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