Skip to content

Instantly share code, notes, and snippets.

@QuantVI
Created July 23, 2019 23:07
Show Gist options
  • Select an option

  • Save QuantVI/e78b51e7f1d07b45ab6cff23724d0d12 to your computer and use it in GitHub Desktop.

Select an option

Save QuantVI/e78b51e7f1d07b45ab6cff23724d0d12 to your computer and use it in GitHub Desktop.
ElasticSearch query: range of rates paid per night for a room. 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" : {
"zero_or_not": {
"range" : {
"field" : "totalRoomRateInPropertyCurrency",
"ranges" : [
{"from": 0, "to" : 0.1 },
{ "from" : 1}
]
},
"aggs": {
"total_room_rate_range": {
"histogram" : {
"field" : "totalRoomRateInPropertyCurrency",
"interval" : 500
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment