Created
December 4, 2014 19:57
-
-
Save dadoonet/836d95a339790e4edb36 to your computer and use it in GitHub Desktop.
Example computing duration with aggs
This file contains hidden or 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
DELETE myindex | |
PUT myindex | |
POST /myindex/travel/_mapping | |
{ | |
"travel": { | |
"properties": { | |
"end_date": { | |
"format": "dateOptionalTime", | |
"type": "date" | |
}, | |
"start_date": { | |
"format": "dateOptionalTime", | |
"type": "date" | |
} | |
} | |
} | |
} | |
POST /myindex/travel/ | |
{ | |
"start_date":"2013-09-11T11:50:00.000Z", | |
"end_date":"2013-09-11T13:08:00.000Z" | |
} | |
GET /myindex/travel/_search?pretty | |
{ | |
"aggs": { | |
"duration": { | |
"histogram": { | |
"interval": 1, | |
"script": "(doc['end_date'].value-doc['start_date'].value)/3600" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment