Skip to content

Instantly share code, notes, and snippets.

@QuantVI
Created July 23, 2019 23:00
Show Gist options
  • Save QuantVI/b192f3d5202815a9fa8fd49f13d12f87 to your computer and use it in GitHub Desktop.
Save QuantVI/b192f3d5202815a9fa8fd49f13d12f87 to your computer and use it in GitHub Desktop.
ElasticSearch query: emails per year. Example of an aggregation query returning results in JSON format. These result were passed to "Excel Printer" via "Scribe Report", two other gists you'll find here.
{ "size": 0,
"query": {
"term": {"propertyId":"{{property_id}}"}
},
"aggs": {
"email_recency": {
"date_histogram" : {
"field": "checkinDate",
"interval": "year",
"format" : "yyyy-MM-dd"
},
"aggs" : {
"non_null_email" : {
"value_count" : {
"field" : "email"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment