Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save renshuki/5aaa48b9d5f312bc74474abd05c412cb to your computer and use it in GitHub Desktop.
Save renshuki/5aaa48b9d5f312bc74474abd05c412cb to your computer and use it in GitHub Desktop.
Elasticsearch / Watcher - Transform script to extract duplicates (doc_count > 1)
"transform": {
  "script": {
    "source": "return [ 'dups': ctx.payload.aggregations.my_buckets.buckets.stream().filter(t -> { return t.doc_count > 1 }).map(t -> { return ['key': t.key ] }).collect(Collectors.toList()) ]",
    "lang": "painless"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment